Good afternoon. My task is to take a questionnaire and write the selected options into the database, according to the type true or false. With the help of Microsoft Recognize, I get the desired table and then with the help of cm2, I make a crop of the image to understand whether it is true or false.
imagePage = cv2.imread(image.path)
x = int(coordinates[0])
y = int(coordinates[1])
w = int(coordinates[2])
h = int(coordinates[3])
imageCell = imagePage[y:y+h, x:x+w]
cv2.rectangle(imagePage, (x, y), (x + w, y + h), (0, 255, 0), 3)
Table with selected cells:

Next, the idea was to check by the presence of black pixels. If there are many of them, then the item has been selected and it is true. Unfortunately, this does not work, because the border of the lines, which are also considered black pixels, fall.
def countBlackPixels(imageCell):
lowerBlack = np.array([0, 0, 0], np.uint8)
blackRange = cv2.inRange(imageCell, lowerBlack, lowerBlack)
blackPixels = cv2.countNonZero(blackRange)
return blackPixels
For example, one cell with X shows 258 black pixels, the second cell with X shows 98.
Are there any ways to read in the questionnaire the answers to the cells that are presented in the format: X, V?
