Can't open camera from the docker container

My situation is similar to this problem(I can't use the webcam from the docker container), but the error is different.

I used L4T-ML to build the Yolov5 development environment and installed the required libraries.
I was able to use to identify objects in pictures (as shown in the first command in the picture). But when I try to open the camera, it tells me that the camera cannot be opened.

My env: JetPack 4.5(L4T R32.5.0), l4t-ml:r32.5.0-py3
Could you tell me what should i do?

Hi @Mariaa, what camera are you using? Is it MIPI CSI or USB?

When you started the container, if you manually ran docker run did you mount the V4L2 device with --device /dev/video0 ? Note that the script from jetson-containers does this for you automatically.

It is USB (realsense d435). Sorry I am a newbie, and I failed to understand the meaning of “mount the V4L2 device”, I ran docker run with
docker run -id --name=yolov5 --network host --runtime nvidia -w /home/yolo -v /home/nvidia/yolo/yolov5:/home/yolo
Have I forgotten any steps?

I deleted the container and ran run docker with --device /dev/video0, and finally got the same error.

@Mariaa do you now see the /dev/video0 device inside container? Have you been able to test that V4L2 camera outside of camera using similar/same cv2.VideoCapture code to confirm that it’s working?

I see the /dev/video0 inside container now, but I still got a similar error, it looks like there is an extra sentence VIDEOIO ERROR: V4L2: Pixel format of incoming image is unsupported by OpenCV I tried to use the solution on the Internet export LD_PRELOAD=/usr/lib/aarch64-linux-gnu/libv4l/, but it doesn’t seem to work.

There is no update from you for a period, assuming this is not an issue any more.
Hence we are closing this topic. If need further support, please open a new one.

@Mariaa have you gotten your RealSense camera to work outside of container and that it typically works with V4L2?