(image, c, i, color=(0, 255, 0), thickness=2)
| 29 | |
| 30 | |
| 31 | def label_contour(image, c, i, color=(0, 255, 0), thickness=2): |
| 32 | # compute the center of the contour area and draw a circle |
| 33 | # representing the center |
| 34 | M = cv2.moments(c) |
| 35 | cX = int(M["m10"] / M["m00"]) |
| 36 | cY = int(M["m01"] / M["m00"]) |
| 37 | |
| 38 | # draw the contour and label number on the image |
| 39 | cv2.drawContours(image, [c], -1, color, thickness) |
| 40 | cv2.putText(image, "#{}".format(i + 1), (cX - 20, cY), cv2.FONT_HERSHEY_SIMPLEX, |
| 41 | 1.0, (255, 255, 255), 2) |
| 42 | |
| 43 | # return the image with the contour number drawn on it |
| 44 | return image |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…