I am using Opencv 3.0 with Python 2.7, for an Optical Character Recognition I need to find points of each contours that are found by findContours method. When I do debugging, I can see there are 208 countours found but I am curious about how can I access them.
Here is the method for capturing contours:
contours,hierarchy = cv2.findContours(thresh,cv2.RETR_LIST,cv2.CHAIN_APPROX_SIMPLE)
I need something like this:
cv2.getcontoursPoints(counter)
You already have your contours point in contours
output which is a python list composed of Numpy array of (x,y)
coordinates. Take care that as said in the documentation you have several contours layers :
Each contour [of
countours
] is stored as a vector of points.
So if you print contours[0]
it will display a list of points. So if you want to access precisely a point in a specific layer you have to detail an index again.