I am trying to read numbers from simple attached image.
For this I am trying to find pentagon which holds number. However when I am trying to find pentagon using opencv findcontour function it is not giving correct values. I tried various permutation with that function. None of that worked.
I have tried following so far:
import cv2 as cv
import numpy as np
im = cv.imread(r'out.jpg')
imgray = cv.cvtColor(im, cv.COLOR_BGR2GRAY)
ret, thresh = cv.threshold(imgray, 200, 255, 0)
contours, hierarchy = cv.findContours(thresh, cv.RETR_LIST , cv.CHAIN_APPROX_SIMPLE)
for c in contours:
print(len(c))
output: 1 1 1 1 1 1 1 1 38 36 1 1 85 87 128 133 55 47 4 4 7 4 4 4
None of this is 5, so above points can't be pentagon.
can you please help me if I am making any mistake?


