Dear all,
Suppose I wish to keep track of multiple shapes that is detected via approxPolyDP in real-time (example: there are 3 individual triangles). How could I go about naming those triangles 1, 2 and 3? As I need to perform an operation starting from the left-most triangle. Here is my base code for shape detection.
canny_white, contours, hierarchy = cv2.findContours(white_mask,cv2.RETR_CCOMP,cv2.CHAIN_APPROX_SIMPLE)
for i in range(0,len(contours)):
approx = cv2.approxPolyDP(contours[i],cv2.arcLength(contours[i],True)*0.02,True)
if(len(approx) == 3):
x,y,w,h = cv2.boundingRect(contours[i])
cv2.putText(frame,"Triangle",(x,y),cv2.FONT_HERSHEY_SIMPLEX,1.5,(255,0,0),2,cv2.LINE_AA)
Thank you.