I’m using the program squares.c available in the samples of OpenCV libraries. It works well with every image, but I really can’t figure it out why it doesn’t recognize the square drawn in that image
The RESULT image (in red)
http://img267.imageshack.us/img267/8016/resultuq.jpg
As you can see, the square is NOT detected.
After the detection I need to extract the area contained in the square…How is it possible without a ROI?



The source code below presents a small variation of the Square Detector program. It’s not perfect, but it illustrates one way to approach your problem.
You can diff this code to the original and check all the changes that were made, but the main ones are:
Decrease the number of threshold levels to 2.
In the beginning of
findSquares(), dilate the image to detect the thin white square, and then blur the entire image so the algorithm doesn’t detect the sea and the sky as individual squares.Once compiled, run the application with the following syntax:
./app <image>Outputs: