...
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 |
...
Build the sample application "jpeg_app" and install it on the camera (eg, it can be installed from the green frame in the image below).
See here for how to buildPlease perform the build method according to each SDK version.
Open the app screen (red frame button in the image below), and if the jpeg image taken by the camera is displayed, it is successful.
...
Build the sample application "sqlite_app" and install it on the camera (eg, it can be installed from the green frame in the image below).
See here for how to buildPlease perform the build method according to each SDK version.
Open the app screen (red frame button in the image below),
...
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
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 |
Compile
Compile pycurl module and OpenSSL 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/additional_info_sample_app” as an example.
Deploy PyCurl
...
Info |
---|
If the SoC is ambaCV5X and the camera firmware is v3.10 or earlier, it will use OpenSSL 1.1.1 in the camera, so it will work without placing OpenSSL. Since the camera firmware is v3.20 or later, OpenSSL has been updated to 3.0.12, so it will not work unless OpenSSL is placed in the app or built using OpenSSL 3.0.12. Please select and use the version of OpenSSL that suits your app environment. For more information on SoC, see below. Installation conditions for applications - FAQ - Development Partner Portal (En) (i-pro.com) |
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
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 |
Compile
Compile pycurl module and OpenSSL 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/hogehoge_app” as an example.
Deploy PyCurl
PyCurl module is installed in the following directory.
${SDK_DIR}/external/build/sample/docker/docker_volume/pycurl-7.45.2/build/lib.linux-aarch64-3.7
pycurl.cpython-37m-aarch64-linux-gnu.so
Copy the above file to the AdamApp source directory.
${SDK_DIR}/src/adamapp-py/hogehoge_app/python/site-packages
Code Block |
---|
$ cp -R ${SDK_DIR}/external/build/sample/docker/docker_volume/pycurl-7.45.2/build/lib.linux-aarch64-3.7/pycurl.cpython-37m-aarch64-linux-gnu.so ${SDK_DIR}/src/adamapp-py/hogehoge_app/python/site-packages |
Then, the directory structure will be as follows.
${SDK_DIR}/src/adamapp-py/hogehoge_app/python/site-packages/pycurl.cpython-37m-aarch64-linux-gnu.so
Modify the source code to load PyCurl
Open “${SDK_DIR}/src/adamapp-py/hogehoge_app/python/pymain.py” and add as follows.
import os;
Add the following one line below.
import pycurl;
...
Build the sample application
Build the sample application "hogehoge_app" and install it on the camera (eg, it can be installed from the green frame in the image below).
Please perform the build method according to each SDK version.
...
Compile a Python module (Numba)
...
This article describes the steps to build Numba, which is used to speed up Python.
Download source code
Several modules are required to run Numba. Please download each source code from the URL below. Also, please select a version of each module that is compatible with Python 3.7.9.
Numba 0.56.4:
https://github.com/numba/numba/archive/refs/tags/0.56.4.zipNumpy 1.19.4:
https://github.com/numpy/numpy/archive/v1.19.4.tar.gzLLVM 11.1.0:
https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-11.1.0.tar.gzllvmlite 0.39.1:
https://github.com/numba/llvmlite/archive/refs/tags/v0.39.1.tar.gzimportlib_metadata 6.7.0:
https://github.com/python/importlib_metadata/archive/refs/tags/v6.7.0.ziptyping_extensions 4.7.1:
https://github.com/python/typing_extensions/archive/refs/tags/4.7.1.zipzipp 3.15.0:
https://github.com/jaraco/zipp/archive/refs/tags/v3.15.0.zip
Place the downloaded file in the following directory. ${SDK_DIR}/external/build/sample/docker/docker_volume
Update the compilation instructions file
The compilation procedure is described in the file below.
${SDK_DIR}/external/build/sample/docker/docker_volume/module_compile.sh
Please copy the content below.
Code Block |
---|
#!/bin/sh -x
#----------
HOME_PATH=/home/docker
LIB_INSTALL_DIR=${HOME_PATH}/install_path
SITE_PACKAGES=${LIB_INSTALL_DIR}/lib/python3.7/site-packages
NUMPY_ARCHIVES=numpy-1.19.4.tar.gz
NUMPY_DIR=numpy-1.19.4
LLVM_ARCHIVES=llvm-project-llvmorg-11.1.0.tar.gz
LLVM_DIR=llvm-project-llvmorg-11.1.0
LLVM_INSTALL_DIR=${LIB_INSTALL_DIR}/llvm
LLVM_PATCH_SRC=${LLVMLITE_DIR}/conda-recipes
LLVM_PATCH_DST=${LLVM_DIR}/llvm
LLVMLITE_ARCHIVES=llvmlite-0.39.1.tar.gz
LLVMLITE_DIR=llvmlite-0.39.1
NUMBA_ARCHIVES=numba-0.56.4.zip
NUMBA_DIR=numba-0.56.4
#----------
# NumPy
cd ${HOME_PATH}
mkdir -p ${SITE_PACKAGES}
tar xf ${NUMPY_ARCHIVES}
cd ${NUMPY_DIR}
python setup.py build
PYTHONPATH=$PYTHONPATH:${SITE_PACKAGES}
export PYTHONPATH
python setup.py install --prefix=${LIB_INSTALL_DIR}
# LLVM / llvmlite
cd ${HOME_PATH}
tar xf ${LLVM_ARCHIVES}
tar xf ${LLVMLITE_ARCHIVES}
cd ${LLVM_PATCH_DST}
for patchFile in $(find ../../${LLVM_PATCH_SRC} -name "*.patch" -type f); do
patch --dry-run -f -p1 -i ${patchFile}
if [ $? -eq 0 ]; then
patch -p1 -i ${patchFile}
fi
done
LLVM_BUILD_SH="../../${LLVMLITE_DIR}/conda-recipes/llvmdev/build.sh"
mkdir -p ${LLVM_INSTALL_DIR}
export PREFIX=${LLVM_INSTALL_DIR} CPU_COUNT=2
sed -i -e "s/\(^LLVM_TARGETS_TO_BUILD=\).*/\1\$\{LLVM_TARGETS_TO_BUILD:-\"AArch64\"\}/" ${LLVM_BUILD_SH}
sed -i -e "/LLVM_ENABLE_ASSERTIONS/d" ${LLVM_BUILD_SH}
sed -i -e "/LLVM_EXPERIMENTAL_TARGETS_TO_BUILD/d" ${LLVM_BUILD_SH}
chmod +x ${LLVM_BUILD_SH}
${LLVM_BUILD_SH}
cd ../../
cd ${LLVMLITE_DIR}
export LLVM_CONFIG=${LLVM_INSTALL_DIR}/bin/llvm-config
python setup.py build
python setup.py install --prefix=${LIB_INSTALL_DIR}
cd ../
# numba
unzip ${NUMBA_ARCHIVES}
cd ${NUMBA_DIR}
export NUMBA_DISABLE_TBB=1
python setup.py build
python setup.py install --prefix=${LIB_INSTALL_DIR}
cd ../
# replace some libraries compatible with python3.7
cd ${HOME_PATH}
unzip importlib_metadata-6.7.0.zip
mv importlib_metadata-6.7.0/importlib_metadata ${SITE_PACKAGES}
unzip typing_extensions-4.7.1.zip
mv typing_extensions-4.7.1/src/typing_extensions.py ${SITE_PACKAGES}
unzip zipp-3.15.0.zip
mv zipp-3.15.0/zipp ${SITE_PACKAGES}
# cleanup
cd ${SITE_PACKAGES}
rm -f easy-install.pth setuptools.pth site.py
find . -maxdepth 2 -name numpy -type d -exec mv {} . \;
find . -maxdepth 2 -name numba -type d -exec mv {} . \;
rm -rf *.egg*
find . -name *pycache* -type d -print | xargs rm -rf
find . -name tests -type d -print | xargs rm -rf
find . -name *.so | xargs aarch64-linux-gnu-strip --strip-debug
cd ${HOME_PATH} |
compile
Compile each module using Docker.
Run Docker in the directory below.
${SDK_DIR}/external/build/sample/docker
...
pycurl.cpython-37m-aarch64-linux-gnu.so
Copy the above file to the AdamApp source directory.
${SDK_DIR}/src/adamapp-py/additional_info_sample_app/python/site-packages
...
Code Block |
---|
$ docker run --rm -it --name aarch64-ubuntu -v `pwd`/docker_volume:/home/docker compile/ubuntu-rel:0.1 |
Compiled modules are placed in the following directories.
${SDK_DIR}/external/build/sample/docker/docker_volume/
...
install_path/lib/python3.7/site-packages
Info |
---|
LLVM will take some time to compile, so please wait for a while. |
Place in AdamApp
Place the created module so that it can be used by AdamApp.
The tutorial uses the following as an example.
${SDK_DIR}/src/adamapp-py/
...
yuv_
...
yolov5_app
...
Then,
Place the module
Copy the compiled module to the AdamApp source directory, keeping the directory structure will be as followsis.
$ cp -R ${SDK_DIR}/srcexternal/adamapp-py/additional_info_sample_app/python/site-packages/pycurl.cpython-37m-aarch64-linux-gnu.so
Modify the source code to load PyCurl
...
build/sample/docker/docker_volume/install_path/lib/python3.7/site-packages ${SDK_DIR}/src/adamapp-py/
...
yuv_
...
yolov5_app/python/
update pymain.py” and add as follows.
import os;
Add the following one line below.
import pycurl;
...
Build the sample application
Build the sample application "additional_info_sample.py
Change the source code to be compatible with numba. Replace the attached file "pymain.py" with the file below.
\src\adamapp-py\yuv_yolov5_app\python\pymain.py
View file | ||
---|---|---|
|
Build the sample app
Build the sample app "yuv_yolov5_app" and install it on the camera (eg, it can be installed from the green frame in the image below).
See here for how to build.
Open the app screen (red frame button in the image below), and if the string is displayed like "body", it is successful.
...
. Please perform the build method according to each SDK version. When you open the app screen, if there is a frame around the object (such as a person) on the screen, it is a success.
Please also refer to the operation explanation of the sample application.
If it fails, a message will be displayed on the application screen indicating that the application has failed to start. From now on, please use the message content and debugging tools to solve the problem and create an application.
...