Help with using usb camera with opencv and ml container

Hi

I apologize if this has been answered before, but I am using the latest ml container from ngc, and start it up using the following shell command:

sudo docker run -it --rm --runtime nvidia --network host -v ~/Projects/vision-playground:/playground --device /dev/video0 nvcr.io/nvidia/l4t-ml:r32.5.0-py3

but when I run a simple open_cv program that uses the usb camera at /dev/video0 , I get:

[ 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

(python3:37): Gtk-WARNING **: 15:47:45.254: cannot open display:

If use the jetson-inference image it all works.

Thanks for your help

What happens if you change the script to:

cv2.VideoCapture(0, cv2.CAP_V4L2)

Also, to enable the display in the container, run this when launching the container (note the options that I added):

$ sudo xhost +si:localuser:root
$ sudo docker run -it --rm --runtime nvidia --network host \
-v ~/Projects/vision-playground:/playground \
--device /dev/video0 \
-e DISPLAY=$DISPLAY \
-v /tmp/.X11-unix/:/tmp/.X11-unix \
nvcr.io/nvidia/l4t-ml:r32.5.0-py3

Thanks for the speedy turnaround. Seriously impressed! Even better, it now works. Both suggestions were necessary to getting things to work. Many thanks, and I apologize if this was all documented somewhere.

Is there an easy way to pull the aruco library in? (open-cv contrib?)

bb