Ask Your Question
4

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

asked 2012-08-10 13:43:13 -0500

Tharaki gravatar image

updated 2012-08-10 14:56:16 -0500

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)

edit retag flag offensive close merge delete

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 ( 2012-08-10 14:04:01 -0500 )edit
1

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

Tharaki gravatar imageTharaki ( 2012-08-10 14:58:32 -0500 )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 ( 2012-08-10 15:31:40 -0500 )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 ( 2012-08-10 15:40:30 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
6

answered 2012-08-10 14:11:46 -0500

updated 2012-08-10 14:15:46 -0500

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.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

3 followers

Stats

Asked: 2012-08-10 13:43:13 -0500

Seen: 4,611 times

Last updated: Aug 10 '12