...
Here we proceed without changing “module_compile.sh”.
Compile
Compile NumPy module and OpenCV module using docker.
Run Docker in “${SDK_DIR}/external/build/sample/docker” directory.
Code Block |
---|
Code Block |
#!/bin/sh -x HOME_PATH=/home/docker compile/ubuntu-rel:0.1 |
...
NUMPY_ARCHIVES=numpy-1.19.4.tar.gz
NUMPY_DIR=numpy-1.19.4
LIB_INSTALL_DIR=${HOME_PATH}/install_path
NUMPY_SITE_PACKAGES=${LIB_INSTALL_DIR}/lib/python3.7/site-packages
OPENCV_ARCHIVES=opencv-3.4.7.zip
OPENCV_DIR=opencv-3.4.7
OPENCV_BUILD_DIR=opencv-3.4.7/build
## for NumPy
cd ${HOME_PATH}
mkdir -p ${NUMPY_SITE_PACKAGES}
tar zxf ${NUMPY_ARCHIVES}
cd ${NUMPY_DIR}
python setup.py build
PYTHONPATH=$PYTHONPATH:${NUMPY_SITE_PACKAGES}
export PYTHONPATH
python setup.py install --prefix=${LIB_INSTALL_DIR}
## for OpenCV
cd ${HOME_PATH}
unzip ${OPENCV_ARCHIVES}
mkdir -p ${OPENCV_BUILD_DIR}
cd ${OPENCV_BUILD_DIR}
cmake \
-G "Unix Makefiles" \
-D CMAKE_INSTALL_PREFIX=${LIB_INSTALL_DIR} \
-D BUILD_CUDA_STUBS=OFF \
-D BUILD_DOCS=OFF \
-D BUILD_EXAMPLES=OFF \
-D BUILD_JASPER=OFF \
-D BUILD_JPEG=OFF \
-D BUILD_OPENEXR=OFF \
-D BUILD_PACKAGE=ON \
-D BUILD_PERF_TESTS=OFF \
-D BUILD_PNG=OFF \
-D BUILD_SHARED_LIBS=ON \
-D BUILD_TBB=OFF \
-D BUILD_TESTS=OFF \
-D BUILD_TIFF=OFF \
-D BUILD_WITH_DEBUG_INFO=ON \
-D BUILD_ZLIB=OFF \
-D BUILD_WEBP=OFF \
-D BUILD_opencv_apps=OFF \
-D BUILD_opencv_calib3d=ON \
-D BUILD_opencv_core=ON \
-D BUILD_opencv_cudaarithm=OFF \
-D BUILD_opencv_cudabgsegm=OFF \
-D BUILD_opencv_cudacodec=OFF \
-D BUILD_opencv_cudafeatures2d=OFF \
-D BUILD_opencv_cudafilters=OFF \
-D BUILD_opencv_cudaimgproc=OFF \
-D BUILD_opencv_cudalegacy=OFF \
-D BUILD_opencv_cudaobjdetect=OFF \
-D BUILD_opencv_cudaoptflow=OFF \
-D BUILD_opencv_cudastereo=OFF \
-D BUILD_opencv_cudawarping=OFF \
-D BUILD_opencv_cudev=OFF \
-D BUILD_opencv_features2d=ON \
-D BUILD_opencv_flann=ON \
-D BUILD_opencv_hal=ON \
-D BUILD_opencv_highgui=ON \
-D BUILD_opencv_imgcodecs=ON \
-D BUILD_opencv_imgproc=ON \
-D BUILD_opencv_java=OFF \
-D BUILD_opencv_ml=ON \
-D BUILD_opencv_objdetect=ON \
-D BUILD_opencv_photo=ON \
-D BUILD_opencv_python2=OFF \
-D BUILD_opencv_python3=ON \
-D PYTHON3_DEFAULT_EXECUTABLE=/usr/bin/python3.7 \
-D PYTHON3_EXECUTABLE=/usr/bin/python3.7 \
-D PYTHON3_LIBRARY=/usr/lib/python3.7 \
-D PYTHON3_INCLUDE_DIR=/usr/include/python3.7 \
-D PYTHON3_NUMPY_INCLUDE_DIRS=${NUMPY_SITE_PACKAGES}/numpy-1.19.4-py3.7-linux-aarch64.egg/numpy/core/include \
-D BUILD_opencv_shape=OFF \
-D BUILD_opencv_stitching=OFF \
-D BUILD_opencv_superres=OFF \
-D BUILD_opencv_ts=OFF \
-D BUILD_opencv_video=ON \
-D BUILD_opencv_videoio=ON \
-D BUILD_opencv_videostab=OFF \
-D BUILD_opencv_viz=OFF \
-D BUILD_opencv_world=ON \
-D CMAKE_BUILD_TYPE=RELEASE \
-D ENABLE_NEON=ON \
-D WITH_1394=OFF \
-D WITH_CUBLAS=OFF \
-D WITH_CUDA=OFF \
-D WITH_CUFFT=OFF \
-D WITH_EIGEN=OFF \
-D WITH_FFMPEG=OFF \
-D WITH_GDAL=OFF \
-D WITH_GPHOTO2=OFF \
-D WITH_GIGEAPI=OFF \
-D WITH_GSTREAMER=OFF \
-D WITH_GTK=OFF \
-D WITH_INTELPERC=OFF \
-D WITH_IPP=OFF \
-D WITH_IPP_A=OFF \
-D WITH_JASPER=OFF \
-D WITH_JPEG=ON \
-D WITH_LIBV4L=OFF \
-D WITH_OPENCL=OFF \
-D WITH_OPENCLAMDBLAS=OFF \
-D WITH_OPENCLAMDFFT=OFF \
-D WITH_OPENCL_SVM=OFF \
-D WITH_OPENEXR=OFF \
-D WITH_OPENGL=OFF \
-D WITH_OPENMP=OFF \
-D WITH_OPENNI=OFF \
-D WITH_PNG=OFF \
-D WITH_PTHREADS_PF=OFF \
-D WITH_PVAPI=OFF \
-D WITH_QT=OFF \
-D WITH_TBB=OFF \
-D WITH_TIFF=OFF \
-D WITH_UNICAP=OFF \
-D WITH_V4L=OFF \
-D WITH_VTK=OFF \
-D WITH_WEBP=OFF \
-D WITH_XIMEA=OFF \
-D WITH_XINE=OFF \
../../${OPENCV_DIR}
make
make install |
Compile
Compile NumPy module and OpenCV module using docker.
Run Docker in “${SDK_DIR}/external/build/sample/docker” directory.
Code Block |
---|
$ docker run --rm -it --name aarch64-ubuntu -v `pwd`/docker_volume:/home/docker compile/ubuntu-rel:0.1 |
The compiled module is created in “external/build/sample/docker/docker_volume/install_path”.
...
AdamApp does not use (_pycache_), Python cash file.We recommend that you delete the files to reduce the folder sizefile.
We recommend that you delete the files to reduce the folder size.
Info |
---|
Simply deleting unnecessary files can reduce the capacity by several tens of MB. Please note that if the app file size becomes too large, it may cause the app to crash due to ROM capacity limitations. |
Code Block | ||
---|---|---|
| ||
$ cd ${SDK_DIR}/src/adamapp-py/yuv_yolo_app/python/site-packages/numpy/ $ find . -name *pycache* -print | xargs rm -rf |
...
Code Block | ||
---|---|---|
| ||
$ cd ${SDK_DIR}/src/adamapp-py/yuv_yolo_app/external/lib/aarch64-linux-gnu/
$ aarch64-linux-gnu-strip --strip-debug libopencv_world.so.3.4.7 |
...
Numpy and OpenCV were compiled. As the next tutorial, we will compile SQLite.
Download source code
Download sqlite and Python source code from the URLs below.
This tutorial uses sqlite 3.40.0, Python 3.7.9.
Select the version to download according to the functions you use.
sqlite 3.40.0
https://www.sqlite.org/2022/sqlite-autoconf-3400000.tar.gz
Python 3.7.9
Place the downloaded files to “${SDK_DIR}/external/build/sample/docker/docker_volume” directory.
Update compilation instructions file
Put the compilation instructions in “${SDK_DIR}/external/build/sample/docker/docker_volume/module_compile.sh” file.
Please copy the content below.
...
Download source code
Download sqlite and Python source code from the URLs below.
This tutorial uses sqlite 3.40.0, Python 3.7.9.
Select the version to download according to the functions you use.
sqlite 3.40.0
...
Python 3.7.9
...
Compile
Compile sqlite module and Python module using docker.
Run Docker in “${SDK_DIR}/external/build/sample/docker” directory.
Code Block |
---|
$ docker run --rm -it --name aarch64-ubuntu -v `pwd`/docker_volume:/home/docker compile/ubuntu-rel:0.1 |
The compiled module is created in “external/build/sample/docker/docker_volume/install_path”.
Deployment in AdamApp
Deploy the modules to use them with AdamApp.
Here we take “${SDK_DIR}/src/adamapp-py/sqlite_app” as an example.
Info |
---|
An SD card is required for sqlite_app to work. Only cameras that can insert an SD card can be checked. Also, depending on the firmware of the camera, it may not work unless the SD card is formatted with ext4. |
Deploy SQLite
SQLite module is installed in the following directory.
${SDK_DIR}/external/build/sample/docker/docker_volume/install_path/lib
libsqlite3.so
libsqlite3.so.0
libsqlite3.so.0.8.6
libsqlite3.la
libsqlite3.a
Copy the above 5 files to the AdamApp source directory.
${SDK_DIR}/src/adamapp-py/sqlite_app/external/lib/aarch64-linux-gnu
...
Place the downloaded files to “${SDK_DIR}/external/build/sample/docker/docker_volume” directory.
Update compilation instructions file
Put the compilation instructions in “${SDK_DIR}/external/build/sample/docker/docker_volume/module_compile.sh” file.
Please copy the content below.
Code Block |
---|
#!/bin/sh -x
HOME_PATH=/home/docker
LIB_INSTALL_DIR=${HOME_PATH}/install_path
SQLITE_ARCHIVES=sqlite-autoconf-3400000.tar.gz
SQLITE_DIR=sqlite-autoconf-3400000
SQLITE_BUILD_DIR=sqlite-autoconf-3400000/build
PYTHONPATH=$PYTHONPATH:${NUMPY_SITE_PACKAGES}
export PYTHONPATH
PYTHON_ARCHIVES=Python-3.7.9.tgz
PYTHON_DIR=Python-3.7.9
## for sqlite
cd ${HOME_PATH}
tar zxf ${SQLITE_ARCHIVES}
mkdir -p ${SQLITE_BUILD_DIR}
cd ${SQLITE_DIR}
./configure --prefix=${LIB_INSTALL_DIR}
make
make install
## for python
cd ${HOME_PATH}
tar zxf ${PYTHON_ARCHIVES}
cd ${PYTHON_DIR}
./configure --prefix=${LIB_INSTALL_DIR}
make
make install |
Compile
Compile sqlite module and Python module using docker.
Run Docker in “${SDK_DIR}/external/build/sample/docker” directory.
Code Block |
---|
$ docker run --rm -it --name aarch64-ubuntu -v `pwd`/docker_volume:/home/docker compile/ubuntu-rel:0.1 |
The compiled module is created in “external/build/sample/docker/docker_volume/install_
...
path”.
Deployment in AdamApp
Deploy the modules to use them with AdamApp.
Here we take “${SDK_DIR}/src/adamapp-py/sqlite_
...
app” as an example.
Info |
---|
An SD card is required for sqlite_app to work. Only cameras that can insert an SD card can be checked. Also, depending on the firmware of the camera, it may not work unless the SD card is formatted with ext4. |
Deploy SQLite
SQLite module is installed in the following directory.
${SDK_DIR}/external/build/sample/docker/docker_volume/install_path/lib
...
libsqlite3.so
libsqlite3.so.0
libsqlite3.so.0.8.6
Copy the above 5 files to the AdamApp source directory.
${SDK_DIR}/src/adamapp-py/sqlite_app/external/lib/aarch64-linux-gnu
...
Code Block |
---|
$ cp -R ${SDK_DIR}/external/build/sample/docker/docker_volume/install_path/lib/libsqlite3.so.0.8.6 ${SDK_DIR}/src/adamapp-py/sqlite_app/external/lib/aarch64-linux-gnu $ cp -R ${SDK_DIR}/external/build/sample/docker/docker_volume/install_path/lib/libsqlite3.laso.0 ${SDK_DIR}/src/adamapp-py/sqlite_app/external/lib/aarch64-linux-gnu $ cp -R ${SDK_DIR}/external/build/sample/docker/docker_volume/install_path/lib/libsqlite3.aso.0.8.6 ${SDK_DIR}/src/adamapp-py/sqlite_app/external/lib/aarch64-linux-gnu |
Then, the directory structure will be as follows.
...
.
...
${SDK_DIR}/src/adamapp-py/sqlite_app/external/lib/aarch64-linux-gnu/libsqlite3.so.0
${SDK_DIR}/src/adamapp-py/sqlite_app/external/lib/aarch64-linux-gnu/libsqlite3.so.0.8.6
${SDK_DIR}/src/adamapp-py/sqlite_app/external/lib/aarch64-linux-gnu/libsqlite3.la
${SDK_DIR}/src/adamapp-py/sqlite_app/external/lib/aarch64-linux-gnu/libsqlite3.a.so.0.8.6
Deploy sqlite for Python
...
pycurl 7.45.2
OpenSSL 1.1.1
https://github.com/openssl/openssl/archive/OpenSSL_1_1_1i.tar.gz
OpenSSL 3.0.12
https://github.com/openssl/openssl/releases/download/openssl-3.0.12/openssl-3.0.12.tar.gz
Place the downloaded files to “${SDK_DIR}/external/build/sample/docker/docker_volume” directory.
Info |
---|
If the ambaCV5X SoC your SoC is ambaCV2X or ambaCV5X (camera firmware is v3.10 or earlier), the camera uses use OpenSSL 1.1.1 , so it will work without placing OpenSSL. Camera firmware to match the version of OpenSSL in the camera. If your SoC is ambaCV5X (v3.20 and later has been updated to or later), use OpenSSL 3.0.12 , so it will not work unless OpenSSL is placed. Please select and use the version of OpenSSL that matches your app environmentas it has been updated to OpenSSL 3.0.12. For more information on SoC, see below. Installation conditions for applications - FAQ - Development Partner Portal (En) (i-pro.com) |
...
Code Block |
---|
#!/bin/sh -x HOME_PATH=/home/docker OPENSSL_ARCHIVES=openssl-OpenSSL_1_1_1i.tar.gz OPENSSL_DIR=openssl-OpenSSL_1_1_1i PYCURL_ARCHIVES=pycurl-7.45.2.tar.gz PYCURL_DIR=pycurl-7.45.2 apt update apt install libcurl4-openssl-dev libssl-dev cd ${HOME_PATH} tar zxf ${OPENSSL_ARCHIVES} cd ${OPENSSL_DIR} ./Configure linux-aarch64 make export PYCURL_SSL_LIBRARY=openssl export CPPFLAGS=-I${HOME_PATH}/${OPENSSL_DIR}/include/openssl export LDFLAGS=-L${HOME_PATH}/${OPENSSL_DIR} ## for pycurl cd ${HOME_PATH} tar zxf ${PYCURL_ARCHIVES} cd ${PYCURL_DIR} python3.7 setup.py --with-openssl --openssl-dir=${HOME_PATH}/${OPENSSL_DIR} build |
Info |
---|
If you are using OpenSSL 3.0.12, please rewrite it as follows. Before) OPENSSL_ARCHIVES=openssl-OpenSSL_1_1_1i.tar.gz After) OPENSSL_ARCHIVES=openssl-3.0.12.tar.gz |
Compile
Compile pycurl module and OpenSSL module using docker.
...