- OpenCV (3.4.4和4.5.2)
1. Follow this website to install the necessary packages
2. My setting for CMakecmake {...} -D CMAKE_BUILD_TYPE=RELEASE \ -D CMAKE_INSTALL_PREFIX=/usr/local \ -D INSTALL_C_EXAMPLES=OFF \ -D INSTALL_PYTHON_EXAMPLES=ON \ -D BUILD_EXAMPLES=ON \ -D WITH_CUDA=OFF (CUDA SDK is not installed) \ -D WITH_OPENCL=ON \ -D OPENCV_EXTRA_MODULES_PATH=~/openCV/opencv_contrib/modules\ (your_path) -D PYTHON2_EXECUTABLE=\ -D BUILD_OPENCV_PYTHON3=yes\ -D PYTHON3_EXECUTABLE=/usr/bin/python3.8\ -D PYTHON3_INCLUDE_DIR=/usr/include/python3.8\ -D PYTHON3_INCLUDE_DIR2=/usr/include/python3.8\ -D PYTHON3_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython3.8.so\ (a soft lint) -D PYTHON3_NUMPY_INCLUDE_DIRS=/usr/local/lib/python3.8/dist-packages/numpy/core/include\ (your_path, apt-get install python3-numpy) -D PYTHON3_PACKAGES_PATH=/usr/lib/python3/dist-packages -D OPENCV_GENERATE_PKGCONFIG=YES (create the opencv4.pc for opencv version 4.x)
-D WITH_TENGINE=ON (for Tengine on ARM_64) -D OPENCV_ENABLE_NONFREE:BOOL=ON (such as SURF for Image Stitching) .. ----------------------------------------------------------------------------- ----------------------------------------------------------------------------- CMAKE要3.19以上(為什麼不會寫在CMakeError.log = =, 後來又有freetype/harfhuzz的問題,先用4.5.3) -D BUILD_ANDROID_EXAMPLES=OFF \ -D ANDROID_NDK=$NDK \ -D CMAKE_TOOLCHAIN_FILE=$NDK/build/cmake/android.toolchain.cmake \ -D BUILD_ANDROID_PROJECTS=OFF \ -D ANDROID_ABI=arm64-v8a \ -D ANDROID_STL=c++_shared \ -D ANDROID_NATIVE_API_LEVEL=android-29 -D BUILD_SHARED_LIBS=ON \ (build so file) -D OpenCV_STATIC=OFF ..... ... ... -D PYTHON3_EXECUTABLE=$(which python3) \ -D PYTHON_INCLUDE_DIR=$(python3 -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") \ -D PYTHON_INCLUDE_DIR2=$(python3 -c "from os.path import dirname; from distutils.sysconfig import get_config_h_filename; print(dirname(get_config_h_filename()))") \ -D PYTHON_LIBRARY=$(python3 -c "from distutils.sysconfig import get_config_var;from os.path import dirname,join ; print(join(dirname(get_config_var('LIBPC')),get_config_var('LDLIBRARY')))") \ -D PYTHON3_NUMPY_INCLUDE_DIRS=$(python3 -c "import numpy; print(numpy.get_include())") \ -D PYTHON3_PACKAGES_PATH=$(python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") ref: stackoverflow
3. Output (Check the Libraries path in Python 3)
... ... ... ... -- OpenCL: YES (no extra features) -- Include path: /home/nice/openCV/opencv/3rdparty/include/opencl/1.2 -- Link libraries: Dynamic load -- -- Python 3: -- Interpreter: /usr/bin/python3.8 (ver 3.8.5) -- Libraries: /usr/lib/x86_64-linux-gnu/libpython3.8.so -- numpy: /usr/local/lib/python3.8/dist-packages/numpy/core/include (ver 1.20.3) -- packages path: /usr/lib/python3/dist-packages -- -- Python (for build): /usr/bin/python3.8 -- -- Java: -- ant: NO -- JNI: NO -- Java wrappers: NO -- Java tests: NO
-
5. Troubleshooting:
a. CL/cl.h: No such file or directory
$ apt-get install opencl-headers ref: Here
a. $ sudo apt install --reinstall linux-libc-dev
b. $ sudo apt-get install v4l-utils
$ cd /usr/include/linux
$ sudo ln -s -f ../libv4l1-videodev.h videodev.h
$ /usr/local/lib/pkgconfig
a. opencv.pc (for opencv3.4.2)
b. opencv4.pc (for openc4.x, make a softlink)
opencv.pc -> opencv4.pc
error: #error "OpenCV 4.x+ requires enabled C++11 support"
$ vim Makefile
...
...
...
CPP=g++ -std=c++11
$ /usr/local/lib/pkgconfig
a. opencv.pc (for opencv3.4.2)
b. opencv4.pc (for openc4.x, make a softlink)
opencv.pc -> opencv4.pc
CMakeError.log
Determining if the include file io.h exists failed with the following output:
2 Change Dir: /home/ubuntu/object_recognition/opencv/opencv/build_android/CMakeFiles/CMakeTmp
...
...
...
/home/ubuntu/object_recognition/opencv/opencv/build_android/CMakeFiles/CMakeTmp/CheckIncludeFile.c:1:10: fatal error: 'io.h' file not found
注意cmake要求的版本
(in build directory) a. $ rm -r CMakeCache.txt; b. $ Cmake -D ...... (as above) c. make -j27. cv2.so
$ sudo cp /usr/lib/python3/dist-packages/cv2/python-3.8/cv2.cpython-38-x86_64-linux-gnu.so /usr/local/python/cv2/python-3.8/cv2.so $ sudo ldconfig
$ python3 -c "import cv2; print(cv2.__version__)"
3.4.4
- Darknet
1. Follow this website to install the necessary packages
2. Compile with OpenCV (exclude CUDA)$ git clone https://github.com/pjreddie/darknet.git $ vim Makefile $ OPENCV=1 $ make ref: 1. Installing Darknet 2. 手把手教你用AlexeyAB版Darknet
$ wget https://pjreddie.com/media/files/yolov3.weights $ ./darknet detect cfg/yolov3.cfg yolov3.weights data/dog.jpg
沒有留言:
張貼留言