Search code examples
c++opencvwebcamgstreamerframe-rate

Setting gstreamer capsfilter with OpenCV in c++


With the Microsoft LifeCam Cinema (on Ubuntu) in guvcview I get 30fps on 1280x720. In my OpenCV program, I only get 10fps (only queryframe and showimage, no image processing is done). I found out that it is a problem in gstreamer. A solution is to set a capsfilter in gstreamer, in terminal I can do it like this:

gst-launch v4l2src device=/dev/video0 !
'video/x-raw-yuv,width=1280,height=720,framerate=30/1' ! xvimagesink

This works! The question is:

  1. How do I implement this in my c++/OpenCV program?
  2. Or is it possible to set gstreamer to always use this capsfilter?

I already found this question Option 3, but I can't get it working with a webcam.


Solution

  • My bad, I was setting my webcam to 1280x800, which forces it to use YUVY with max 10 fps. Setting it back to 1280x720 in my program gave me 30 fps