Camera server for Jetson 2GB DevKit SD

Makes sense, you may want to keep a few on hand. SD Cards tend to wear out and die on a pretty regular basis. :wink:

Thank you for your help. I have tested the code with a few new SD cards, and I am still receiving this error. When I plug in the Jetson, it starts downloading the image, and eventually stops at about 30%, and restarts. The GitHub is still up to date. I tried following your comment above about swiping in the OpenCV snippet from the Jetser Dockerfile. Do you know if I could have made a mistake in the dockerfile that could be causing this?

Supervisor starting
Downloading image 'registry2.balena-cloud.com/v2/9513e5e8be8869e4d3f88ca820bbe661@sha256:dc3075f51a700dc510490733811e354a67dcf8a338e582b8a36d3f444e56d8e9'
Failed to download image 'registry2.balena-cloud.com/v2/9513e5e8be8869e4d3f88ca820bbe661@sha256:dc3075f51a700dc510490733811e354a67dcf8a338e582b8a36d3f444e56d8e9' due to 'connect ECONNREFUSED /var/run/balena-engine.sock'
Supervisor starting
Applying configuration change {"SUPERVISOR_DELTA":"1"}
Applied configuration change {"SUPERVISOR_DELTA":"1"}
Downloading image 'registry2.balena-cloud.com/v2/9513e5e8be8869e4d3f88ca820bbe661@sha256:dc3075f51a700dc510490733811e354a67dcf8a338e582b8a36d3f444e56d8e9'
Failed to download image 'registry2.balena-cloud.com/v2/9513e5e8be8869e4d3f88ca820bbe661@sha256:dc3075f51a700dc510490733811e354a67dcf8a338e582b8a36d3f444e56d8e9' due to 'connect ECONNREFUSED /var/run/balena-engine.sock'
Supervisor starting
Downloading image 'registry2.balena-cloud.com/v2/9513e5e8be8869e4d3f88ca820bbe661@sha256:dc3075f51a700dc510490733811e354a67dcf8a338e582b8a36d3f444e56d8e9'
Failed to download image 'registry2.balena-cloud.com/v2/9513e5e8be8869e4d3f88ca820bbe661@sha256:dc3075f51a700dc510490733811e354a67dcf8a338e582b8a36d3f444e56d8e9' due to 'connect ECONNREFUSED /var/run/balena-engine.sock'
Supervisor starting
Downloading image 'registry2.balena-cloud.com/v2/9513e5e8be8869e4d3f88ca820bbe661@sha256:dc3075f51a700dc510490733811e354a67dcf8a338e582b8a36d3f444e56d8e9'

I’ll try to duplicate this today @NateKing on my Nano, and let you know what I find out.

Hi @NateKing, I can’t even build directly from your repo, I think you might need to re-examine your Dockerfile. I get:
<–snip–>

[main]     [ 14%] Building CXX object 3rdparty/protobuf/CMakeFiles/libprotobuf.dir/src/google/protobuf/util/type_resolver_util.cc.o
[main]     [ 14%] Building CXX object 3rdparty/protobuf/CMakeFiles/libprotobuf.dir/src/google/protobuf/wire_format.cc.o
[main]     [ 14%] Building CXX object modules/CMakeFiles/ade.dir/__/3rdparty/ade/ade-0.1.1d/sources/ade/source/search.cpp.o
[main]     [ 14%] Building CXX object 3rdparty/protobuf/CMakeFiles/libprotobuf.dir/src/google/protobuf/wrappers.pb.cc.o
[main]     [ 14%] Building CXX object modules/CMakeFiles/ade.dir/__/3rdparty/ade/ade-0.1.1d/sources/ade/source/subgraphs.cpp.o
[main]     [ 14%] Building CXX object modules/CMakeFiles/ade.dir/__/3rdparty/ade/ade-0.1.1d/sources/ade/source/topological_sort.cpp.o
[main]     [ 14%] Linking CXX static library ../lib/liblibprotobuf.a
[main]     [ 14%] Built target libprotobuf
[main]     Scanning dependencies of target opencv_ts_pch_dephelp
[main]     [ 14%] Building CXX object modules/ts/CMakeFiles/opencv_ts_pch_dephelp.dir/opencv_ts_pch_dephelp.cxx.o
[main]     In file included from /usr/src/app/opencv-4.0.1/modules/ts/src/precomp.hpp:2:0,
[main]                      from /usr/src/app/opencv-4.0.1/build/modules/ts/opencv_ts_pch_dephelp.cxx:1:
[main]     /usr/src/app/opencv-4.0.1/modules/core/include/opencv2/core/private.hpp:66:12: fatal error: Eigen/Core: No such file or directory
[main]      #  include <Eigen/Core>
[main]                 ^~~~~~~~~~~~
[main]     compilation terminated.
[main]     
[main]     modules/ts/CMakeFiles/opencv_ts_pch_dephelp.dir/build.make:62: recipe for target 'modules/ts/CMakeFiles/opencv_ts_pch_dephelp.dir/opencv_ts_pch_dephelp.cxx.o' failed
[main]     make[2]: *** [modules/ts/CMakeFiles/opencv_ts_pch_dephelp.dir/opencv_ts_pch_dephelp.cxx.o] Error 1
[main]     
[main]     CMakeFiles/Makefile2:9992: recipe for target 'modules/ts/CMakeFiles/opencv_ts_pch_dephelp.dir/all' failed
[main]     make[1]: *** [modules/ts/CMakeFiles/opencv_ts_pch_dephelp.dir/all] Error 2
[main]     make[1]: *** Waiting for unfinished jobs....
[main]     
[main]     [ 14%] Linking CXX static library ../lib/libade.a
[main]     [ 14%] Built target ade
[main]     Makefile:162: recipe for target 'all' failed
[main]     make: *** [all] Error 2
[main]     
[main]     Removing intermediate container 9b3647d3408a
[main]     The command '/bin/sh -c 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,6.2,7.2 	-D CUDA_ARCH_PTX= 	-D WITH_GSTREAMER=ON 	-D WITH_LIBV4L=ON 	-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-4.0.1/modules 	-D CMAKE_BUILD_TYPE=RELEASE 	-D CMAKE_INSTALL_PREFIX=$(python3 -c "import sys; print(sys.prefix)") 	-D PYTHON_EXECUTABLE=$(which python3) 	-D BUILD_EXAMPLES=OFF         -D BUILD_opencv_python2=ON         -D BUILD_opencv_python3=ON         -D CUDA_FAST_MATH=ON         -D CUDNN_VERSION='8.0'         -D EIGEN_INCLUDE_PATH=/usr/include/eigen3         -D ENABLE_NEON=ON         -D OPENCV_DNN_CUDA=ON         -D OPENCV_ENABLE_NONFREE=ON         -D OPENCV_GENERATE_PKGCONFIG=ON         -D WITH_CUBLAS=ON         -D WITH_CUDNN=ON         -D WITH_OPENGL=ON .. &&     make -j2 && make install && ldconfig' returned a non-zero code: 2
[Info]     Uploading images
[Success]  Successfully uploaded images
[Error]    Some services failed to build:
[Error]      Service: main
[Error]        Error: The command '/bin/sh -c 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,6.2,7.2 -D CUDA_ARCH_PTX= 	-D WITH_GSTREAMER=ON 	-D WITH_LIBV4L=ON 	-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-4.0.1/modules 	-D CMAKE_BUILD_TYPE=RELEASE 	-D CMAKE_INSTALL_PREFIX=$(python3 -c "import sys; print(sys.prefix)") 	-D PYTHON_EXECUTABLE=$(which python3) 	-D BUILD_EXAMPLES=OFF         -D BUILD_opencv_python2=ON         -D BUILD_opencv_python3=ON         -D CUDA_FAST_MATH=ON         -D CUDNN_VERSION='8.0'         -D EIGEN_INCLUDE_PATH=/usr/include/eigen3         -D ENABLE_NEON=ON         -D OPENCV_DNN_CUDA=ON         -D OPENCV_ENABLE_NONFREE=ON         -D OPENCV_GENERATE_PKGCONFIG=ON         -D WITH_CUBLAS=ON         -D WITH_CUDNN=ON         -D WITH_OPENGL=ON .. &&     make -j2 && make install && ldconfig' returned a non-zero code: 2
[Info]     Built on arm05
[Error]    Not deploying release.
Remote build failed

Actually I just noticed you updated the Dockerfile today, so I went back and built your previous one instead @NateKing. It built, and downloaded to my Jetson Nano 2gb right away. It does have the error of simply restart-looping, though:

04.05.21 13:50:15 (-0700)  main  first Line
04.05.21 13:50:17 (-0700)  main  Second Line
04.05.21 13:50:17 (-0700)  main  Traceback (most recent call last):
04.05.21 13:50:17 (-0700)  main    File "src/main.py", line 4, in <module>
04.05.21 13:50:17 (-0700)  main      import cv2  
04.05.21 13:50:17 (-0700)  main  ModuleNotFoundError: No module named 'cv2'
04.05.21 13:50:18 (-0700) Service exited 'main sha256:3cb19f116f791444bbafe49a3e8caf60983e83517855eb490d6a9c6575d3d0ff'

Perhaps you are having some connectivity troubles, or, those SD Cards you purchased are not fast enough to keep up with data being written as the container arrives in conjunction with the running system. You can check for errors in the more verbose logs by running journalctl -u balena -n 200to see what is going on.

Thank you! I will try running the journalctl. I assume I made a mistake in the newer version of the code, so I will revert with the push from 11 days ago and try to work off that. I’ll keep you updated on how it works out!

Thank you, I pulled the old set of code, and receive the same log as you have listed above.

04.05.21 18:01:42 (-0500) Restarting service 'main sha256:8f23f949b13ce904659d5de6d54805f3ff21cc669c847935b6fab635be826c41'
04.05.21 18:01:42 (-0500)  main  first Line
04.05.21 18:01:43 (-0500)  main  Second Line
04.05.21 18:01:43 (-0500)  main  Traceback (most recent call last):
04.05.21 18:01:43 (-0500)  main    File "src/main.py", line 4, in <module>
04.05.21 18:01:43 (-0500)  main      import cv2  
04.05.21 18:01:43 (-0500)  main  ModuleNotFoundError: No module named 'cv2'
04.05.21 18:01:44 (-0500) Service exited 'main sha256:8f23f949b13ce904659d5de6d54805f3ff21cc669c847935b6fab635be826c41'
04.05.21 18:02:45 (-0500) Restarting service 'main sha256:8f23f949b13ce904659d5de6d54805f3ff21cc669c847935b6fab635be826c41'
04.05.21 18:02:46 (-0500)  main  first Line
04.05.21 18:02:47 (-0500)  main  Second Line
04.05.21 18:02:47 (-0500)  main  Traceback (most recent call last):
04.05.21 18:02:47 (-0500)  main    File "src/main.py", line 4, in <module>
04.05.21 18:02:47 (-0500)  main      import cv2  
04.05.21 18:02:47 (-0500)  main  ModuleNotFoundError: No module named 'cv2'
04.05.21 18:02:48 (-0500) Service exited 'main sha256:8f23f949b13ce904659d5de6d54805f3ff21cc669c847935b6fab635be826c41'
04.05.21 18:03:50 (-0500) Restarting service 'main sha256:8f23f949b13ce904659d5de6d54805f3ff21cc669c847935b6fab635be826c41'
04.05.21 18:03:50 (-0500)  main  first Line
04.05.21 18:03:51 (-0500)  main  Second Line
04.05.21 18:03:51 (-0500)  main  Traceback (most recent call last):
04.05.21 18:03:51 (-0500)  main    File "src/main.py", line 4, in <module>
04.05.21 18:03:51 (-0500)  main      import cv2  
04.05.21 18:03:51 (-0500)  main  ModuleNotFoundError: No module named 'cv2'
04.05.21 18:03:52 (-0500) Service exited 'main sha256:8f23f949b13ce904659d5de6d54805f3ff21cc669c847935b6fab635be826c41'

I also was able to run the journalctl -u balena -n 200 command in the terminal, and received the log below.

Connecting to 460ffed3061529036a9069325a9cc149...
Spawning shell...
=============================================================
    Welcome to balenaOS
=============================================================
root@460ffed:~# journalctl -u balena -n 200
-- Logs begin at Tue 2021-05-04 20:56:52 UTC, end at Tue 2021-05-04 23:00:02 UTC. --
May 04 22:50:48 460ffed 2ad22a3a1128[4847]: [event]   Event: Service exit {"service":{"appId>
May 04 22:50:53 460ffed balenad[4887]: time="2021-05-04T22:50:53.780741062Z" level=info msg=>
May 04 22:50:55 460ffed balenad[4887]: time="2021-05-04T22:50:55.453553978Z" level=info msg=>
May 04 22:50:55 460ffed balenad[4847]: time="2021-05-04T22:50:55.459271269Z" level=info msg=>
May 04 22:51:48 460ffed balenad[4887]: time="2021-05-04T22:51:48.607989009Z" level=info msg=>
lines 1-6...skipping...
-- Logs begin at Tue 2021-05-04 20:56:52 UTC, end at Tue 2021-05-04 23:00:02 UTC. --
May 04 22:50:48 460ffed 2ad22a3a1128[4847]: [event]   Event: Service exit {"service":{"appId":>
May 04 22:50:53 460ffed balenad[4887]: time="2021-05-04T22:50:53.780741062Z" level=info msg="s>
-- Logs begin at Tue 2021-05-04 20:56:52 UTC, end at Tue 2021-05-04 23:00:02 UTC. --
May 04 22:50:48 460ffed 2ad22a3a1128[4847]: [event]   Event: Service exit {"service":{"appId":>
May 04 22:50:53 460ffed balenad[4887]: time="2021-05-04T22:50:53.780741062Z" level=info msg="s>
May 04 22:50:55 460ffed balenad[4887]: time="2021-05-04T22:50:55.453553978Z" level=info msg="s>
May 04 22:50:55 460ffed balenad[4847]: time="2021-05-04T22:50:55.459271269Z" level=info msg="i>
May 04 22:51:48 460ffed balenad[4887]: time="2021-05-04T22:51:48.607989009Z" level=info msg="s>
May 04 22:51:49 460ffed 2ad22a3a1128[4847]: [event]   Event: Service restart {"service":{"appI>
May 04 22:51:50 460ffed f3a751610baa[4847]: first Line
May 04 22:51:51 460ffed f3a751610baa[4847]: Second Line
May 04 22:51:56 460ffed balenad[4887]: time="2021-05-04T22:51:56.299221350Z" level=info msg="s>
May 04 22:51:56 460ffed balenad[4847]: time="2021-05-04T22:51:56.302945152Z" level=info msg="i>
May 04 22:51:56 460ffed 2ad22a3a1128[4847]: [event]   Event: Service exit {"service":{"appId":>
May 04 22:52:48 460ffed 2ad22a3a1128[4847]: [api]     GET /v1/healthy 200 - 3.569 ms
May 04 22:52:56 460ffed balenad[4887]: time="2021-05-04T22:52:56.652412108Z" level=info msg="s>
May 04 22:52:57 460ffed 2ad22a3a1128[4847]: [event]   Event: Service restart {"service":{"appI>
May 04 22:52:58 460ffed f3a751610baa[4847]: first Line
May 04 22:52:59 460ffed f3a751610baa[4847]: Second Line
May 04 22:53:04 460ffed balenad[4887]: time="2021-05-04T22:53:04.079746272Z" level=info msg="s>
May 04 22:53:04 460ffed balenad[4847]: time="2021-05-04T22:53:04.087678564Z" level=info msg="i>
May 04 22:53:04 460ffed 2ad22a3a1128[4847]: [event]   Event: Service exit {"service":{"appId":>
May 04 22:53:56 460ffed balenad[4887]: time="2021-05-04T22:53:56.556846356Z" level=info msg="s>
May 04 22:53:58 460ffed balenad[4887]: time="2021-05-04T22:53:58.350276147Z" level=info msg="s>
May 04 22:53:58 460ffed balenad[4847]: time="2021-05-04T22:53:58.355257033Z" level=info msg="i>
May 04 22:54:04 460ffed balenad[4887]: time="2021-05-04T22:54:04.423201458Z" level=info msg="s>
May 04 22:54:05 460ffed 2ad22a3a1128[4847]: [event]   Event: Service restart {"service":{"appI>
May 04 22:54:05 460ffed f3a751610baa[4847]: first Line
May 04 22:54:06 460ffed f3a751610baa[4847]: Second Line
May 04 22:54:10 460ffed balenad[4887]: time="2021-05-04T22:54:10.440352289Z" level=info msg="s>
May 04 22:54:10 460ffed balenad[4847]: time="2021-05-04T22:54:10.442686664Z" level=info msg="i>
May 04 22:54:10 460ffed 2ad22a3a1128[4847]: [event]   Event: Service exit {"service":{"appId":>
May 04 22:55:10 460ffed balenad[4887]: time="2021-05-04T22:55:10.795147214Z" level=info msg="s>
May 04 22:55:11 460ffed 2ad22a3a1128[4847]: [event]   Event: Service restart {"service":{"appI>
May 04 22:55:12 460ffed f3a751610baa[4847]: first Line
May 04 22:55:13 460ffed f3a751610baa[4847]: Second Line
May 04 22:55:16 460ffed balenad[4887]: time="2021-05-04T22:55:16.297876795Z" level=info msg="s>
May 04 22:55:16 460ffed balenad[4847]: time="2021-05-04T22:55:16.305345128Z" level=info msg="i>
May 04 22:55:16 460ffed 2ad22a3a1128[4847]: [event]   Event: Service exit {"service":{"appId":>
May 04 22:55:55 460ffed balenad[4847]: time="2021-05-04T22:55:55.757038603Z" level=error msg=">
May 04 22:55:55 460ffed balenad[4847]: time="2021-05-04T22:55:55.868593342Z" level=error msg=">
May 04 22:55:59 460ffed balenad[4847]: time="2021-05-04T22:55:59.967267716Z" level=error msg=">
May 04 22:56:00 460ffed balenad[4847]: time="2021-05-04T22:56:00.057833445Z" level=error msg=">

Do you have any ideas to move forward?

If this helps, my main goal at this point is to have a working set of code that uses OpenCV on the Jetson Nano. If you have any past projects with working sample code that you know works, I am not particular to the set of code on my github.

Removing this line allowed your version from this morning to finish building properly: Camera-Streamer/Dockerfile at 31261351f2628a32105312dc053fa58f5545369b · NateDKing/Camera-Streamer (github.com)

However, I have not pushed it to a device to test if the application actually runs, I just noticed it builds. So, you could possibly try that.

Alternatively, if all you want is an OpenCV sample, we sure do have that! Check this repo here: balena-io-playground/jetson-nano-sample-new: Jetson Nano sample using new packages (github.com)

I started with your alternative option at this link. I was able to build it without problems. I tried running the main.py file in the OpenCV service, and as a new “main” service. For both attempts, it reaches the “second line”, and seems to restart before importing cv2. Do you know how to add a python file to this structure that imports cv2, and runs?

In the example you cited, you would need to add the flags -D BUILD_opencv_python3=ON -D PYTHON3_EXECUTABLE=$(which python3) to the OpenCV cmake line with the other -D arguments (jetson-nano-sample-new/Dockerfile at fae92f4692abc2f570b93bbc919d16c0112a3aaa · balena-io-playground/jetson-nano-sample-new · GitHub) You may also have to install Python 3.7 or greater in one or both steps of that multi-step build.

Thank you, I added -D BUILD_opencv_python3=ON -D PYTHON3_EXECUTABLE=$(which python3) to line 33 of the docker file. I also copied the main.py to both services, so that is why there are two instances of the main.py code running. I did update the GitHub with the most recent code. It is still not able to pass the import cv2 of main.py. Do you know if I implemented the -D BUILD_opencv_python3=ON -D PYTHON3_EXECUTABLE=$(which python3) correctly, or how I would have it update to python 3.7?

06.05.21 14:33:36 (-0500) Restarting service 'main sha256:275844a421f252c2b29d36ebea6b735d3828153ca0d085bc3b232f8a401d371d'
06.05.21 14:33:37 (-0500)  main  first Line
06.05.21 14:33:37 (-0500)  opencv  first Line
06.05.21 14:33:38 (-0500)  main  Second Line
06.05.21 14:33:39 (-0500)  opencv  Second Line
06.05.21 14:33:52 (-0500) Service exited 'opencv sha256:684dd64c44124513d850860a749f18b1d2dc7685553f5e84f9ae05873d459c88'

Thank you!

It looks like you added the python flags correctly. Let’s temporarily try removing the multistep by deleting line 41 (Camera-Streamer/Dockerfile at a3eccbd6b3ca7e4a17411ece6b6edd9376a3b0af · NateDKing/Camera-Streamer · GitHub) through line 55, just in case some required cv2 files are not making into the second step. The container will be larger but it can be reduced later if this works.

I commented out lines 41-55, and the log is still showing:

07.05.21 10:40:53 (-0500) Restarting service 'opencv sha256:e47f042231a2c121a960763a00d90d06cb6afe29a8008af410d74a0bba5de463'
07.05.21 10:40:53 (-0500)  main  first Line
07.05.21 10:40:55 (-0500)  opencv  first Line
07.05.21 10:40:56 (-0500)  main  Second Line
07.05.21 10:40:56 (-0500)  opencv  Second Line
07.05.21 10:41:13 (-0500) Service exited 'opencv sha256:e47f042231a2c121a960763a00d90d06cb6afe29a8008af410d74a0bba5de463' 

Two questions:

  1. I have programed in java and python for a while, but I do not know much about setting up the environment. The main service I created, is it a use in any way, or should the main.py be in the OPENCV service only?
  2. I understand OPENCV is native in C++, but I have seen people using it for Python. Would this process be more streamlined if I used C++ instead of python? If so, I can switch over, if setting it up for python is what is causing these problems.

Other than those questions, would you have any suggestions on what could be causing this?

Each container is usually a standalone package of of software that includes everything needed to run your code. In your case, since main.py requires OpenCV, you really only need main.py in the OPENCV container. The others are not required, so you could remove them from your docker-compose, or just build from the Dockerfile in the OPENCV folder.

Using C++ would be more streamlined in that you would not need to build/install OpenCV Python support, so if you want to use C++ you are probably already set. However, the cause of your current issues aren’t quite clear yet.

All we see is the container exiting, so it would be helpful to see why. Can you reinstate CMD [ "sleep", "infinity" ] in your Dockerfile, ssh into the container and run main.py manually and let us know what the error message says?

Thanks!

I reinstated CMD [ "sleep", "infinity" ] , and received this in the terminal:

root@a274f174afb7:/usr/src/app# ls
Dockerfile
Tegra210_Linux_R32.4.4_aarch64.tbz2
core.803
corridor.jpg
example_ximgproc_fourier_descriptors_demo
example_ximgproc_paillou_demo
main.py
opencv_version
requirements.txt
root@a274f174afb7:/usr/src/app# python3 main.py
first Line
Second Line
Illegal instruction (core dumped)
root@a274f174afb7:/usr/src/app# 

-Also, the GitHub is up to date.

Edit:

I googled the Illegal instruction (core dumped) error, and found an issue here for tensorflow import that was similar. They solved it by installing an older version of the library. I ran pip list and have the results below, if you think these could be useful.

root@a274f174afb7:/usr/src/app# pip list
Package                Version
---------------------- ---------------
asn1crypto             0.24.0
certifi                2018.1.18
chardet                3.0.4
click                  7.1.2
cryptography           2.1.4
Flask                  1.1.2
httplib2               0.9.2
idna                   2.6
itsdangerous           1.1.0
Jetson.GPIO            2.0.11
Jinja2                 2.11.3
keyring                10.6.0
keyrings.alt           3.0
MarkupSafe             1.1.1
numpy                  1.19.5
opencv-python-headless 4.5.1.48
pip                    21.1.1
pycrypto               2.6.1
pygobject              3.26.1
python-apt             1.6.5+ubuntu0.5
pyxdg                  0.25
requests               2.18.4
requests-unixsocket    0.1.5
SecretStorage          2.3.1
setuptools             39.0.1
six                    1.11.0
systemd-python         234
urllib3                1.22
Werkzeug               1.0.1
wheel                  0.30.0
root@a274f174afb7:/usr/src/app#

I see two possible issues: in your requirements.txt file you’re installing opencv-python-headless, which may be overwriting parts of the previous OpenCV Python support you already built from scratch. I would try removing that requirement.
The “Illegal instruction” error could be part of this numpy issue: Illegal instruction (core dumped) on import for numpy 1.19.5 on ARM64 · Issue #18131 · numpy/numpy · GitHub - you have the version in question on the same architecture. Their suggestion is to pin your numpy to an earlier version with something like pip3 install numpy==1.19.4 - but you probably want to do this in the Dockerfile before the OpenCV build.

I removed the opencv-python-headless from requirements.txt and added pip3 install numpy==1.19.4. It is now showing this error:

root@10945f2aaee4:/usr/src/app# python3 main.py
first Line
Second Line
Traceback (most recent call last):
  File "main.py", line 4, in <module>
    import cv2  
ModuleNotFoundError: No module named 'cv2'
root@10945f2aaee4:/usr/src/app#

To me, it seems like the same error as in post 16 of this thread. Do you have any suggestions on how to proceed?

github

Side question,

I was able to download working OpenCV code for RaspberryPi B+ from here. I forked the project to see if I could adjust it to work with the Jetson, and I changed the FROM line in the docker file, to FROM balenalib/jetson-nano-ubuntu:bionic as buildstep, beacuse the origional line produced this error:

Error: manifest for balenalib/jetson-nano-2gb-devkit-debian:buster not found: Manifest unknown: manifest unknown

It now seems to get stuck on the following prompt:

[opencv-test]  Setting up libnuma1:arm64 (2.0.11-2.1ubuntu0.1) ...
[opencv-test]  Setting up tzdata (2021a-0ubuntu0.18.04) ...
[opencv-test]  debconf: unable to initialize frontend: Dialog
[opencv-test]  debconf: (TERM is not set, so the dialog frontend is not usable.)
[opencv-test]  debconf: falling back to frontend: Readline
[opencv-test]  Configuring tzdata
[opencv-test]  ------------------
[opencv-test]  Please select the geographic area in which you live. Subsequent configuration
[opencv-test]  questions will narrow this down by presenting a list of cities, representing
[opencv-test]  the time zones in which they are located.
[opencv-test]    1. Africa      4. Australia  7. Atlantic  10. Pacific  13. Etc
[opencv-test]    2. America     5. Arctic     8. Europe    11. SystemV
[opencv-test]    3. Antarctica  6. Asia       9. Indian    12. US
[opencv-test]  Geographic area:
[Info]         Still Working...
[Info]         Still Working...
[Info]         Still Working...
[Info]         Still Working...
[Info]         Still Working...
[Info]         Still Working...

It installs OpenCV using apt-get install python3-opencv. Do you know if there is a way to enter my geographic area, and if so would it work and build to working opencv?

Forked Project

We have another working example of building OpenCV and importing cv2 into Python here although it is for a Pi 3. I’ll see if I can make a few tweaks for the Jetson so we have a good working example. In regards to your side question, you could try adding the line ENV DEBIAN_FRONTEND=noninteractive near the top of your Dockerfile to suppress configuration prompts.

Good News!

It works! Thank you and the balena team for all your help! I was able to implement the ENV DEBIAN_FRONTEND=noninteractive to the second project, linked here.

I do not know enough about setting up the environment to know if I am missing parts of OpenCV from the larger make file, but atleast for my purpuses, this one seems to work!

Thank you!

1 Like