OpenCV Video capture and fps problem

前端 未结 4 1758
时光取名叫无心
时光取名叫无心 2021-01-06 23:53

I\'m capturing video from my webcam using OpenCV on MacOSX. It works fine but when I try to play on QuickTime my captured video it plays too fast. i.e. I capture from camera

相关标签:
4条回答
  • 2021-01-07 00:02

    I confirm that 10 fps is standard, although I believe it may be because you don't have a camera which captures at more than 10 fps (which is likely the issue).

    This is still strange because I'm using waitkey(30), which should be 33fps, but it's precisely 10.

    0 讨论(0)
  • 2021-01-07 00:06

    Use cvCreateVideoWriter(filename, fourcc, fps, frame size, is color) with fps = 10 , fps = 20 and different values. If you already know the fps value of frames coming from camera use that.

    Problem is that you are getting less frames per second from camera and you're writing more frames to video file

    Regards, Saleh.

    0 讨论(0)
  • 2021-01-07 00:08

    I was having similar performance as you mentioned (about 10fps) and found that successive retrieveFrame() calls were taking forever. I found that getCaptureProperty(CV_CAP_PROP_FPS) was at a default value of 0. I changed this value to 25 using setCaptureProperty(CV_CAP_PROP_FPS,25.0) and was able to capture much faster.

    0 讨论(0)
  • 2021-01-07 00:11

    Could be that compressing the captured video and saving it to a file is too CPU intensive. If that's the case then you really only see 10 FPS in the cvNamedWindow, and only 10 FPS are written to the file. Specifiying 25 FPS in the file will naturally speed playback up some.

    To see if that's really your problem, you could try to save the image data only in memory. I've not tried it out, but I think you'd do that with cvCloneImage().

    You could also try some other format with a lower CPU overhead to save your video:

    CV_FOURCC('P','I','M','1')    = MPEG-1 codec
    CV_FOURCC('M','J','P','G')    = motion-jpeg codec (does not work well)
    CV_FOURCC('M', 'P', '4', '2') = MPEG-4.2 codec
    CV_FOURCC('D', 'I', 'V', '3') = MPEG-4.3 codec
    CV_FOURCC('D', 'I', 'V', 'X') = MPEG-4 codec
    CV_FOURCC('U', '2', '6', '3') = H263 codec
    CV_FOURCC('I', '2', '6', '3') = H263I codec
    CV_FOURCC('F', 'L', 'V', '1') = FLV1 codec
    
    0 讨论(0)
提交回复
热议问题