开发者

Tracking rectangles with opencv

开发者 https://www.devze.com 2023-01-06 15:31 出处:网络
I want to define the orientation and location of the rectangle from web-camera. I used the algorithm camshift, but it gave poor results (high dep开发者_Python百科endence on lighting). Tell my what mec

I want to define the orientation and location of the rectangle from web-camera. I used the algorithm camshift, but it gave poor results (high dep开发者_Python百科endence on lighting). Tell my what mechanisms exist to solve this problem. May be exits some source code with similar program?


That only an idea.

I usually think of discrimination to separate the object I want to detect/track. I know you can detect rectangles using other methods.

I prefer to obtain a binarize image that only my object, or a few of them including my target object include.

After that work with blobs. I use cvBlobs library and have option to track blobs and detect blobs. In this library the is a method to obtain angle (orientation), you can try this option.

 double cvAngle(CvBlob *blob);

If your rectangles is moving try to detect it using difference between frames.

Sory for this long speech. I wish this could help you. Jorge


I am not quite sure what "Rectangle" your talking about, some screenshots or a better description would be great:

1: If you have problems with lightning, you should consider developing your own algorithms to neutralize noise, by converting your image to a binary image and do background substraction (depending on setup, and initialization), erode and dilate etc, though thats another long topic which is worth researching on.

2: What you can do is first you will find all the contours around your rectangle, this can be done with the OpenCV function findContours(); (Remember you image MUST be binary) When stored all your contour points, you can afterwards feed the information to another OpenCV function minAreaRect();

Store the information from minAreaRect(), which is a struct of the type RotatedRect; within a variable, and dive into the struct to extract the rotation degree with:

variablename.degree


There is good workable algoritm in sample, OpenCV folder = square.cpp. Need small remake (int main) for video (CvCapture) except image. It works ok.

0

精彩评论

暂无评论...
验证码 换一张
取 消