1

i am currently trying to detect the boxes in an image and then i want to crop the detected boxes to use it on my project...but, the square detection samples of opencv also detect the lining of the image...so, the question is how can i only detect the boxes in the image??i am using opencv244, c++...just for the record, i've searched in here regarding this topic, but i couldn't get any ideas...any help would be appreciated, thanks! Here is the link to my images...

  1. the original image : http://www.flickr.com/photos/94841531@N08/8631367890/in/photostream/lightbox/
  2. the detected boxes : http://www.flickr.com/photos/94841531@N08/8631368138/in/photostream/lightbox/
Cœur
  • 37,241
  • 25
  • 195
  • 267
joeblack90
  • 13
  • 3

1 Answers1

1

Just ignore the largest square.

In **squares.cpp* there's this function:

static void findSquares( const Mat& image, vector<vector<Point> >& squares )
{

}

which receives a Mat and a vector<vector<Point> >. So after this function is called, the green rectangles were not draw yet in the original image and you can iterate on squares to filter out the largest rectangle found in the input image.

You can take a look at this post to check how to identify the largest square found in the image.

After that, you might want to check this post to extract an area of an image from a vector of squares.

Remember, it's drawSquares() that draws the green stuff on the image.

Community
  • 1
  • 1
karlphillip
  • 92,053
  • 36
  • 243
  • 426
  • hi, i've tested your solution, it worked...but, what should i do if i want to filter out the smallest square in the image??i've tried playing with the code, but nothing seems to change – joeblack90 Apr 09 '13 at 16:23
  • Since that code finds the largest square, finding the smallest square is the exact opposite logic. – karlphillip Apr 09 '13 at 17:33