JustAMartin
JustAMartin

Reputation: 13733

Simple algorithm for tracking a rectangular blob

I have created an experimental fast rectangular object tracking system; it will be used for headtracking and controllling objects in 3D engine (Ogre3D).

For now I am able to show to the webcam any kind of bright colored rectangle (text markers are good objects) and system registers basic properties of this object (hue/value/lightness and initial width and height in 0 degrees rotation).

After I have registered the trackable object, I do some simple frame processing to create grayscale probabilty map.

So now I have 2 known things: 1) 4 corners for the last object position (it's always a rectangle but it may be rotated) 2) a pretty rectangular (but still far from perfect) blob which is the brightest in the frame. I can get coordinates of any point of the blob without problems, point detection is stable enough.

I can find a bounding rectangle of the object without problems, but I have a problem with detecting the object corners themselves.

I need the simplest possible (quick&dirty would be great) algorithm to scan the image starting with some known coordinates (a point inside the blob) and detect new 4 x,y coordinates of a "blobish" rectangle corners (not corners of a bounding box but corners of the rectangular blob itself).

Ready-to-use C++ function would be awesome, but somehow google doesn't like me today :(

I think that it would be overkill to use some complicated function form OpenCV library just to extract 4 points of a single rectanglular blob. But if you know a quick and efficient way how to do it using OpenCV (it must be real-time and light on CPU because I'll run the 3D engine at the same time) then I would be really grateful.

Upvotes: 1

Views: 1870

Answers (1)

Adi
Adi

Reputation: 1316

You can apply Hough transform on segmented image to detect lines. Using detected lines you can calculate their intersection to find the corner coordinates of the blob.

Upvotes: 2

Related Questions