chamfermatching.cpp:969:30: error: the compiler can assume that the address of ‘annotate_img’

我编译的版本是opencv2.4.9
解决办法
找到opencv-2.4.9/build/modules/contrib/CMakeFiles/opencv_contrib.dir/flags.make文件,删掉-Werror=address,然后重新

make

就行了
参考文章:g++ 6.3编译opencv-2.48报错记录
修改后flags.make文件的内容

# CMAKE generated file: DO NOT EDIT!
# Generated by "Unix Makefiles" Generator, CMake Version 3.7

# compile CXX with /usr/bin/c++
CXX_FLAGS =    -fsigned-char -W -Wall -Werror=return-type  -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -msse3 -ffunction-sections -O3 -DNDEBUG  -DNDEBUG -fPIC  

CXX_DEFINES = -DCVAPI_EXPORTS

CXX_INCLUDES = -I/home/pikachu/dev/opencv-2.4.9/modules/contrib/test -I/home/pikachu/dev/opencv-2.4.9/modules/features2d/include -I/home/pikachu/dev/opencv-2.4.9/modules/highgui/include -I/home/pikachu/dev/opencv-2.4.9/modules/imgproc/include -I/home/pikachu/dev/opencv-2.4.9/modules/flann/include -I/home/pikachu/dev/opencv-2.4.9/modules/core/include -I/home/pikachu/dev/opencv-2.4.9/modules/ts/include -I/home/pikachu/dev/opencv-2.4.9/modules/contrib/include -I/home/pikachu/dev/opencv-2.4.9/modules/nonfree/include -I/home/pikachu/dev/opencv-2.4.9/modules/ocl/include -I/home/pikachu/dev/opencv-2.4.9/modules/gpu/include -I/home/pikachu/dev/opencv-2.4.9/modules/photo/include -I/home/pikachu/dev/opencv-2.4.9/modules/objdetect/include -I/home/pikachu/dev/opencv-2.4.9/modules/legacy/include -I/home/pikachu/dev/opencv-2.4.9/modules/video/include -I/home/pikachu/dev/opencv-2.4.9/modules/ml/include -I/home/pikachu/dev/opencv-2.4.9/modules/calib3d/include -I/home/pikachu/dev/opencv-2.4.9/build/modules/contrib -I/home/pikachu/dev/opencv-2.4.9/modules/contrib/src -I/home/pikachu/dev/opencv-2.4.9/build 

详细报错信息

/home/pikachu/dev/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/pikachu/dev/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/pikachu/dev/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/pikachu/dev/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/pikachu/dev/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/pikachu/dev/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/pikachu/dev/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/pikachu/dev/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/pikachu/dev/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:3195: recipe for target 'modules/contrib/CMakeFiles/opencv_contrib.dir/all' failed
make[1]: *** [modules/contrib/CMakeFiles/opencv_contrib.dir/all] Error 2
Makefile:149: recipe for target 'all' failed
make: *** [all] Error 2

你可能感兴趣的:(chamfermatching.cpp:969:30: error: the compiler can assume that the address of ‘annotate_img’)