Closed mythrex closed 6 years ago
Found a work around. Instead for sorting top to bottom first. Sort left to right first. This will sort all the countours form left to right such that first contour is 15a and 15th countour is 1a and 16th is 30a.
Then sort from top to bottom
# sort the question contours from left to right
questionCnts = contours.sort_contours(questionCnts)[0]
# sort the first 4 countours left to right
e = contours.sort_contours(questionCnts[0:240], method='top-to-bottom')[0]
cv2.drawContours(paper, questionCnts[0:16], -1, 255, -1)
It works but don't understand fully why? :)
The problem is not resolved till now.
Now the contours are sorted as:
1A-> questionCnts[0]
1B-> questionCnts[1]
..
Now here is the twist
16A-> questionCnts[5]
questionCnts[104] will be .. that's right 37A
This code should show question 1 A contour but instead it shows some random contour. See in pic which contour is being displayed.
This code should show question 1 B contour but instead it shows some random contour. but instead the following has been showing.