First time here? Check out the FAQ!

Ask Your Question
4

How to detect square in a video using c++ and opencv?

asked Aug 10 '12

Tharaki gravatar image

updated Aug 10 '12

I want to build an program that can detect square shape object in a video. i used SURF algorithm for that. but that only detect key points.i want to detect square shape objects which are situated near the road. As a example road signs. the program simply check whether the frame that taken by camera (which is putting inside the vehicle) has square sign or not.(if that frame has square shape object then frame is sent to next function, else delete that)

Preview: (hide)

Comments

Could you please attach examples of images? Should detection be robust to different scaling, rotations, affine and perspective distortions?

Ilya Lysenkov gravatar imageIlya Lysenkov (Aug 10 '12)edit
1

thank you very much for helping. i attached an example to this question.

Tharaki gravatar imageTharaki (Aug 10 '12)edit
1

Thank you, it helps to understand the problem better. Both Chamfer Matching and Line2D should work correctly with such images. Chamfer Matching is a classic algorithm for edge-based detection and Line2D is a state-of-the-art algorithm published at ICCV 2011. I would recommend to use Line2D because it is more robust but you can try both algorithms for this task.

Ilya Lysenkov gravatar imageIlya Lysenkov (Aug 10 '12)edit

Thank you very much.now on words i'm going to study about both Chamfer Matching and Line2D. i think i could find solution from them.

Tharaki gravatar imageTharaki (Aug 10 '12)edit

1 answer

Sort by » oldest newest most voted
7

answered Aug 10 '12

updated Aug 10 '12

If shape is the most distinguishable feature then you should use edges to detect such an object. A simple and fast approach is to use Chamfer Matching which is available in the OpenCV contrib module. You should specifiy square as a template and then this algorithm will find a square in Canny edges of a test image. See a sample chamfer.cpp how to use this function.

Another solution is to use the Line2D algorithm from the OpenCV objdetect module (see a sample linemod.cpp). This algorithm is more robust in cluttered scenes.

Preview: (hide)

Question Tools

3 followers

Stats

Asked: Aug 10 '12

Seen: 5,669 times

Last updated: Aug 10 '12