TX2 NX - CSI Camera inside Docker Container

Hello all.

We are trying to get an IMX219 CSI camera running inside a docker container.

The docker container will be deployed on Balena, and it will not have nvidia runtime, so all the dependencies need to be installed within the container.

This is the dockerfile that we have used successfully in the Nano. I used this one as a template:

FROM balenalib/jetson-nano-ubuntu-node:14-bionic as buildstep

WORKDIR /usr/src/app

# Don't prompt with any configuration questions
ENV DEBIAN_FRONTEND noninteractive

# Download and install BSP binaries for L4T 32.5.1
RUN apt-get update && apt-get install -y wget tar lbzip2 python3 libegl1 binutils && \
  wget https://developer.nvidia.com/embedded/l4t/r32_release_v5.2/t210/jetson-210_linux_r32.5.2_aarch64.tbz2 && \       
  tar xf jetson-210_linux_r32.5.2_aarch64.tbz2 && \
  cd Linux_for_Tegra && \
  sed -i 's/config.tbz2\"/config.tbz2\" --exclude=etc\/hosts --exclude=etc\/hostname/g' apply_binaries.sh && \
  sed -i 's/install --owner=root --group=root \"${QEMU_BIN}\" \"${L4T_ROOTFS_DIR}\/usr\/bin\/\"/#install --owner=root --group=root \"${QEMU_BIN}\" \"${L4T_ROOTFS_DIR}\/usr\/bin\/\"/g' nv_tegra/nv-apply-debs.sh && \
  sed -i 's/LC_ALL=C chroot . mount -t proc none \/proc/ /g' nv_tegra/nv-apply-debs.sh && \
  sed -i 's/umount ${L4T_ROOTFS_DIR}\/proc/ /g' nv_tegra/nv-apply-debs.sh && \
  sed -i 's/chroot . \//  /g' nv_tegra/nv-apply-debs.sh && \
  ./apply_binaries.sh -r / --target-overlay && cd .. \
  rm -rf jetson-210_linux_r32.5.2_aarch64.tbz2 && \
  rm -rf Linux_for_Tegra && \
  echo "/usr/lib/aarch64-linux-gnu/tegra" > /etc/ld.so.conf.d/nvidia-tegra.conf && \
  echo "/usr/lib/aarch64-linux-gnu/tegra-egl" >> /etc/ld.so.conf.d/nvidia-tegra.conf && \
  ldconfig


# Install CUDA, CUDA compiler and some utilities
RUN \
  apt-get update && apt-get install -y cuda-toolkit-10-2 cuda-compiler-10-2 \
  lbzip2 xorg-dev \
  cmake wget unzip \
  libgtk2.0-dev \
  libavcodec-dev \
  libgstreamer1.0-dev \
  libgstreamer-plugins-base1.0-dev \
  libjpeg-dev \
  libpng-dev \
  libtiff-dev \
  libdc1394-22-dev -y --no-install-recommends && \
  wget https://github.com/opencv/opencv/archive/4.0.1.zip && \
  unzip 4.0.1.zip && rm 4.0.1.zip

# COPY ./build-resources/4.0.1-contrib.zip ./opencv_modules.4.0.1.zip
RUN \
  wget https://github.com/opencv/opencv_contrib/archive/4.0.1.zip -O opencv_modules.4.0.1.zip && \
  unzip opencv_modules.4.0.1.zip && rm opencv_modules.4.0.1.zip && \
  export CUDA_HOME=/usr/local/cuda-10.2/ && \
  export LD_LIBRARY_PATH=${CUDA_HOME}/lib64 && \
  PATH=${CUDA_HOME}/bin:${PATH} && export PATH && \
  mkdir -p opencv-4.0.1/build && cd opencv-4.0.1/build && \
  cmake -D WITH_CUDA=ON -D CUDA_ARCH_BIN="5.3"  -D BUILD_LIST=cudev,highgui,videoio,cudaimgproc,ximgproc -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-4.0.1/modules -D CUDA_ARCH_PTX="" -D WITH_GSTREAMER=ON -D WITH_LIBV4L=ON -D BUILD_TESTS=OFF -D BUILD_PERF_TESTS=OFF -D BUILD_SAMPLES=OFF -D BUILD_EXAMPLES=OFF -D CMAKE_BUILD_TYPE=RELEASE -D WITH_GTK=ON -D BUILD_DOCS=OFF -D CMAKE_INSTALL_PREFIX=/usr/local .. && \
 make -j32 && make install && \
  cp /usr/src/app/opencv-4.0.1/build/bin/opencv_version /usr/src/app/ && \
  rm -rf /usr/src/app/opencv-4.0.1 && \
  rm -rf /usr/src/app/opencv_contrib-4.0.1


ENV UDEV=1
ENV LD_LIBRARY_PATH=/usr/local/lib


# Install G-Streamer
#https://docs.nvidia.com/jetson/l4t/index.html#page/Tegra%20Linux%20Driver%20Package%20Development%20Guide/accelerated_gstreamer.html#wwpID0E0R40HA

RUN apt-get update && apt-get install -y gstreamer1.0-tools gstreamer1.0-alsa \
  gstreamer1.0-plugins-base gstreamer1.0-plugins-good \
  gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly \
  gstreamer1.0-libav 

RUN  apt-get install -y libgstreamer1.0-dev \
  libgstreamer-plugins-base1.0-dev \
  libgstreamer-plugins-good1.0-dev \
  libgstreamer-plugins-bad1.0-dev

CMD [ "sleep", "infinity" ]

When running the container, I’m running it as privileged with cap_add SYS_RAWIO (though i’m not sure if required).

Inside the container I run nvargus-daemon & and then try to launch gstreamer. I’m getting a whole bunch of gstreamer errors that I have no idea how to address.

root@voltera-desktop:/# gst-launch-1.0 nvarguscamerasrc ! nvoverlaysink
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
(Argus) Error FileOperationFailed: Connecting to nvargus-daemon failed: Connection refused (in src/rpc/socket/client/SocketClientDispatch.cpp, function openSocketConnection(), line 201)
(Argus) Error FileOperationFailed: Cannot create camera provider (in src/rpc/socket/client/SocketClientDispatch.cpp, function createCameraProvider(), line 102)
Error generated. /dvs/git/dirty/git-master_linux/multimedia/nvgstreamer/gst-nvarguscamera/gstnvarguscamerasrc.cpp, execute:639 Failed to create CameraProvider

(gst-launch-1.0:224): GStreamer-CRITICAL **: 17:17:04.100: gst_mini_object_set_qdata: assertion 'object != NULL' failed
Got EOS from element "pipeline0".
Execution ended after 0:00:00.001363826
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...
root@voltera-desktop:/# nvargus-daemon &
[1] 235
root@voltera-desktop:/# === NVIDIA Libargus Camera Service (0.97.3)=== Listening for connections...gst-launch-1.0 nvarguscamerasrc ! nvoverlaysink
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
=== gst-launch-1.0[240]: Connection established (7F7239C1D0)OFParserListModules: module list: /proc/device-tree/tegra-camera-platform/modules/module0
OFParserListModules: module list: /proc/device-tree/tegra-camera-platform/modules/module1
NvPclHwGetModuleList: No module data found
NvPclHwGetModuleList: No module data found
NvPclHwScanExternalCameras: Failed to stat '/dev//log'; No such file or directory
NvPclHwScanExternalCameras: Failed to stat '/dev//initctl'; No such file or directory
NvPclHwScanExternalCameras: Failed to stat '/dev//log'; No such file or directory
NvPclHwScanExternalCameras: Failed to stat '/dev//initctl'; No such file or directory
NvPclHwScanExternalCameras: Failed to stat '/dev//log'; No such file or directory
NvPclHwScanExternalCameras: Failed to stat '/dev//initctl'; No such file or directory
OFParserGetVirtualDevice: NVIDIA Camera virtual enumerator not found in proc device-tree
---- imager: No override file found. ----
(Argus) Error EndOfFile: Unexpected error in reading socket (in src/rpc/socket/client/ClientSocketManager.cpp, function recvThreadCore(), line 266)
(Argus) Error EndOfFile: Receive worker failure, notifying 1 waiting threads (in src/rpc/socket/client/ClientSocketManager.cpp, function recvThreadCore(), line 340)
(Argus) Error InvalidState: Argus client is exiting with 1 outstanding client threads (in src/rpc/socket/client/ClientSocketManager.cpp, function recvThreadCore(), line 357)
(Argus) Error EndOfFile: Receiving thread terminated with error (in src/rpc/socket/client/ClientSocketManager.cpp, function recvThreadWrapper(), line 368)
(Argus) Error EndOfFile: Client thread received an error from socket (in src/rpc/socket/client/ClientSocketManager.cpp, function send(), line 145)
(Argus) Error EndOfFile:  (propagating from src/rpc/socket/client/SocketClientDispatch.cpp, function dispatch(), line 87)
(Argus) Error InvalidState: Receive thread is not running cannot send. (in src/rpc/socket/client/ClientSocketManager.cpp, function send(), line 96)
(Argus) Error InvalidState:  (propagating from src/rpc/socket/client/SocketClientDispatch.cpp, function dispatch(), line 87)
Error generated. /dvs/git/dirty/git-master_linux/multimedia/nvgstreamer/gst-nvarguscamera/gstnvarguscamerasrc.cpp, execute:639 Failed to create CameraProvider

(gst-launch-1.0:240): GStreamer-CRITICAL **: 17:17:18.539: gst_mini_object_set_qdata: assertion 'object != NULL' failed
Got EOS from element "pipeline0".
Execution ended after 0:00:00.626490142
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...
(Argus) Error InvalidState: Receive thread is not running cannot send. (in src/rpc/socket/client/ClientSocketManager.cpp, function send(), line 96)
(Argus) Error InvalidState:  (propagating from src/rpc/socket/client/SocketClientDispatch.cpp, function dispatch(), line 87)

Like I mentioned, this seemed to work on the Nano. Any guidance would be appreciated.

Sorry for the late response, have you managed to get issue resolved? Thanks

Did you confirm the same command out of the Docker to confirm the camera functionality?

Hi @ShaneCCC and @kayccc ,

I am still experiencing the issue.

Outside the docker container I can confirm that I can stream the camera no problem with the gst-launch-1.0 nvarguscamerasrc ! nvoverlaysink command.

So I am confident that the hardware is working as expected.

Inside the container, I must start the daemon by running nvargus-daemon & and then I kick off the stream and I get the set of errors I listed above. I’m not very familiar with Gstreamer so I’m not sure what the errors mean.

Please follow below link to run the docker to try.

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