In preparation for processing the video, I want the user to be able to select the first and last frames to be processed in the video. The trackbard seems like a useful tool for this, but can I use it to read and display specific frames from a video?
Usually I read the video frame by frame and run my processing algorithm on it using the while loop:
cap = cv2.VideoCapture('myvideo.mp4')
while(cap.isOpened()):
ret, frame = cap.read()
This is not conducive to the user quickly checking the video to find a good frame interval for processing.
The trackbard is great for adjusting image processing settings, but if there is a better tool you might think about, please suggest. Below you can see the code for setting the threshold level variable using the track panel.
def onTrackbarChange(trackbarValue):
pass
cv2.createTrackbar( 'threshold level', 'mywindow', 100, 255, onTrackbarChange )
thresholdlevel = cv2.getTrackbarPos('thresh','mywindow')
Is there a way to do something like this?
start_frame = cv2.getTrackbarPos('start-frame','mywindow')
ret, frame = cap.read(start_frame)
cv2.imshow('window', frame)
Ideally, there should be two window panels, one s start_frameand one s stop_frame, each of which is controlled by a track bar.