Ask Your Question

gryzly123's profile - activity

2017-05-11 03:53:28 -0600 received badge  Scholar (source)
2017-05-11 03:53:17 -0600 commented answer Issue with detecting combinations of squares

Rotating the entire image seems like an overkill so I rotated the contours instead. The solution works for the complex shapes but sometimes tends to fail on the simple cases (though that just might be because my implementation is faulty somewhere). But yes, this seems like the most correct approach to the situation so I'm marking it as resolved :)

2017-05-08 06:01:09 -0600 asked a question Issue with detecting combinations of squares

Hello,

I am making a program that allows the user to put white square-shaped items (pieces of paper or blocks, whatever he has) on the table and get the pattern made of these blocks detected by the camera (for example one item, two items connected together and so on, including domino-like mazes). What I have at the moment:

  • Getting data from camera and conversion to cv::Mat
  • Conversion from RGB to HSV and thresholding
  • Contour detection through findContours() (using CV_RETR_CCOMP and CV_CHAIN_APPROX_SIMPLE)
  • Conversion from contours to rotated bounding boxes through minAreaRect()

My next idea is to get a list of points (coordinates on camera image) where the blocks are (to determine whether the block is in that particular point, and to possibly detect its color if the requirements change) based on the bounding box and the area it covers. Here's the idea and my issue:

Issue

I know that this is not a bug - the feature works correctly because this is indeed a smaller rectangle that the shape fits in.

My question is: are there any alternatives to minAreaRect() that would take shape edges into consideration?

Thanks in advance :)