面对在Ubuntu 18.04上安装openCV 2.4.9的问题

时间:2019-02-21 09:14:08

标签: opencv ubuntu installation ubuntu-18.04

我正在尝试在Ubuntu 18.0上安装openCv 我已遵循此blog

的步骤

但是当我运行此命令时

  

制作

它会引发以下错误

[ 57%] Built target opencv_perf_ocl
[ 57%] Built target opencv_nonfree
[ 57%] Built target opencv_perf_nonfree
[ 58%] Built target opencv_test_nonfree
[ 58%] Building CXX object modules/contrib/CMakeFiles/opencv_contrib.dir/src/chamfermatching.cpp.o
/home/knoldus/opencv-2.4.9/modules/contrib/src/chamfermatching.cpp: In member function ‘void cv::ChamferMatcher::Matching::computeDistanceTransform(cv::Mat&, cv::Mat&, cv::Mat&, float, float, float)’:
/home/knoldus/opencv-2.4.9/modules/contrib/src/chamfermatching.cpp:969:30: error: the compiler can assume that the address of ‘annotate_img’ will never be NULL [-Werror=address]
             if (&annotate_img!=NULL) {
                              ^
/home/knoldus/opencv-2.4.9/modules/contrib/src/chamfermatching.cpp:1016:34: error: the compiler can assume that the address of ‘annotate_img’ will never be NULL [-Werror=address]
                 if (&annotate_img!=NULL) {
                                  ^
/home/knoldus/opencv-2.4.9/modules/contrib/src/chamfermatching.cpp: In member function ‘cv::ChamferMatcher::Match* cv::ChamferMatcher::Matching::localChamferDistance(cv::Point, cv::Mat&, cv::Mat&, cv::ChamferMatcher::Template*, float)’:
/home/knoldus/opencv-2.4.9/modules/contrib/src/chamfermatching.cpp:1111:25: error: the compiler can assume that the address of ‘orientation_img’ will never be NULL [-Werror=address]
     if (&orientation_img!=NULL) {
                         ^
/home/knoldus/opencv-2.4.9/modules/contrib/src/chamfermatching.cpp:1111:5: warning: nonnull argument ‘orientation_img’ compared to NULL [-Wnonnull-compare]
     if (&orientation_img!=NULL) {
     ^~
/home/knoldus/opencv-2.4.9/modules/contrib/src/chamfermatching.cpp: In member function ‘void cv::ChamferMatcher::Matching::computeDistanceTransform(cv::Mat&, cv::Mat&, cv::Mat&, float, float, float)’:
/home/knoldus/opencv-2.4.9/modules/contrib/src/chamfermatching.cpp:1016:17: warning: nonnull argument ‘annotate_img’ compared to NULL [-Wnonnull-compare]
                 if (&annotate_img!=NULL) {
                 ^~
/home/knoldus/opencv-2.4.9/modules/contrib/src/chamfermatching.cpp:969:13: warning: nonnull argument ‘annotate_img’ compared to NULL [-Wnonnull-compare]
             if (&annotate_img!=NULL) {
             ^~
cc1plus: some warnings being treated as errors
modules/contrib/CMakeFiles/opencv_contrib.dir/build.make:158: recipe for target 'modules/contrib/CMakeFiles/opencv_contrib.dir/src/chamfermatching.cpp.o' failed
make[2]: *** [modules/contrib/CMakeFiles/opencv_contrib.dir/src/chamfermatching.cpp.o] Error 1
CMakeFiles/Makefile2:2974: recipe for target 'modules/contrib/CMakeFiles/opencv_contrib.dir/all' failed
make[1]: *** [modules/contrib/CMakeFiles/opencv_contrib.dir/all] Error 2
Makefile:151: recipe for target 'all' failed
make: *** [all] Error 2

1 个答案:

答案 0 :(得分:1)

安装旧版本的opencv可能会导致很多问题,如本问题所述(请参见注释)。

  • 解决有关CXXCompiler的Cmake错误的解决方案可以是 找到了here
  • fatal error: stdlib.h: No such file or directory的解决方案可以 被发现here
  • 最新版《 问题可以在补丁here
  • 中找到