Install opencv in termux

1. Install python3 and dev

pkg install python python-dev

2. Install tools and libs

pkg install libjpeg-turbo-dev libpng-dev cmake pkg-config

3. Clone opencv from git

git clone && cd opencv

4. Create build directory

mkdir build && cd build

5. Configure

LDFLAGS=" -llog -lpython3" cmake -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=$PREFIX -DBUILD_opencv_python3=on -DBUILD_opencv_python2=off -DWITH_QT=OFF -DWITH_GTK=OFF ..

Don’t missing the double dot at the end of command, It means start from the parent folder. After success, execute the following command:

make install

Please be noted that make will take a long time.
6. After installed, test it in python
>>> import cv2
If no error it will print the version

Note: don’tt install python2, cmake will confuse with it and when import cv will face error.


电子邮件地址不会被公开。 必填项已用*标注