Tianhe new generation, install OpenCV

1) Download

Releases · opencv/opencv · GitHub

Download a version and upload it.

Decompression, because only the most basic functions are required, so there is no need for packages such as ctri.

2)

some options

cmake .. -D<选项名1>=<设定值1> -D<选项名2>=<设定值2>

The ".." in this command indicates that the path where the CMakeLists.txt file is located is in the upper-level directory of the build. When CMake executes the build, it will generate many auxiliary files (mainly Makefile). In order not to let these files mess up the root directory of the project, a "build" subdirectory is usually created in the project directory, and the cmake command is executed in this subdirectory. , all auxiliary files will be stored here.

After the command (all before "..") is the setting of all generation options. Here are some of the most commonly used options organized and explained:

  • CMAKE_BUILD_TYPE=Release: Do not include debugging information in the generated library file, and perform speed optimization. If you specify Debug, you can enter the code inside OpenCV during the Debug process, but the running speed will decrease slightly.
  • CMAKE_VERBOSE_MAKEFILE=ON: Be sure to turn it on , so as to find problems in compilation.
  • CMAKE_INSTALL_PREFIX=/usr/local: Specify the installation path of the library files generated by OpenCV in the system.
  • BUILD_SHARED_LIBS=ON: into a shared library (.so), if set to OFF, only a static library (.a) will be generated
  • OPENCV_EXTRA_MODULES_PATH=<opencv-contrib directory>, according to the previous description, it should be "../../opencv_contrib-4.3.1". You can use the ls command to confirm whether the relative path exists.
  • OPENCV_ENABLE_NONFREE=ON: If it is set to OFF, some functions containing patent protection algorithms will not be generated.
  • ENABLE_CXX11=ON: Support C++11 and above syntax and STL library.
  • BUILD_TESTS=OFF, BUILD_PERF_TESTS=OFF: Turn off the generated self-TEST, which is unnecessary in most cases and can greatly shorten the generation time. But if you suspect a problem with the generated OpenCV library, you can test yourself.
  • OPENCV_GENERATE_PKGCONFIG=ON: It is recommended to enable it, so that C++ programs can refer to the OpenCV library through pkg-config.
  • WITH_CUDA=ON, ENABLE_FAST_MATH=ON, CUDA_FAST_MATH=ON, WITH_CUBLAS=ON: If the system has CUDA installed correctly and you want OpenCV to enable CUDA support, all four options should be turned on.
  • WITH_IPP=ON, WITH_TBB=ON, WITH_OPENMP=ON, WITH_PTHREADS_PF=ON: These four options control how OpenCV performs concurrent operations. The default is ON, but if you need to generate an OpenCV that is absolutely single-threaded, please set these options are set to OFF.

3)CMAKE_INSTALL_PREFIX=XXX

Remember to set the current directory, because there is no root permission

cmake .. -D<选项名1>=<设定值1> -D<选项名2>=<设定值2>

4)

mkdir build install

cmake .. -D CMAKE_INSTALL_PREFIX=../install

make j20

ls get 

bin  include  lib  share
 

5)

 ./opencv_version
4.7.0

easy to install
 

It can be seen that the ecological environment of the new generation of supercomputers in Tianjin is still relatively complete

6)

Error: ModuleNotFoundError: No module named 'cv2'
Refer to this, I don't know if it will work, or it must be installed

opencv-python?

No internet is really troublesome

cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=install/opencv3.4.3 \
-D OPENCV_EXTRA_MODULES_PATH=/home/facri/Documents/OpenCV/OpenCV3.4.3_Source/opencv_contrib-3.4.3/modules \
-D ENABLE_NEON=ON \
-D ENABLE_VFPV3=ON \
-D WITH_OPENMP=ON \
-D WITH_OPENCL=OFF \
-D BUILD_ZLIB=ON \
-D BUILD_JAVA=OFF \
-D BUILD_TIFF=ON \
-D WITH_FFMPEG=ON \
-D WITH_TBB=ON \
-D BUILD_TBB=ON \
-D BUILD_TESTS=OFF \
-D WITH_EIGEN=ON \
-D WITH_GSTREAMER=ON \
-D WITH_V4L=ON \
-D WITH_LIBV4L=ON \
-D WITH_VTK=OFF \
-D WITH_QT=OFF \
-D OPENCV_ENABLE_NONFREE=ON \
-D INSTALL_C_EXAMPLES=OFF \
-D INSTALL_PYTHON_EXAMPLES=OFF \
-D BUILD_opencv_python3=TRUE \
-D PYTHON3_EXECUTABLE=/home/facri/SoftWare/miniconda3/envs/py37/bin/python3 \
-D PYTHON3_NUMPY_INCLUDE_DIRS=/home/facri/SoftWare/miniconda3/envs/py37/lib/python3.7/site-packages/numpy/core/include \
-D PYTHON3_INCLUDE=/home/facri/SoftWare/miniconda3/envs/py37/include \
-D PYTHON3_LIBRARIES=/home/facri/SoftWare/miniconda3/envs/py37/lib/libpython3.so \
-D PYTHON3_PACKAGES_PATH=lib/python3.7/site-packages \
-D OPENCV_GENERATE_PKGCONFIG=ON \
-D BUILD_EXAMPLES=OFF ..
 

Guess you like

Origin blog.csdn.net/anlongstar/article/details/130414804