import cv2 capture = cv2.VideoCapture(0) while (True): (ret, frame) = capture.read() grayFrame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) # conversion en noir et blanc (thresh, blackAndWhiteFrame) = cv2.threshold(grayFrame, 127, 255, cv2.THRESH_BINARY) # recherche du controur contours = cv2.findContours(blackAndWhiteFrame, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) [-2] # dessin du contour en rouge for c in contours: cv2.drawContours(frame, [c], -1, (0,0,255), 2) cv2.imshow('contour', frame) if cv2.waitKey(1) == 27: break capture.release() cv2.destroyAllWindows()