Camera server for Jetson 2GB DevKit SD

I am working with a Nvidia Jetson 2GB DevKit SD. I have been able to download some sample code off the internet that’s intent is to take the image from a USB camera, and push it to a web server it hosts. I started developing the code earlier this week, and had success with it hosting a web server, although I could not find the correct camera port. After looking online, and testing out many terminal commands I found a way to find which port was correct for the Jetson, with turned tout to be port 4. I then plugged that into the code, and I could not get the code to work. It looped the statement

Restarting service 'main sha256:a0e9de1e8976cdfb1093271fbae7baa94ee7a5a81ebb5034ad5114d4154c4e37'
Service exited 'main sha256:a0e9de1e8976cdfb1093271fbae7baa94ee7a5a81ebb5034ad5114d4154c4e37'

I first assumed that I might have broken something in the Jetson itself. So I downloaded a new .ISO for the project, and loaded it onto the Jetson. It then continued to produce the same result. After this, I thought to try to put print statements in the first couple lines of code to see if it was running the file. I have the code shown below:

print("first Line")
from flask import Flask, render_template, Response
print("Second Line")
import cv2
print("Third Line")
import time
print("Fourth Line")

This was an improvement, the logs then showed the first two prints as shown:

Restarting service 'main sha256:a0e9de1e8976cdfb1093271fbae7baa94ee7a5a81ebb5034ad5114d4154c4e37'
main first Line
main Second Line
Service exited 'main sha256:a0e9de1e8976cdfb1093271fbae7baa94ee7a5a81ebb5034ad5114d4154c4e37'

What this signals to me is that there is a problem with the open cv package. Importing onto the Jetson, because the program works well on my computer.
I have linked the Github link to the code below, do you have any recommendations for moving forward? or ways of further debugging on why it errors out when calling the open cv? Also if anyone has sample code they know works that has openCV, and are willing to share it, it would be appreciated.

Github link:

Thank you,

Hi Nate, welcome to the Forums.

I am not sure with certainty if pulling in OpenCV via requirements.txt in the case of a Jetson is valid or not, but, I can say that we build OpenCV from source and it works when using this methodology:

jetson-nano-sample-new/Dockerfile at master · balena-io-playground/jetson-nano-sample-new (

Let’s give it a bit and see if anyone from the community has any ideas, as well. :slight_smile:

Hi Nate,

welcome to the community :slight_smile:

From what i found in your repository, it think its due to the fact, that you are installing opencv headless, therefore only the python bindings. opencv-python-headless is listed in the requirements.txt.

@dtischler way of solving this is probably the fastest. Otherwise you will have to compile it on your own :slight_smile:

Side note:
@dtischler you beat me by a few seconds :frowning_face:

Thanks, I tried installing it not headless and it shoed an error, that after googling, they recommended headless. Do you want me to reproduce the error and show it here?

If I were to replace my requirements file with the one you linked, do you think it would work?

You can not install opencv via pip on the jetson nano, since pypi does not supply a version build for the aarch64 architecture. OpenCV is a powerfull library written in C++ and therefore needs to be compiled on every platform. Sadly there is no prebuild version for the jetson nano, Therefore compilining opencv yourself is your only option.

I would recommend you to merge @dtischler recommended Dockerfile with your dockerfile.

Something like this should work:

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

WORKDIR /usr/src/app

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

# Install CUDA, CUDA compiler and some utilities
    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 && \
    echo "/usr/lib/aarch64-linux-gnu/tegra" > /etc/ && \
    ldconfig && \
    wget && \
    unzip && rm

    wget -O && \
    unzip && rm && \
    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=ON -D BUILD_PERF_TESTS=ON -D BUILD_SAMPLES=ON -D BUILD_EXAMPLES=ON -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/ && \
    cp /usr/src/app/opencv-4.0.1/build/bin/example_ximgproc_paillou_demo /usr/src/app/ && \
    cp /usr/src/app/opencv-4.0.1/build/bin/example_ximgproc_fourier_descriptors_demo /usr/src/app/ && \
    cd /usr/src/app/ && rm -rf /usr/src/app/opencv-4.0.1 && \
    mv opencv_contrib-4.0.1/samples/data/corridor.jpg /usr/src/app/ && \
    rm -rf /usr/src/app/opencv_contrib-4.0.1

FROM balenalib/jetson-nano-ubuntu:bionic as final

# Starting with a fresh new base image, but with access to files in previous build

# Uncomment if planning to use libs from here
#COPY --from=buildstep /usr/local/cuda-10.2 /usr/local/cuda-10.2

# Minimum CUDA runtime libraries
COPY --from=buildstep /usr/lib/aarch64-linux-gnu /usr/lib/aarch64-linux-gnu

# OpenCV runtime libraries
COPY --from=buildstep /usr/local/lib /usr/local/lib

# Demo apps
COPY --from=buildstep /usr/src/app/ /usr/src/app/

ENV DEBIAN_FRONTEND noninteractive

# Download and install BSP binaries for L4T 32.4.4
RUN apt-get update && apt-get install -y wget tar lbzip2 python3 libegl1 && \
    wget && \       
    tar xf Tegra210_Linux_R32.4.4_aarch64.tbz2 && \
    cd Linux_for_Tegra && \
    sed -i 's/config.tbz2\"/config.tbz2\" --exclude=etc\/hosts --exclude=etc\/hostname/g' && \
    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/ && \
    sed -i 's/LC_ALL=C chroot . mount -t proc none \/proc/ /g' nv_tegra/ && \
    sed -i 's/umount ${L4T_ROOTFS_DIR}\/proc/ /g' nv_tegra/ && \
    sed -i 's/chroot . \//  /g' nv_tegra/ && \
    ./ -r / --target-overlay && cd .. \
    rm -rf Tegra210_Linux_R32.4.4_aarch64.tbz2 && \
    rm -rf Linux_for_Tegra && \
    echo "/usr/lib/aarch64-linux-gnu/tegra" > /etc/ && ldconfig

RUN apt-get update && apt-get install -y lbzip2 xorg


ENV LD_LIBRARY_PATH=/usr/local/lib

# Enable systemd init system

# Set our working directory
WORKDIR /usr/src/app

# Copy requirements.txt first for better cache on later pushes
COPY requirements.txt requirements.txt

# pip install python deps from requirements.txt on the build server
RUN pip install -r requirements.txt

# This will copy all files in our root to the working  directory in the container
COPY . ./

# Enable udevd so that plugged dynamic hardware devices show up in our container.

# will run when container starts up on the device
CMD ["python","-u","src/"]

Ok thank you!

LOL Frederic!

In that case Nate, yep, follow that sample I linked above. :slight_smile:

And thanks for lending a hand here Frederic!

1 Like

Yes, thank you both, I will try your recommendations!

Oh, check above, Frederic edited the post to include a nice sample. :slight_smile:

And be sure to ping us back with what you end up building Nate…I am always looking for projects to show off. :wink:

Thank you, I loaded the file in the project, and it has spent the last while downloading the files. It then started on configuring the OpenCV, and seems to be getting stuck at about 7%. I pasted the log below of the configuration, and it shows this error quite a few time:
[Build] [main] cc1: warning: ‘-Werror=’ argument ‘-Werror=non-virtual-dtor’ is not valid for C
I have restarted the build a few times now, and it continues to stop at this point. Is this a problem with C++? or do you have any ideas of what could be causing it?

-as a side note, I just updated github with the current code:

[Build]   [main] -- General configuration for OpenCV 4.0.1 =====================================
[Build]   [main] --   Version control:               unknown
[Build]   [main] --
[Build]   [main] --   Extra modules:
[Build]   [main] --     Location (extra):            /usr/src/app/opencv_contrib-4.0.1/modules
[Build]   [main] --     Version control (extra):     unknown
[Build]   [main] --
[Build]   [main] --   Platform:
[Build]   [main] --     Timestamp:                   2021-04-22T21:33:59Z
[Build]   [main] --     Host:                        Linux 4.9.140-l4t-r32.4 aarch64
[Build]   [main] --     CMake:                       3.10.2
[Build]   [main] --     CMake generator:             Unix Makefiles
[Build]   [main] --     CMake build tool:            /usr/bin/make
[Build]   [main] --     Configuration:               RELEASE
[Build]   [main] --
[Build]   [main] --   CPU/HW features:
[Build]   [main] --     Baseline:                    NEON FP16
[Build]   [main] --       required:                  NEON
[Build]   [main] --       disabled:                  VFPV3
[Build]   [main] --
[Build]   [main] --   C/C++:
[Build]   [main] --     Built as dynamic libs?:      YES
[Build]   [main] --     C++ Compiler:                /usr/bin/c++  (ver 7.5.0)
[Build]   [main] --     C++ flags (Release):         -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections    -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG  -DNDEBUG
[Build]   [main] --     C++ flags (Debug):           -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections    -fvisibility=hidden -fvisibility-inlines-hidden -g  -O0 -DDEBUG -D_DEBUG
[Build]   [main] --     C Compiler:                  /usr/bin/cc
[Build]   [main] --     C flags (Release):           -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections    -fvisibility=hidden -O3 -DNDEBUG  -DNDEBUG
[Build]   [main] --     C flags (Debug):             -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections    -fvisibility=hidden -g  -O0 -DDEBUG -D_DEBUG
[Build]   [main] --     Linker flags (Release):
[Build]   [main] --     Linker flags (Debug):
[Build]   [main] --     ccache:                      NO
[Build]   [main] --     Precompiled headers:         YES
[Build]   [main] --     Extra dependencies:          m pthread cudart_static -lpthread dl rt nppc nppial nppicc nppicom nppidei nppif nppig nppim nppist nppisu nppitc npps cublas cufft -L/usr/local/cuda-10.2/lib64 -L/usr/lib/aarch64-linux-gnu
[Build]   [main] --     3rdparty dependencies:
[Build]   [main] --
[Build]   [main] --   OpenCV modules:
[Build]   [main] --     To be built:                 calib3d core cudaimgproc cudev features2d flann highgui imgcodecs imgproc videoio ximgproc
[Build]   [main] --     Disabled:                    world
[Build]   [main] --     Disabled by dependency:      aruco bgsegm bioinspired ccalib cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping datasets dnn dnn_objdetect dpm face freetype fuzzy gapi hfs img_hash java_bindings_generator line_descriptor ml objdetect optflow phase_unwrapping photo plot python_bindings_generator reg rgbd saliency shape stereo stitching structured_light superres surface_matching text tracking ts video videostab xfeatures2d xobjdetect xphoto
[Build]   [main] --     Unavailable:                 cnn_3dobj cvv hdf java js matlab ovis python2 python3 sfm viz
[Build]   [main] --     Applications:                examples apps
[Build]   [main] --     Documentation:               NO
[Build]   [main] --     Non-free algorithms:         NO
[Build]   [main] --
[Build]   [main] --   GUI:
[Build]   [main] --     GTK+:                        YES (ver 2.24.32)
[Build]   [main] --       GThread :                  YES (ver 2.56.4)
[Build]   [main] --       GtkGlExt:                  NO
[Build]   [main] --     VTK support:                 NO
[Build]   [main] --
[Build]   [main] --   Media I/O:
[Build]   [main] --     ZLib:                        /usr/lib/aarch64-linux-gnu/ (ver 1.2.11)
[Build]   [main] --     JPEG:                        /usr/lib/aarch64-linux-gnu/ (ver 80)
[Build]   [main] --     WEBP:                        build (ver encoder: 0x020e)
[Build]   [main] --     PNG:                         /usr/lib/aarch64-linux-gnu/ (ver 1.6.34)
[Build]   [main] --     TIFF:                        /usr/lib/aarch64-linux-gnu/ (ver 42 / 4.0.9)
[Build]   [main] --     JPEG 2000:                   build (ver 1.900.1)
[Build]   [main] --     OpenEXR:                     build (ver 1.7.1)
[Build]   [main] --     HDR:                         YES
[Build]   [main] --     SUNRASTER:                   YES
[Build]   [main] --     PXM:                         YES
[Build]   [main] --     PFM:                         YES
[Build]   [main] --
[Build]   [main] --   Video I/O:
[Build]   [main] --     DC1394:                      YES (ver 2.2.5)
[Build]   [main] --     FFMPEG:                      NO
[Build]   [main] --       avcodec:                   NO
[Build]   [main] --       avformat:                  NO
[Build]   [main] --       avutil:                    NO
[Build]   [main] --       swscale:                   NO
[Build]   [main] --       avresample:                NO
[Build]   [main] --     GStreamer:
[Build]   [main] --       base:                      YES (ver 1.14.5)
[Build]   [main] --       video:                     YES (ver 1.14.5)
[Build]   [main] --       app:                       YES (ver 1.14.5)
[Build]   [main] --       riff:                      YES (ver 1.14.5)
[Build]   [main] --       pbutils:                   YES (ver 1.14.5)
[Build]   [main] --     v4l/v4l2:                    linux/videodev2.h
[Build]   [main] --
[Build]   [main] --   Parallel framework:            pthreads
[Build]   [main] --
[Build]   [main] --   Trace:                         YES (built-in)
[Build]   [main] --
[Build]   [main] --   Other third-party libraries:
[Build]   [main] --     Lapack:                      NO
[Build]   [main] --     Eigen:                       NO
[Build]   [main] --     Custom HAL:                  YES (carotene (ver 0.0.1))
[Build]   [main] --     Protobuf:                    build (3.5.1)
[Build]   [main] --
[Build]   [main] --   NVIDIA CUDA:                   YES (ver 10.2, CUFFT CUBLAS)
[Build]   [main] --     NVIDIA GPU arch:             53
[Build]   [main] --     NVIDIA PTX archs:
[Build]   [main] --
[Build]   [main] --   OpenCL:                        YES (no extra features)
[Build]   [main] --     Include path:                /usr/src/app/opencv-4.0.1/3rdparty/include/opencl/1.2
[Build]   [main] --     Link libraries:              Dynamic load
[Build]   [main] --
[Build]   [main] --   Python (for build):            /usr/bin/python3
[Build]   [main] --
[Build]   [main] --   Java:
[Build]   [main] --     ant:                         NO
[Build]   [main] --     JNI:                         NO
[Build]   [main] --     Java wrappers:               NO
[Build]   [main] --     Java tests:                  NO
[Build]   [main] --
[Build]   [main] --   Install to:                    /usr/local
[Build]   [main] -- -----------------------------------------------------------------
[Build]   [main] --
[Build]   [main] -- Configuring done
[Build]   [main] -- Generating done
[Build]   [main] -- Build files have been written to: /usr/src/app/opencv-4.0.1/build
[Build]   [main] Scanning dependencies of target quirc
[Build]   [main] [  0%] Building C object 3rdparty/quirc/CMakeFiles/quirc.dir/src/decode.c.o
[Build]   [main] [  0%] Building C object 3rdparty/quirc/CMakeFiles/quirc.dir/src/version_db.c.o
[Build]   [main] Scanning dependencies of target ade
[Build]   [main] Scanning dependencies of target opencv_calib3d_pch_dephelp
[Build]   [main] cc1: warning: ‘-Werror=’ argument ‘-Werror=non-virtual-dtor’ is not valid for C
[Build]   [main] Scanning dependencies of target opencv_ximgproc_pch_dephelp
[Build]   [main] cc1: warning: ‘-Werror=’ argument ‘-Werror=non-virtual-dtor’ is not valid for C
[Build]   [main] [  0%] Building CXX object modules/calib3d/CMakeFiles/opencv_calib3d_pch_dephelp.dir/opencv_calib3d_pch_dephelp.cxx.o
[Build]   [main] [  0%] Building C object 3rdparty/quirc/CMakeFiles/quirc.dir/src/quirc.c.o
[Build]   [main] [  0%] Building CXX object modules/CMakeFiles/ade.dir/__/3rdparty/ade/ade-0.1.1d/sources/ade/source/memory_accessor.cpp.o
[Build]   [main] [  0%] Building CXX object modules/CMakeFiles/ade.dir/__/3rdparty/ade/ade-0.1.1d/sources/ade/source/memory_descriptor.cpp.o
[Build]   [main] [  0%] Building CXX object modules/CMakeFiles/ade.dir/__/3rdparty/ade/ade-0.1.1d/sources/ade/source/edge.cpp.o
[Build]   [main] Scanning dependencies of target opencv_features2d_pch_dephelp
[Build]   [main] Scanning dependencies of target opencv_imgcodecs_pch_dephelp
[Build]   [main] [  1%] Building CXX object modules/CMakeFiles/ade.dir/__/3rdparty/ade/ade-0.1.1d/sources/ade/source/memory_descriptor_ref.cpp.o
[Build]   [main] [  1%] Building CXX object modules/CMakeFiles/ade.dir/__/3rdparty/ade/ade-0.1.1d/sources/ade/source/metadata.cpp.o
[Build]   [main] [  1%] Building CXX object modules/CMakeFiles/ade.dir/__/3rdparty/ade/ade-0.1.1d/sources/ade/source/node.cpp.o
[Build]   [main] [  1%] Building CXX object modules/CMakeFiles/ade.dir/__/3rdparty/ade/ade-0.1.1d/sources/ade/source/metatypes.cpp.o
[Build]   [main] [  1%] Building CXX object modules/CMakeFiles/ade.dir/__/3rdparty/ade/ade-0.1.1d/sources/ade/source/assert.cpp.o
[Build]   [main] [  1%] Building CXX object modules/CMakeFiles/ade.dir/__/3rdparty/ade/ade-0.1.1d/sources/ade/source/graph.cpp.o
[Build]   [main] [  1%] Building CXX object modules/CMakeFiles/ade.dir/__/3rdparty/ade/ade-0.1.1d/sources/ade/source/check_cycles.cpp.o
[Build]   [main] [  1%] Building CXX object modules/CMakeFiles/ade.dir/__/3rdparty/ade/ade-0.1.1d/sources/ade/source/passes/communications.cpp.o
[Build]   [main] Scanning dependencies of target opencv_flann_pch_dephelp
[Build]   [main] [  1%] Building CXX object modules/ximgproc/CMakeFiles/opencv_ximgproc_pch_dephelp.dir/opencv_ximgproc_pch_dephelp.cxx.o
[Build]   [main] [  2%] Building CXX object modules/imgcodecs/CMakeFiles/opencv_imgcodecs_pch_dephelp.dir/opencv_imgcodecs_pch_dephelp.cxx.o
[Build]   [main] [  2%] Building CXX object modules/CMakeFiles/ade.dir/__/3rdparty/ade/ade-0.1.1d/sources/ade/source/execution_engine.cpp.o
[Build]   [main] cc1: warning: ‘-Werror=’ argument ‘-Werror=non-virtual-dtor’ is not valid for C
[Build]   [main] [  2%] Building CXX object modules/CMakeFiles/ade.dir/__/3rdparty/ade/ade-0.1.1d/sources/ade/source/search.cpp.o
[Build]   [main] Scanning dependencies of target opencv_videoio_pch_dephelp
[Build]   [main] Scanning dependencies of target opencv_imgproc_pch_dephelp
[Build]   [main] [  2%] Building CXX object modules/features2d/CMakeFiles/opencv_features2d_pch_dephelp.dir/opencv_features2d_pch_dephelp.cxx.o
[Build]   [main] [  2%] Building CXX object modules/flann/CMakeFiles/opencv_flann_pch_dephelp.dir/opencv_flann_pch_dephelp.cxx.o
[Build]   [main] [  3%] Building CXX object modules/CMakeFiles/ade.dir/__/3rdparty/ade/ade-0.1.1d/sources/ade/source/alloc.cpp.o
[Build]   [main] [  3%] Building CXX object modules/CMakeFiles/ade.dir/__/3rdparty/ade/ade-0.1.1d/sources/ade/source/memory_descriptor_view.cpp.o
[Build]   [main] [  3%] Building CXX object modules/videoio/CMakeFiles/opencv_videoio_pch_dephelp.dir/opencv_videoio_pch_dephelp.cxx.o
[Build]   [main] Scanning dependencies of target opencv_highgui_pch_dephelp
[Build]   [main] Scanning dependencies of target libjasper
[Build]   [main] [  3%] Building CXX object modules/imgproc/CMakeFiles/opencv_imgproc_pch_dephelp.dir/opencv_imgproc_pch_dephelp.cxx.o
[Build]   [main] Scanning dependencies of target carotene_objs
[Build]   [main] [  4%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui_pch_dephelp.dir/opencv_highgui_pch_dephelp.cxx.o
[Build]   [main] [  4%] Building C object 3rdparty/libjasper/CMakeFiles/libjasper.dir/jas_cm.c.o
[Build]   [main] Scanning dependencies of target opencv_cudaimgproc_pch_dephelp
[Build]   [main] Scanning dependencies of target opencv_core_pch_dephelp
[Build]   [main] cc1: warning: ‘-Werror=’ argument ‘-Werror=non-virtual-dtor’ is not valid for C
[Build]   [main] [  4%] Building CXX object 3rdparty/carotene/hal/carotene/CMakeFiles/carotene_objs.dir/src/absdiff.cpp.o
[Build]   [main] Scanning dependencies of target libwebp
[Build]   [main] [  4%] Building C object 3rdparty/libjasper/CMakeFiles/libjasper.dir/jas_debug.c.o
[Build]   [main] Scanning dependencies of target IlmImf
[Build]   [main] [  4%] Building CXX object modules/cudaimgproc/CMakeFiles/opencv_cudaimgproc_pch_dephelp.dir/opencv_cudaimgproc_pch_dephelp.cxx.o
[Build]   [main] cc1: warning: ‘-Werror=’ argument ‘-Werror=non-virtual-dtor’ is not valid for C
[Build]   [main] [  4%] Building CXX object modules/core/CMakeFiles/opencv_core_pch_dephelp.dir/opencv_core_pch_dephelp.cxx.o
[Build]   [main] [  4%] Building C object 3rdparty/libwebp/CMakeFiles/libwebp.dir/src/dec/alpha_dec.c.o
[Build]   [main] [  4%] Building CXX object 3rdparty/openexr/CMakeFiles/IlmImf.dir/Half/half.cpp.o
[Build]   [main] cc1: warning: ‘-Werror=’ argument ‘-Werror=non-virtual-dtor’ is not valid for C
[Build]   [main] [  4%] Building CXX object modules/CMakeFiles/ade.dir/__/3rdparty/ade/ade-0.1.1d/sources/ade/source/subgraphs.cpp.o
[Build]   [main] Scanning dependencies of target libprotobuf
[Build]   [main] [  4%] Building C object 3rdparty/libjasper/CMakeFiles/libjasper.dir/jas_getopt.c.o
[Build]   [main] cc1: warning: ‘-Werror=’ argument ‘-Werror=non-virtual-dtor’ is not valid for C
[Build]   [main] [  6%] Building CXX object modules/CMakeFiles/ade.dir/__/3rdparty/ade/ade-0.1.1d/sources/ade/source/topological_sort.cpp.o
[Build]   [main] [  6%] Building CXX object 3rdparty/protobuf/CMakeFiles/libprotobuf.dir/src/google/protobuf/
[Build]   [main] [  6%] Building C object 3rdparty/libwebp/CMakeFiles/libwebp.dir/src/dec/buffer_dec.c.o
[Build]   [main] cc1: warning: ‘-Werror=’ argument ‘-Werror=non-virtual-dtor’ is not valid for C
[Build]   [main] [  6%] Building C object 3rdparty/libjasper/CMakeFiles/libjasper.dir/jas_icc.c.o
[Build]   [main] cc1: warning: ‘-Werror=’ argument ‘-Werror=non-virtual-dtor’ is not valid for C
[Build]   [main] In file included from /usr/src/app/opencv-4.0.1/modules/core/src/precomp.hpp:56:0,
[Build]                    from /usr/src/app/opencv-4.0.1/build/modules/core/opencv_core_pch_dephelp.cxx:1:
[Build]   /usr/src/app/opencv-4.0.1/modules/core/include/opencv2/core/private.cuda.hpp:75:0: warning: "NPP_VERSION" redefined
[Build]   In file included from /usr/src/app/opencv-4.0.1/modules/core/include/opencv2/core/private.cuda.hpp:71:0,
[Build]                    from /usr/src/app/opencv-4.0.1/modules/core/src/precomp.hpp:56,
[Build]                    from /usr/src/app/opencv-4.0.1/build/modules/core/opencv_core_pch_dephelp.cxx:1:
[Build]   /usr/local/cuda-10.2/include/npp.h:62:0: note: this is the location of the previous definition
[Build]    #define NPP_VERSION (NPP_VER_MAJOR * 1000 +     \
[Build]   [main] In file included from /usr/src/app/opencv_contrib-4.0.1/modules/cudaimgproc/src/precomp.hpp:50:0,
[Build]                    from /usr/src/app/opencv-4.0.1/build/modules/cudaimgproc/opencv_cudaimgproc_pch_dephelp.cxx:1:
[Build]   /usr/src/app/opencv-4.0.1/modules/core/include/opencv2/core/private.cuda.hpp:75:0: warning: "NPP_VERSION" redefined
[Build]   [main] In file included from /usr/src/app/opencv-4.0.1/modules/core/include/opencv2/core/private.cuda.hpp:71:0,
[Build]                    from /usr/src/app/opencv_contrib-4.0.1/modules/cudaimgproc/src/precomp.hpp:50,
[Build]                    from /usr/src/app/opencv-4.0.1/build/modules/cudaimgproc/opencv_cudaimgproc_pch_dephelp.cxx:1:
[Build]   /usr/local/cuda-10.2/include/npp.h:62:0: note: this is the location of the previous definition
[Build]    #define NPP_VERSION (NPP_VER_MAJOR * 1000 +     \
[Build]   [main] [  7%] Building C object 3rdparty/libwebp/CMakeFiles/libwebp.dir/src/dec/frame_dec.c.o
[Build]   [main] cc1: warning: ‘-Werror=’ argument ‘-Werror=non-virtual-dtor’ is not valid for C

Fair warning, that build takes a LONG time. It might be worth letting it run for a few hours actually, and see if it progresses. I probably should have warned you about that up front, oops!

Thanks, It ran ran about 5 minutes after you posted it until the message I just sent. It seems to stop at the end of the section of code I added above. I let it set for an easy 20-30 minutes, and it goes nowhere. Do you know if the warnings are normal? or what could be causing them? -It is still running and stuck at the same place.

I can’t quite recall…It’s been a while since I ran one. I seem to recall Warnings being ok, Errors not being ok. :wink:

I’ll start a build on my side in a little bit, and see if it hangs for me as well.

Ok thank you! I will let it keep going for a while and see if it progresses.

Thank you, Good news!
I had to try it a couple time, but it now goes through without problems!

It did bring up a problem though. I quoted it below:

Restarting service 'main sha256:9895a7f62e747439138886089951d46fbb9e24b869292703e38e13b89b24427c'
 main  first Line
 main  Second Line
 main  Traceback (most recent call last):
 main    File "src/", line 4, in <module>
 main      import cv2  
 main  ModuleNotFoundError: No module named 'cv2'
Service exited 'main sha256:9895a7f62e747439138886089951d46fbb9e24b869292703e38e13b89b24427c'

This is the same problem as I was talking about in my second post. I googled for a solution, and since I am working headless, they recommended I install a headless version of OpenCV. Do you know if what part of the Dockerfile I would need to change to install headless OpenCV? Or would you have other advice?


I think you are looking at changing the requirements.txt file, since that should have all the python packages that are required. I quickly googled, and found this package which is meant for headless opencv in python. You can try using that.

Thank you everyone for your prompt support!

It seems that I am back where I started. I was able to implement the new Docker file, and and have pip install opencv-python-headless. The issue is that the log is showing the same error as before of

Restarting service 'main sha256:8aec8137c619ee5c474aad1e3d332e309fd7cfef2551129e7a0c014e69df30f2'
 main  first Line
 main  Second Line
Service exited 'main sha256:8aec8137c619ee5c474aad1e3d332e309fd7cfef2551129e7a0c014e69df30f2'

It seems to quit on the line import cv2.

If anyone would be up for it, I would be happy to add you to the balena project, and add you to the github project if you would like to push the code yourself, and see if you can debug to find the problem. If so, please DM me.

Thank you!

Just catching up Nate, glad to hear the build did end up finishing. Looking at your error, something still seems odd though. Even if OpenCV is not functioning properly and your import cv2 doesn’t work, you should get an error…not have the container completely die. Try updating your OpenCV snippet in your dockerfile to this one here: jetracer/Dockerfile.template at main · dtischler/jetracer · GitHub, then re-run your build, and see if that helps. :slight_smile:

Thanks for your help! Just to let you know, I am still working on trying to see if the new section of code will work. I was receiving an error that I googled, and it seems to be an sd card write error of some sort. Anyway, I am going to order a new sd card to see if it helps.