Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install OpenCV in Orange pie 4B Python3.7

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article is about how to install OpenCV in Orange Pie 4B Python 3.7. Xiaobian thinks it is quite practical, so share it with everyone for reference. Let's follow Xiaobian and have a look.

Environmental preparation:

1. Install the official website with NPU related system image, the current version is Ubuntu 18.04. This image contains GTI related files. It seems that using https://www.gyrfalcontech.ai/zh/ GTI is not free, registration is required to download the SDK (CNN only), and premium (paid) members can use MDK training models.

2. Run SourceMe.env in the GTI folder GTISDK-Linux_aarch 74_v4.5.1.0

source SourceMe.env

OpenCV required

Execute install_opencv.sh that comes with the system.

After the execution is completed, the dependency environment required to compile OpenCV is basically ready. According to the instructions, it should be automatically installed. Enter Python 2.7, import cv2 should be normal.

But my actual situation is that I installed Python 3.7.5, the implementation of SourceMe.env is written for python2.7, and I use update-alternatives --install python and pip command default upgrade Python 3.7.5 provided, the final SourceMe.env running result is prompted python-opencv, however pip install python-opencv and did not find this package, can only download OpenCV source code from the official website for compilation.

Build and install OpenCV for Python 3.7.5

Download opencv3.4.10 from the official website (because I don't know if GTISDK is compatible with OpenCV4).

Unzip to/home/orangepi/OpenCV and create the build folder

#Create folder mkdir build#Go to build folder cd /home/orangepi/OpenCV/build

Use Cmake to configure compilation settings (so that should be correct...), This is the most crucial step.

cmake -DBUILD_opencv_python3=yes -DPYTHON3_PACKAGES_PATH=/home/orangepi/.local/lib/python3.7/site-packages -DPYTHON_DEFAULT_EXECUTABLE=/usr/bin/python3.7 -DWITH_CUDA=OFF -DWITHCUFFT=OFF -DCUBLAS=OFF -DWITH_NVCUVID=OFF -DWITH_LAPACK=OFF -DWITH_QT=OFF -DWITH_JAVA=OFF -DWITH_OPENGL=ON -DFORCE_VTK=ON -DWITH_TBB=ON -DWITH_GDAL=ON -DWITH_XINE=ON -DBUILD_EXAMPLES=OFF -DENABLE_PRECOMPILED_HEADERS=OFF -DBUILD_opencv_world=ON -DBUILD_opencv_ts=OFF ..

According to your actual situation, modify the Python-related configuration in the above command. There are CUDA-related configurations, I don't know if it can also be configured for Jetson Nano.

Notice if the Python information is the version of Python you specified.

Then make -j2 compiles using two threads (obviously there are 6 cores, using-j4 will have problems, a little confused)

Sudo make install

Testing OpenCV

>>> import numpy as np>>> import cv2 as cv>>> #Modify the image path yourself>>> img = cv.imread ('messi5.jpg ')>>> #Print the colors of the three channels B G R in the coordinates.>>> print(img[100,100]) Thank you for reading! About "Orange pie 4B Python 3.7 how to install OpenCV" this article is shared here, I hope the above content can be of some help to everyone, so that everyone can learn more knowledge, if you think the article is good, you can share it to let more people see it!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report