Identify numbers within polygon shapes with OpenCV

Viewed 80

I would like to identify a house number within a block of houses given a map image. I was able to draw the contours but I am kind of stuck on how to proceed to identify a house numbers from within the contours. Any help is much appreciated. Here is what I have tried so far -

import numpy as np
from skimage import io, measure, morphology
from skimage.io import imsave, imread

image=cv2.imread('MAP.PNG')

gray=cv2.cvtColor(image,cv2.COLOR_BGR2GRAY)
gray=cv2.cvtColor(image,cv2.COLOR_BGR2GRAY)
edged=cv2.Canny(gray,200,200)
cv2.imshow('canny edges',edged)
cv2.waitKey(0)

contours, hierarchy = cv2.findContours(edged,cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_NONE)
cv2.imshow('canny edges after contouring', edged)
cv2.waitKey(0)

print(contours)
print('Numbers of contours found=' + str(len(contours)))
#use -1 as the 3rd parameter to draw all the contours
cv2.drawContours(image,contours,-1,(0,255,0),3)
cv2.imshow('contours',image)
cv2.waitKey(0)
cv2.destroyAllWindows()

enter image description here

0 Answers
Related