Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to Build Docker Container with GStreamer-enabled OpenCV for Jetson Platform? #1922

Closed
shaunliew opened this issue Dec 28, 2024 · 0 comments

Comments

@shaunliew
Copy link

Hi @dusty-nv,

I'm working on implementing YOLOv11 with a CSI camera in the Ultralytics Docker container on my Jetson Orin Nano running JetPack 6.1. I notice that your jetson-inference Docker container has OpenCV built with GStreamer support, while the Ultralytics container does not.

Current Setup:

  • Jetson Orin Nano Super Kit (JetPack 6.1 and L4T 36.4.2)
  • CSI camera (IMX219 Raspberry Pi Camera)
  • ultralytics/ultralytics:latest-jetson-jetpack6 Docker image
  • Following your container setup guide with proper device mounts

Issue Description:
I'm unable to access my CSI camera from within the Ultralytics Docker container, but the camera works perfectly on the host system. When using your jetson-inference container setup, everything works correctly. After investigation, I found that the root cause is that OpenCV in the Ultralytics container is built without GStreamer support.

I've mounted all necessary devices and paths:

sudo docker run -it --rm \
    --runtime nvidia \
    --network host \
    --ipc=host \
    -v /tmp/argus_socket:/tmp/argus_socket \
    -v /etc/enctune.conf:/etc/enctune.conf \
    -v /etc/nv_tegra_release:/etc/nv_tegra_release \
    -v /tmp/nv_jetson_model:/tmp/nv_jetson_model \
    -v /var/run/dbus:/var/run/dbus \
    -v /var/run/avahi-daemon/socket:/var/run/avahi-daemon/socket \
    --privileged \
    $DISPLAY_DEVICE $V4L2_DEVICES \
    $t

I've verified that:

  • Camera is visible at /dev/video0 (confirmed with v4l2-ctl --list-devices)
  • GStreamer works in the container (nvgstcapture-1.0 --orientation 2 runs successfully)
  • All necessary devices are mounted properly

However, when trying to access the camera through OpenCV using GStreamer pipeline:

video_capture = cv2.VideoCapture(gstreamer_pipeline(flip_method=0), cv2.CAP_GSTREAMER)

I get Error: Unable to open camera

Root Cause Identified:
The OpenCV in the Ultralytics container lacks GStreamer support, while your jetson-inference container has it enabled:

Your jetson-inference container shows GStreamer support:

Video I/O:
    DC1394:                      NO
    FFMPEG:                      YES
      avcodec:                   YES (58.134.100)
      avformat:                  YES (58.76.100)
      avutil:                    YES (56.70.100)
      swscale:                   YES (5.9.100)
      avresample:                NO
    GStreamer:                   YES (1.20.3)
    v4l/v4l2:                    YES (linux/videodev2.h)

Ultralytics container shows no GStreamer support:

Video I/O:
    DC1394:                      NO
    FFMPEG:                      YES
      avcodec:                   YES (59.37.100)
      avformat:                  YES (59.27.100)
      avutil:                    YES (57.28.100)
      swscale:                   YES (6.7.100)
      avresample:                NO
    GStreamer:                   NO
    v4l/v4l2:                    YES (linux/videodev2.h)

Questions:

  1. Could you share how you configured OpenCV build in your Dockerfile to enable GStreamer support?
  2. Are there specific dependencies or build flags I should include in my Dockerfile?
  3. Do you have any recommendations for building OpenCV with GStreamer support specifically for Jetson platforms?

The goal is to replicate your successful GStreamer-enabled OpenCV setup in my Ultralytics container for YOLOv11 development. Any guidance would be greatly appreciated! Thank you for maintaining this excellent repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant