python - Opencv play the videos too slow -


i wrote program python play videos opencv... works correctly in windows 10. want run raspberry, , problem videos played slow. used omxplayer , plays files smoothly. problem not raspberry.(i think so...)

i simplified code:

print "---playing videos , images---" cap = cv2.videocapture(str(videopath)) while cap.isopened():  ret, frame = cap.read()  if ret == true:   cv2.imshow('videowindow',frame)  if cv2.waitkey(25) & 0xff == ord('q'):   a=2   break  cv2.destroyallwindows() print "!...done...!" 

could tell me problem is?

your loop doesnt care fps video. looks video not cached in ram, read directly disk, thats why video displayed slow. preload video, save frames in list before display them.

get fps video.get(cv2.cv.cv_cap_prop_fps) cv2.x or video.get(cv2.cap_prop_fps) cv3.x.

now, measure time each loop iteration , calculate needed sleep interval. take here: https://www.learnopencv.com/how-to-find-frame-rate-or-frames-per-second-fps-in-opencv-python-cpp/


Comments

Popular posts from this blog

javascript - Create a stacked percentage column -

Optimising Firebase database by automatically overwriting data -

javascript - Angular UI-Grid customTemplate directive causing rows to load slowly/? -