Reputation: 11
I have Orange Pi5 and ov13855 mipi camera module. Ubuntu 22.04, OpenCV 4.5.4, Gstreamer 1.20.3
I can capture video from /dev/video11 device via gstreamer:
gst-launch-1.0 v4l2src device=/dev/video11 ! video/x-raw,format=NV12,width=1920,height=1080,framerate=25/1 ! videoconvert ! xvimagesink
and it seems good.
But if i try to capture video via OpenCV it gets only 10 fps
#include <stdio.h>
#include <memory>
#include <sys/time.h>
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
int main(int argc, char **argv)
{
cv::namedWindow("Camera FPS");
cv::VideoCapture capture("v4l2src device=/dev/video11 ! video/x-raw,format=NV12,width=1920,height=1080,framerate=25/1 ! videoconvert ! appsink drop=true", cv::CAP_GSTREAMER);
if (!capture.isOpened())
printf("ERROR: Device is not opened!\n");
struct timeval time;
struct timeval time2;
gettimeofday(&time, nullptr);
auto startTime = time.tv_sec * 1000 + time.tv_usec / 1000;
int frames = 0;
auto beforeTime = startTime;
while (capture.isOpened())
{
cv::Mat img;
gettimeofday(&time2, nullptr);
auto startTime2 = time2.tv_usec;
if (capture.read(img) == false)
break;
gettimeofday(&time2, nullptr);
auto endTime2 = time2.tv_usec;
cv::imshow("Camera FPS", img);
if (cv::waitKey(1) == 'q') //Press q to exit
break;
frames++;
if (frames % 30 == 0)
{
gettimeofday(&time, nullptr);
auto currentTime = time.tv_sec * 1000 + time.tv_usec / 1000;
printf("%f fps/s\n", 30.0 / float(currentTime - beforeTime) * 1000.0);
printf("%lu us capture time\n", (endTime2-startTime2));
beforeTime = currentTime;
}
}
while (true)
{
cv::Mat img;
cv::imshow("Camera FPS", img);
if (cv::waitKey(1) == 'q') //Press q to exit
break;
frames++;
}
gettimeofday(&time, nullptr);
auto endTime = time.tv_sec * 1000 + time.tv_usec / 1000;
printf("Average:\t %f fps/s\n", float(frames) / float(endTime - startTime) * 1000.0);
return 0;
}
I have a guess that ov13855 always sends full matrix resolution 4224x3136 and opencv sacale it to 1920x1080 and can't handle this but its only guess.
v4l2-ctl -d 11 -all
Driver Info:
Driver name : rkisp_v6
Card type : rkisp_mainpath
Bus info : platform:rkisp0-vir1
Driver version : 2.5.1
Capabilities : 0x84201000
Video Capture Multiplanar
Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x04201000
Video Capture Multiplanar
Streaming
Extended Pix Format
Media Driver Info:
Driver name : rkisp0-vir1
Model : rkisp0
Serial :
Bus info :
Media version : 5.10.209
Hardware revision: 0x00000000 (0)
Driver version : 5.10.209
Interface Info:
ID : 0x03000007
Type : V4L Video
Entity Info:
ID : 0x00000006 (6)
Name : rkisp_mainpath
Function : V4L2 I/O
Pad 0x01000009 : 0: Sink
Link 0x0200000a: from remote pad 0x1000004 of entity 'rkisp-isp-subdev' (Unknown V4L2 Sub-Device): Data, Enabled
Priority: 2
Format Video Capture Multiplanar:
Width/Height : 1920/1080
Pixel Format : 'UYVY' (UYVY 4:2:2)
Field : None
Number of planes : 1
Flags :
Colorspace : sRGB
Transfer Function : Rec. 709
YCbCr/HSV Encoding: Rec. 709
Quantization : Full Range
Plane 0 :
Bytes per Line : 3840
Size Image : 4147200
Selection Video Capture: crop, Left 0, Top 0, Width 4224, Height 3136, Flags:
Selection Video Capture: crop_bounds, Left 0, Top 0, Width 4224, Height 3136, Flags:
Selection Video Output: crop, Left 0, Top 0, Width 4224, Height 3136, Flags:
Selection Video Output: crop_bounds, Left 0, Top 0, Width 4224, Height 3136, Flags:
also i try use this code instead gst line:
cv::VideoCapture capture(11);
capture.open(11);
capture.set(cv::CAP_PROP_BUFFERSIZE, 1);
capture.set(cv::CAP_PROP_FPS, 25);
capture.set(cv::CAP_PROP_FOURCC, cv::VideoWriter::fourcc('N','V','1','2'));
capture.set(cv::CAP_PROP_FRAME_WIDTH, 1920);
capture.set(cv::CAP_PROP_FRAME_HEIGHT, 1080);
but nothing changes still 10fps max.
Upvotes: 0
Views: 88