Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Generally you are correct. Here is a few hints:

If the chessboard is stationary you do not have to detect it automatically - you can do it once manually and crop the area of interest, like so: croppedImage=wholeImage(Rect(x, y, width, height));

Instead of logical AND use subtraction and thresholding - this will let you ignore minor changes in pixels' brightness or color. Count non zero pixels - if their number exceeds some threshold, you probably have some object in the field of view. Find contours and bounding rectangle. Or iterate through all white pixels and find the leftmost and the rightmost ones - I think it might be faster than finding contours and bounding box, but contours still should run in less than 10 ms (provided you don't get hundreds of separate pixels). Either way you know the left and right boundary of your object, so you know where it is in terms of squares (as you know where the squares are).

Generally you are correct. Here is a few hints:

If the chessboard is stationary you do not have to detect it automatically - you can do it once manually and crop the area of interest, like so: croppedImage=wholeImage(Rect(x, y, width, height));

Instead of logical AND use subtraction and thresholding - this will let you ignore minor changes in pixels' brightness or color. Count non zero pixels - if their number exceeds some threshold, you probably have some object in the field of view. Find contours and bounding rectangle. Or iterate through all white pixels and find the leftmost and the rightmost ones - I think it might be faster than finding contours and bounding box, but contours still should run in less than 10 ms (provided you don't get hundreds of separate pixels). Either way you know the left and right boundary of your object, so you know where it is in terms of squares (as you know where the squares are).

Look at these two sites to learn about OpenCV:

https://www.learnopencv.com/

https://www.pyimagesearch.com/