opencv contour detection python code example
Example: how to draw contours in python opencv
import cv2
image = cv2.imread(“path to image file”)
LUV = cv2.cvtColor(image, cv2.COLOR_BGR2LUV)
edges = cv2.Canny(LUV, 10, 100)
contours, hierarchy = cv2.findContours(edges,cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)
print("Number of Contours is: " + str(len(contours)))
cv2.drawContours(image, contours, 0, (0, 230, 255), 6)
cv2.drawContours(image, contours, 2, (0, 230, 255), 6)
cv2.imshow('Contours', image)
cv2.waitKey(0)