ubuntu20.04安装opencv 3.2.0 报错

安装记录

Error 1:

cmake时报错
CMake Error at cmake/OpenCVCompilerOptions.cmake:21 (else):
A duplicate ELSE command was found inside an IF block.

Fix:

修改opencv-3.2.0/cmake/OpenCVCompilerOptions.cmake文件
注释掉21和22行

      else()
        message(STATUS "Unable to compile program with enabled ccache, reverting...")
        set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${__OLD_RULE_LAUNCH_COMPILE}")
      endif()
    # else()
    #   message(STATUS "Looking for ccache - not found")
    endif()

Error 2:

fatal error: LAPACKE_H_PATH-NOTFOUND/lapacke.h: No such file or directory #include “LAPACKE_H_PATH-NOTFOUND/lapacke.h”

Fix:

来源:https://blog.csdn.net/Dead_Rabbit6_0/article/details/78044754
需要注意的是在后续的修改中如果修改了源代码,需要重新cmake,就要在make install之前做这个操作

安装sudo apt-get install liblapacke-dev checkinstall
并修改opencv-3.2.0/build/opencv_lapack.h文件

注释掉:
#include"LAPACKE_H_PATH-NOTFOUND/lapacke.h" 
添加:
#include"lapacke.h"

Error 3:

error: ‘CODEC_FLAG_GLOBAL_HEADER’ was not declared in this scope

Fix:

来源:https://www.cnblogs.com/rainbow70626/p/17649814.html
在opencv-3.2.0/modules/videoio/src/cap_ffmpeg_impl.hpp,顶端添加如下代码:

#define AV_CODEC_FLAG_GLOBAL_HEADER (1 << 22)
#define CODEC_FLAG_GLOBAL_HEADER AV_CODEC_FLAG_GLOBAL_HEADER
#define AVFMT_RAWPICTURE 0x0020

Error 4:

make[2]: *** [modules/python3/CMakeFiles/opencv_python3.dir/build.make:186: modules/python3/CMakeFiles/opencv_python3.dir/__/src2/cv2.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:3151: modules/python3/CMakeFiles/opencv_python3.dir/all] Error 2
make: *** [Makefile:163: all] Error 2

Fix:

来源:https://blog.csdn.net/qq_44357371/article/details/105966714
修改/opencv-3.2.0/modules/python/src2/cv2.cpp文件730行

修改
char* str = PyString_AsString(obj);
添加(char *)
char* str = (char *)PyString_AsString(obj);

你可能感兴趣的:(opencv,人工智能,计算机视觉)