Можно ли перематывать назад, когда вы нажимаете назначенную клавишу в opencv? У меня есть ниже, но это не перематывает воспроизведение.
def run(self, filepath, fps, width, height, monochrome=False):
video_file = self.read_file(filepath)
previous_frame = None
while (video_file.isOpened()):
ret, frame = video_file.read()
if previous_frame is not None:
pass
previous_frame = frame
if ret:
frame = self.color(frame, monochrome)
final_frame = self.resolution(frame, width, height)
delaytime = self.frame_per_second(fps)
cv2.imshow('frame', final_frame)
key = cv2.waitKey(delaytime)
if key & 0xFF == ord("p"):
cv2.waitKey(234320)
if key & 0xFF == ord("r"):
cv2.set(cv2.CV_CAP_PROP_POS_FRAMES(2, previous_frame))
video_file.release()
cv2.destroyAllWindows()
Приведенный выше код переносит его в предыдущий кадр, но не воспроизводит.