Ask Your Question
0

Chessboard black square is NOT detected via contour?

asked 2020-08-26 21:26:43 -0600

Hi, I'm testing some chessboard images using cv2.findContours(), using cnts = cv2.findContours(otsu, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) .

I obtained the binary image via otsu binarization, and did some cv2.HoughLinesP experiments. So far, what I can obtain are as follows:

image description image description image description

My question is: why ONLY the white squares/rectangles have been successfully detected, but those BLACK ones failed to be detected ?

Any possibilities?

Thank you ...

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2020-08-27 04:50:36 -0600

berak gravatar image

findContours expects white foreground and black background.

if you want it the other way round (detect black things) -- invert the image

img = ~img
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2020-08-26 21:26:43 -0600

Seen: 974 times

Last updated: Aug 27 '20