0

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.

2

2 Answers 2

4

The normal way would be to detect edges with a canny filter then a hough transform to find lines and then find pairs of lines with slopes that are 90deg different

Sign up to request clarification or add additional context in comments.

2 Comments

Sir thank you very much for your reply. i used hough transform for image processing? but is that working for video processing?
@Tk1988 - video is just images. If speed matters you might use another technique to quickly check if the square is in the same place as the last frame and if not do Hough again. Or you can limit the Hough search space to parameters near to the last hit
0

The code for square detection ( specifically rectangle, you can modify a little bit to work it for squares only) comes directly with opencv samples and you get it when you download the OpenCV library.

You didn't specify the language you work. But the code comes in Python and C++.

Python , C++

How it works:

  • Split image in to R,G,B plane
  • For each plane, threshold image for a range values in 0 to 255
  • Find the contours, approximate, and select the ones with only 4 points
  • Find cosine of angle between all the lines of the contour and check if close to 90
  • If so, it is rectangle
  • If you want square, check if its all sides are almost equal.

It works pretty well. And if you have seen this, and this is not what you want, update your question with more specific details, including some test images.

Hope it helps!!!

2 Comments

There is a large number of examples on Stackoverflow that shows how to achieve these 2 tasks separately, I talk about them here, when I replied his other question. I believe this question right here is a duplicate.
Yeah.. just checked that link. Link to square detection clearly given in your answer. There was no need to ask this question, unless he wanted something else.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.