(1) Does it work if you run
$ ./camera_v4l2_cuda -d /dev/video0 -s 1280x720 -f UYVY & ./camera_v4l2_cuda -d /dev/video1 -s 1280x720 -f UYVY
(2)You have to customize the code into multi-thread. Each thread opens one camera through v4l2 interfaces:
ctx->cam_fdX = open("/dev/videoX", O_RDWR);
ioctl(ctx->cam_fdX, VIDIOC_S_FMT, &fmt);
ioctl(ctx->cam_fdX, VIDIOC_G_FMT, &fmt);
...
Hi DaneLLL,
Yes, it works. Launch and exit it with Ctrl+C, the messages are as follows (some messages were added by me before). As the display window cannot be moved, I’m not sure there is/are one or two windows is/are there.
From the messages below, if I’m not wrong, we can see that before camera1 is opened, start_capture for camera0 was stopped, and also stop_stream for camera0 was executed. Does this mean only one camera is opened at any time?
I believe that, to make multi cameras to work at the same time, modifying start_capture() to do multi-thread processing could be necessary, but it looks not simple to do it. I could be wrong. Please advise.
BTW, I also tried to use this code in different terminals to open 6 cameras to let 6 windows working at the same time, it’s ok.
$ ./camera_v4l2_cuda -d /dev/video0 -s 1280x720 -f UYVY & ./camera_v4l2_cuda -d /dev/video1 -s 1280x720 -f UYVY
[1] 10634
GST stream number is 2
Now device video ... 0
device video0
Try to open camera /dev/video0 ......
GST stream number is 2
Now device video ... 0
device video0
Try to open camera /dev/video0 ......
Opend camera /dev/video0
Opend camera /dev/video0
[INFO] (NvEglRenderer.cpp:110) <renderer0> Setting Screen width 1280 height 720
[INFO] (NvEglRenderer.cpp:110) <renderer0> Setting Screen width 1280 height 720
init_components OK!
WARN: request_camera_buff(): (line:428) Camera v4l2 buf length is not expected
WARN: request_camera_buff(): (line:428) Camera v4l2 buf length is not expected
WARN: request_camera_buff(): (line:428) Camera v4l2 buf length is not expected
WARN: request_camera_buff(): (line:428) Camera v4l2 buf length is not expected
init_components OK!
ERROR: request_camera_buff(): (line:405) Failed to request v4l2 buffers: Device or resource busy (16)
ERROR: prepare_buffers(): (line:568) Failed to set up camera buff
start_stream OK!
Failed to prepare v4l2 buffsApp run failed
^CQuit due to exit command from user!
----------- Element = renderer0 -----------
Total Profiling time = 16.3269
Average FPS = 30.0119
Total units processed = 491
Num. of late units = 0
-------------------------------------
start_capture OK!
stop_stream OK!
Now device video ... 1
device video1
Try to open camera /dev/video1 ......
Opend camera /dev/video1
[INFO] (NvEglRenderer.cpp:110) <renderer0> Setting Screen width 1280 height 720
init_components OK!
WARN: request_camera_buff(): (line:428) Camera v4l2 buf length is not expected
WARN: request_camera_buff(): (line:428) Camera v4l2 buf length is not expected
WARN: request_camera_buff(): (line:428) Camera v4l2 buf length is not expected
WARN: request_camera_buff(): (line:428) Camera v4l2 buf length is not expected
start_stream OK!
----------- Element = renderer0 -----------
Total Profiling time = 0
Average FPS = 0
Total units processed = 0
Num. of late units = 0
-------------------------------------
start_capture OK!
stop_stream OK!
App run was successful
[1]+ Exit 255 ./camera_v4l2_cuda -d /dev/video0 -s 1280x720 -f UYVY