hi, thanks for your reply, here is what I got from v4l2-ctl
ioctl: VIDIOC_ENUM_FMT
Index : 0
Type : Video Capture
Pixel Format: 'MJPG' (compressed)
Name : Motion-JPEG
Size: Discrete 1920x1080
Interval: Discrete 0.033s (30.000 fps)
Size: Discrete 352x288
Interval: Discrete 0.033s (30.000 fps)
Size: Discrete 432x240
Interval: Discrete 0.033s (30.000 fps)
Size: Discrete 320x184
Interval: Discrete 0.033s (30.000 fps)
Size: Discrete 176x144
Interval: Discrete 0.033s (30.000 fps)
Size: Discrete 160x120
Interval: Discrete 0.033s (30.000 fps)
Size: Discrete 320x240
Interval: Discrete 0.033s (30.000 fps)
Size: Discrete 640x360
Interval: Discrete 0.033s (30.000 fps)
Size: Discrete 640x480
Interval: Discrete 0.033s (30.000 fps)
Size: Discrete 800x600
Interval: Discrete 0.033s (30.000 fps)
Size: Discrete 960x720
Interval: Discrete 0.033s (30.000 fps)
Size: Discrete 1024x768
Interval: Discrete 0.033s (30.000 fps)
Size: Discrete 1280x720
Interval: Discrete 0.032s (31.000 fps)
Size: Discrete 1280x960
Interval: Discrete 0.033s (30.000 fps)
Index : 1
Type : Video Capture
Pixel Format: 'YUYV'
Name : YUYV 4:2:2
Size: Discrete 1920x1080
Interval: Discrete 0.200s (5.000 fps)
Size: Discrete 352x288
Interval: Discrete 0.033s (30.000 fps)
Size: Discrete 432x240
Interval: Discrete 0.033s (30.000 fps)
Size: Discrete 320x184
Interval: Discrete 0.033s (30.000 fps)
Size: Discrete 176x144
Interval: Discrete 0.033s (30.000 fps)
Size: Discrete 160x120
Interval: Discrete 0.033s (30.000 fps)
Size: Discrete 320x240
Interval: Discrete 0.033s (30.000 fps)
Size: Discrete 640x360
Interval: Discrete 0.033s (30.000 fps)
Size: Discrete 640x480
Interval: Discrete 0.033s (30.000 fps)
Size: Discrete 800x600
Interval: Discrete 0.048s (21.000 fps)
Size: Discrete 960x720
Interval: Discrete 0.091s (11.000 fps)
Size: Discrete 1024x768
Interval: Discrete 0.077s (13.000 fps)
Size: Discrete 1280x720
Interval: Discrete 0.111s (9.000 fps)
Size: Discrete 1280x960
Interval: Discrete 0.167s (6.000 fps)
I also modified my code like this
int main()
{
VideoCapture cap(0);
cv::VideoWriter gst_testsink;
gst_testsink.open("appsrc ! queue ! videoconvert ! video/x-raw, format=RGBA ! nvvidconv ! nvoverlaysink ", cv::CAP_GSTREAMER, 0, 3, cv::Size(640, 480));
cv::Mat img;
double fps=0;
cap.set(cv::CAP_PROP_FRAME_WIDTH,640);
cap.set(cv::CAP_PROP_FRAME_HEIGHT,480);
cap.set(cv::CAP_PROP_FPS,30);
while(true)
{
if (!cap.read(img)) {
std::cout<<"Capture read error"<<std::endl;
break;
}
gst_testsink.write(img);
//imshow("CamShow",frame);
fps = cap.get(cv::CAP_PROP_FPS);
cout<<"FPS:"<<fps<<endl;
waitKey(1);
}
gst_testsink.release();
cap.release();
return 0;
}
when I ran the code, the output is
xavier2@xavier2-desktop:~/code/videoCapture/build$ ./videoCapture
[ WARN:0] global /home/nvidia/host/build_opencv/nv_opencv/modules/videoio/src/cap_gstreamer.cpp (933) open OpenCV | GStreamer warning: Cannot query video position: status=0, value=-1, duration=-1
FPS:5
FPS:5
FPS:5
FPS:5
FPS:5
FPS:5
FPS:5
FPS:5
FPS:5
FPS:5
when I set width and height as 640x480 and used gstreamer pipeline I still got 5 fps,
but when I used imshow instead, it became much faster, the print of CAP_PROP_FPS was always 5,
It seemed that cap.set(cv::CAP_PROP_FPS,30) didn’t work