I've got image of book
And I need to contour it. I've tried this:
- make it gray
- blur
- threshold
- find contours using findContours()
But it doesn't work!
I think it's all up to the blue part on the top, so I tried changing it's color to the color of book with cv.inRange()
, but it didn't work, the contour was still unclear.
Then I tried to change background color ( table color ) to green and try again. It worked nice, but only for that image, if I change background it don't work
Sometimes the contour also included "M" letter, maybe because it's near edge
Is there any way to do it?
gray = cv.cvtColor(image, cv.COLOR_BGR2GRAY)
gray = cv.GaussianBlur(gray, (5, 5), 0)
#at this step I also tried using cv2.Canny(gray, 75, 200)
thresh = cv.adaptiveThreshold(blurred, 255, cv.ADAPTIVE_THRESH_MEAN_C, cv.THRESH_BINARY_INV, 21, 10)
#I also tried usual threshold and THRESH_BINARY, but it works worse
contours, _ = cv.findContours(thresh, cv.RETR_LIST, cv.CHAIN_APPROX_TC89_KCOS)