How can I know which camera is used when multiple cameras are plugged?

My board and system information is as below:
Model: NVIDIA Orin Nano Developer Kit - Jetpack 5.1.1 [L4T 35.3.1]
NV Power Mode[1]: 7W
Serial Number: [XXX Show with: jetson_release -s XXX]
Hardware:

  • 699-level Part Number: 699-13767-0005-300 K.2
  • P-Number: p3767-0005
  • Module: NVIDIA Jetson Orin Nano (Developer kit)
  • SoC: tegra23x
  • CUDA Arch BIN: 8.7
  • Codename: P3768

I have imx219 CSI camera and another USB camera in my system.

In my code, I use gstreamer/nvarguscamerasrc element to get CSI camera video. But if I connect the USB camera, I often got failure to open the CSI camera(gstreamer/nvarguscamerasrc). If I dont connect the USB camera, I have no any issues.

From the error log, looks nvargus-daemon trying to open v4l2 camera which is the USB camera. How can I let gstreamer/nvarguscamerasrc open the CSI camera instead of USB camera. The camera ID(/dev/video#) for CSI and USB camera may be changed, so I can’t use this ID to tell the CSI camera.

hello harry_xiaye,

you may refer to Camera Architecture Stack.
gstreamer/nvarguscamerasrc element it doesn’t support with USB cameras.

I assume you’ve USB camera connected before system power-up, right?

@JerryChang ,

Yes. The USB camera is connected before the system power up.

The error is from argus-daemon. I copied some argus-daemon log below.

Jan 25 11:32:14 txkj-desktop tx_acam[9473]: [getCapGstreamerStr] Cap gstreamer string: nvarguscamerasrc ! video/x-raw(memory:NVMM), width=(int)1640, height=(int)1232, format=(string)NV12, framerate=(fraction)30/1 ! nvvidconv flip-method=2 ! video/x-raw, width=(int)800, height=(int)600, format=(string)BGRx ! videoconvert ! appsink
Jan 25 11:32:14 txkj-desktop nvargus-daemon[9487]: === NVIDIA Libargus Camera Service (0.99.33)=== Listening for connections…=== SaturnAcam[9473]: Connection established (FFFF89A5D900)OFParserListModules: module list: /proc/device-tree/tegra-camera-platform/modules/module0
Jan 25 11:32:14 txkj-desktop nvargus-daemon[9487]: OFParserListModules: module list: /proc/device-tree/tegra-camera-platform/modules/module1
Jan 25 11:32:14 txkj-desktop nvargus-daemon[9487]: (NvCamV4l2) Error ModuleNotPresent: V4L2Device not available (in /dvs/git/dirty/git-master_linux/camera/utils/nvcamv4l2/v4l2_device.cpp, function verifyDeviceCaps(), line 206)
Jan 25 11:32:14 txkj-desktop nvargus-daemon[9487]: (NvCamV4l2) Error ModuleNotPresent: (propagating from /dvs/git/dirty/git-master_linux/camera/utils/nvcamv4l2/v4l2_device.cpp, function initialize(), line 66)
Jan 25 11:32:14 txkj-desktop nvargus-daemon[9487]: (NvCamV4l2) Error ModuleNotPresent: V4L2Device not available (in /dvs/git/dirty/git-master_linux/camera/utils/nvcamv4l2/v4l2_device.cpp, function verifyDeviceCaps(), line 206)
Jan 25 11:32:14 txkj-desktop nvargus-daemon[9487]: (NvCamV4l2) Error ModuleNotPresent: (propagating from /dvs/git/dirty/git-master_linux/camera/utils/nvcamv4l2/v4l2_device.cpp, function initialize(), line 66)
Jan 25 11:32:14 txkj-desktop nvargus-daemon[9487]: OFParserGetVirtualDevice: NVIDIA Camera virtual enumerator not found in proc device-tree
Jan 25 11:32:14 txkj-desktop nvargus-daemon[9487]: ---- imager: No override file found. ----
Jan 25 11:32:14 txkj-desktop nvargus-daemon[9487]: ---- imager: No override file found. ----
Jan 25 11:32:14 txkj-desktop nvargus-daemon[9487]: (NvCamV4l2) Error ModuleNotPresent: V4L2Device not available (in /dvs/git/dirty/git-master_linux/camera/utils/nvcamv4l2/v4l2_device.cpp, function findDevice(), line 256)
Jan 25 11:32:14 txkj-desktop nvargus-daemon[9487]: (NvCamV4l2) Error ModuleNotPresent: (propagating from /dvs/git/dirty/git-master_linux/camera/utils/nvcamv4l2/v4l2_device.cpp, function initialize(), line 60)
Jan 25 11:32:14 txkj-desktop nvargus-daemon[9487]: (NvOdmDevice) Error ModuleNotPresent: (propagating from dvs/git/dirty/git-master_linux/camera-partner/imager/src/devices/V4L2SensorViCsi.cpp, function initialize(), line 107)
Jan 25 11:32:14 txkj-desktop nvargus-daemon[9487]: NvPclDriverInitializeData: Unable to initialize driver v4l2_sensor
Jan 25 11:32:14 txkj-desktop nvargus-daemon[9487]: NvPclInitializeDrivers: error: Failed to init camera sub module v4l2_sensor
Jan 25 11:32:14 txkj-desktop nvargus-daemon[9487]: NvPclStartPlatformDrivers: Failed to start module drivers
Jan 25 11:32:14 txkj-desktop nvargus-daemon[9487]: NvPclDriver_V4L2_Focuser_Stub_Close: Invalid NULL input pPclDriver
Jan 25 11:32:14 txkj-desktop nvargus-daemon[9487]: NvPclStateControllerOpen: Failed ImagerGUID 0. (error 0xA000E)
Jan 25 11:32:14 txkj-desktop nvargus-daemon[9487]: NvPclOpen: PCL Open Failed. Error: 0xf
Jan 25 11:32:14 txkj-desktop nvargus-daemon[9487]: SCF: Error BadParameter: Sensor could not be opened. (in src/services/capture/CaptureServiceDeviceSensor.cpp, function getSourceFromGuid(), line 689)
Jan 25 11:32:14 txkj-desktop nvargus-daemon[9487]: SCF: Error BadParameter: (propagating from src/services/capture/CaptureService.cpp, function addSourceByGuid(), line 453)
Jan 25 11:32:14 txkj-desktop nvargus-daemon[9487]: SCF: Error BadParameter: (propagating from src/api/CameraDriver.cpp, function addSourceByIndex(), line 333)
Jan 25 11:32:14 txkj-desktop nvargus-daemon[9487]: SCF: Error BadParameter: (propagating from src/api/CameraDriver.cpp, function getSource(), line 505)
Jan 25 11:32:14 txkj-desktop nvargus-daemon[9487]: ---- imager: No override file found. ----
Jan 25 11:32:14 txkj-desktop nvargus-daemon[9487]: initializeDevNode: Failed to open dev node ‘/dev/camera/video1’; No such file or directory, trying alternate default location
Jan 25 11:32:14 txkj-desktop nvargus-daemon[9487]: (NvCamV4l2) Error BadParameter: Control 10094858 not found (in /dvs/git/dirty/git-master_linux/camera/utils/nvcamv4l2/v4l2_device.cpp, function findControlById(), line 1874)
Jan 25 11:32:14 txkj-desktop nvargus-daemon[9487]: (NvCamV4l2) Error BadParameter: (propagating from /dvs/git/dirty/git-master_linux/camera/utils/nvcamv4l2/v4l2_device.cpp, function getControlRange(), line 331)
Jan 25 11:32:14 txkj-desktop nvargus-daemon[9487]: initialize: focus query failed
Jan 25 11:32:14 txkj-desktop nvargus-daemon[9487]: SCF: Error BadParameter: (propagating from src/services/capture/CaptureServiceDeviceSensor.cpp, function open(), line 189)
Jan 25 11:32:14 txkj-desktop nvargus-daemon[9487]: SCF: Error BadParameter: (propagating from src/services/capture/CaptureServiceDeviceSensor.cpp, function getSourceFromGuid(), line 686)
Jan 25 11:32:14 txkj-desktop nvargus-daemon[9487]: SCF: Error BadParameter: (propagating from src/services/capture/CaptureService.cpp, function addSourceByGuid(), line 453)
Jan 25 11:32:14 txkj-desktop nvargus-daemon[9487]: SCF: Error BadParameter: (propagating from src/api/CameraDriver.cpp, function addSourceByIndex(), line 333)
Jan 25 11:32:14 txkj-desktop nvargus-daemon[9487]: SCF: Error BadParameter: (propagating from src/api/CameraDriver.cpp, function getSource(), line 505)
Jan 25 11:32:14 txkj-desktop nvargus-daemon[9487]: ---- imager: No override file found. ----
Jan 25 11:32:14 txkj-desktop nvargus-daemon[9487]: initializeDevNode: Failed to open dev node ‘/dev/camera/video2’; No such file or directory, trying alternate default location
Jan 25 11:32:14 txkj-desktop nvargus-daemon[9487]: (NvCamV4l2) Error NotSupported: Must be capture/output devices (in /dvs/git/dirty/git-master_linux/camera/utils/nvcamv4l2/v4l2_device.cpp, function setActiveBufferType(), line 813)
Jan 25 11:32:14 txkj-desktop nvargus-daemon[9487]: (NvCamV4l2) Error NotSupported: (propagating from /dvs/git/dirty/git-master_linux/camera/utils/nvcamv4l2/v4l2_device.cpp, function initialize(), line 68)
Jan 25 11:32:14 txkj-desktop nvargus-daemon[9487]: (NvOdmDevice) Error NotSupported: (propagating from dvs/git/dirty/git-master_linux/camera-partner/imager/src/devices/V4L2SensorNonViCsi.cpp, function initialize(), line 146)
Jan 25 11:32:14 txkj-desktop nvargus-daemon[9487]: NvPclDriverInitializeData: Unable to initialize driver v4l2_sensor_usb
Jan 25 11:32:14 txkj-desktop nvargus-daemon[9487]: NvPclInitializeDrivers: error: Failed to init camera sub module v4l2_sensor_usb
Jan 25 11:32:14 txkj-desktop nvargus-daemon[9487]: NvPclStartPlatformDrivers: Failed to start module drivers
Jan 25 11:32:14 txkj-desktop nvargus-daemon[9487]: NvPclStateControllerOpen: Failed ImagerGUID 3. (error 0x2)
Jan 25 11:32:14 txkj-desktop nvargus-daemon[9487]: NvPclOpen: PCL Open Failed. Error: 0xf
Jan 25 11:32:14 txkj-desktop nvargus-daemon[9487]: SCF: Error BadParameter: Sensor could not be opened. (in src/services/capture/CaptureServiceDeviceSensor.cpp, function getSourceFromGuid(), line 689)
Jan 25 11:32:14 txkj-desktop nvargus-daemon[9487]: SCF: Error BadParameter: (propagating from src/services/capture/CaptureService.cpp, function addSourceByGuid(), line 453)
Jan 25 11:32:14 txkj-desktop nvargus-daemon[9487]: SCF: Error BadParameter: (propagating from src/api/CameraDriver.cpp, function addSourceByIndex(), line 333)
Jan 25 11:32:14 txkj-desktop nvargus-daemon[9487]: SCF: Error BadParameter: (propagating from src/api/CameraDriver.cpp, function getSource(), line 505)
Jan 25 11:32:14 txkj-desktop nvargus-daemon: E/ libnvphs:socket: Error[2]: socket connection /var/lib/nvphs/nvphsd.ctl to PHS failed: No such file or directory
Jan 25 11:32:14 txkj-desktop nvargus-daemon: D/ libnvphs:socket: Warning: connecting to Power Hinting Service failed. Is PHS running?
Jan 25 11:32:14 txkj-desktop nvargus-daemon[9487]: === SaturnAcam[9473]: CameraProvider initialized (0xffff847a01c0)SCF: Error BadValue: NvPHSSendThroughputHints (in src/common/CameraPowerHint.cpp, function sendCameraPowerHint(), line 56)
Jan 25 11:32:14 txkj-desktop nvargus-daemon: E/ libnvphs:socket: Error[2]: socket connection /var/lib/nvphs/nvphsd.ctl to PHS failed: No such file or directory
Jan 25 11:32:14 txkj-desktop nvargus-daemon: D/ libnvphs:socket: Warning: connecting to Power Hinting Service failed. Is PHS running?
Jan 25 11:32:14 txkj-desktop nvargus-daemon: E/ libnvphs: Error: NvPHSSendThroughputHints[usecase=camera, hint=MinCPU, value=4294967295, timeout_ms=1000]: queue_or_send() failed

hello harry_xiaye,

you cannot uses nvarguscamerasrc plugin to enable USB camera.
please try below instead.
$ gst-launch-1.0 v4l2src device=/dev/video1 num-buffers=150 ! 'video/x-raw, width=1920, height=1080, framerate=30/1, format=YUY2' ! xvimagesink -e

BTW,
it’s v4l to register USB camera to /dev/videoX while system booting-up, normally it should be process after CSI camera registration.
for example,

// To register CSI camera, IMX185
[   13.982816] imx185 30-001a: probing v4l2 sensor
[   13.983159] imx185 30-001a: tegracam sensor driver:imx185_v2.0.6
[   14.018190] imx185 30-001a: Detected IMX185 sensor
...
// To register USB camera.
[   14.525236] uvcvideo: Found UVC 1.00 device Logitech BRIO (046d:085e)
[   14.564363] usbcore: registered new interface driver uvcvideo

you may running with… $ v4l2-ctl -d /dev/video0 --list-formats-ext to dump sensor capability.
please check the format types for confirmation.
for instance,
Bayer CSI camera.

$ v4l2-ctl -d /dev/video0 --list-formats-ext
ioctl: VIDIOC_ENUM_FMT
	Type: Video Capture

	[0]: 'RG10' (10-bit Bayer RGRG/GBGB)
		Size: Discrete 1920x1080
			Interval: Discrete 0.033s (30.000 fps)

USB camera.

$ v4l2-ctl -d /dev/video1 --list-formats-ext
ioctl: VIDIOC_ENUM_FMT
	Type: Video Capture

	[0]: 'YUYV' (YUYV 4:2:2)
		Size: Discrete 640x480
			Interval: Discrete 0.033s (30.000 fps)

besides,
you may adding some delay to the uvc driver, so that you’ll have USB camera always register after CSI camera.

@JerryChang ,

I dont want to use nvarguscamerasrc for USB camera. But my system has a CSI camera, and another USB camera.

In my code, I want to use nvarguscamerasrc to handle CSI camera, but I am not sure if I use nvarguscamerasrc to open camera device, it will only open the CSI camera, wont touch the USB camera.

In my system, the CSI camera device may not be started before USB camera. Because the USB camear is a thermal camera, it takes long time to power up.

hello harry_xiaye,

nvarguscamerasrc won’t touch the USB camera. you should double check you’ve assign correct video node to launch the stream.

@JerryChang ,

The nvarguscamerasrc has property sensor_id, if I dont set this property, it will use the default value which is 0. This should open the device /dev/video0, right? If so, my code (gstreamer/nvarguscamerasrc) always open /dev/video0 for CSI camera. But if the USB camera is first started, it will take the device /dev/video0. I think this will cause problem, right?

hello harry_xiaye,

not really, nvarguscamerasrc it actually checks the position property,
let me taking an example with a three-camera system, it has position property settings with… bottom, top, and center.
it’s sensor-id=0 to enable bottom, sensor-id=1 to enable top, and sensor-id=2 to enable center…etc, and so on.

So if I have a CSI camera and a USB camera, what will be sensor-id for CSI camera? Is it fixed or it will be changed?

there’s no property for USB cameras.
as demonstration in comment #5. it’s UVC driver to register USB camera as video node, it’ll register to linux kernel as /dev/videoN. the only approach is adding some delay to the UVC driver, so that you’ll have USB camera always register behind CSI camera.

If I only have one CSI camera and use sensor-id=0, nvarguscamerasrc can get the correct CSI camera device whatever its device name is /dev/video0 or /dev/video1? Or we still make sure the CSI camera device is /dev/video0?

hello harry_xiaye,

you meant the dual camera combination with CSI camera + USB camera?
I did not fully test it, but, as long as you’ve using correct position property setting, nvarguscamerasrc it should enable CSI camera correctly no matter it’s located in video0 or video1.
for sure, you can have USB camera always register behind CSI camera.

“for sure, you can have USB camera always register behind CSI camera.” – if I can’t ensure the USB camera register behind CSI camera, I may get problems? Why will it cause problems?

for clarification, as mentioned above, I did not fully test it.

hello harry_xiaye,

BTW,
you may give it a try to assign the specific video node number for UVC driver.
for instance,
$public_sources/kernel_src/kernel/kernel-5.10/drivers/media/usb/uvc/uvc_driver.c

        ret = video_register_device(vdev, VFL_TYPE_VIDEO, -1); 
        if (ret < 0) { 
                uvc_printk(KERN_ERR, "Failed to register %s device (%d).\n",
                           v4l2_type_names[type], ret);
                return ret; 
        }

the value -1 within video_register_device() function means it’ll find a available number to register the video node automatically.
please try specify 99, or any specific device node number is desired for your USB camera use-case.
for more details, you may dig into $public_sources/kernel_src/kernel/kernel-5.10/include/media/v4l2-dev.h of __video_register_device() for function description.

With this way, I can only have one USB camera on my board, right?

yes, please give it a try.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.