I am new to python and opencv, I want to create a track bar to manage the hierarchy of the cv2.findContours function, but I don’t know how to add it to the source code this is the code:
import cv2
import cv2.cv as cv
cv2.namedWindow("test")
vc = cv2.VideoCapture(2);
retVal, frame = vc.read();
while True:
if frame is not None:
imgray = cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY)
ret,thresh = cv2.threshold(imgray,127,255,0)
contours, hierarchy = cv2.findContours(thresh,cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_SIMPLE)
cv2.drawContours(frame, contours, -1, (0,255,0), 2)
cv2.imshow("test", frame)
rval, frame = vc.read()
if cv2.waitKey(1) & 0xFF == 27:
break
cv.DestroyAllWindows()
early
source
share