Frame from video file
I am new to opencv, really appreciate your help. I am trying to detect the frame number in video file when the contour was detected and trim the video file based on frame [2 frame before the contour was detected and 2 frame after contour].
ret, frame=cap.read()
frame[frame<=thresholds]=0
mask = object_detector.apply(frame)
_, mask = cv2.threshold(mask,254,255,cv2.THRESH_BINARY) #mask the backgroubd to the color ratio of 255 for complete black color
contours,_ = cv2.findContours(mask, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
res = cv2.bitwise_and(frame,frame,mask=mask)
for cnt in contours:
area = cv2.contourArea(cnt)
if area>100: #detect for the flashes above 1000pixel
cv2.drawContours(frame, [cnt], -1, (0,255,0),2)
python