opencv常见问题整理

1. 多版本opencv相关CmakeList.txt文件设置

set(OpenCV_DIR "/usr/local/opencv-3.4.1/share/OpenCV/")
find_package(OpenCV 3.4.1 REQUIRED)
include_directories( ${OpenCV_INCLUDE_DIRS} )

ADD_EXECUTABLE(Test main.cpp)
target_link_libraries( Test ${OpenCV_LIBS})

1.error: ‘CV_WINDOW_AUTOSIZE’ was not declared

解决方案:
opencv版本4.1.1
添加头文件

#include 

2.autoware.ai/src/autoware/common/object_map/include/object_map/object_map_utils.cpp:163: undefined reference to `cv::fillConvexPoly(cv::InputOutputArray const&, cv::Point const*, int, cv::Scalar_ const&, int, int)’

问题描述:

在这里插入代码片
```--- stderr: object_map                                                   
CMakeFiles/object_map_utils_lib.dir/include/object_map/object_map_utils.cpp.o: In function `object_map::FillPolygonAreas(grid_map::GridMap&, std::vector >, std::allocator > > >, std::allocator >, std::allocator > > > > > const&, std::__cxx11::basic_string, std::allocator > const&, int, int, int, int, std::__cxx11::basic_string, std::allocator > const&, std::__cxx11::basic_string, std::allocator > const&, tf::TransformListener const&)':
/home/zhangying/autoware.ai/src/autoware/common/object_map/include/object_map/object_map_utils.cpp:163: undefined reference to `cv::fillConvexPoly(cv::_InputOutputArray const&, cv::Point_ const*, int, cv::Scalar_ const&, int, int)'
collect2: error: ld returned 1 exit status
make[2]: *** [devel/lib/libobject_map_utils_lib.so] Error 1
make[1]: *** [CMakeFiles/object_map_utils_lib.dir/all] Error 2
make: *** [all] Error 2
---
Failed   <<< object_map	[ Exited with code 2 ]
Aborted  <<< kitti_player
Aborted  <<< imm_ukf_pda_track                                                          
Aborted  <<< sick_ldmrs_tools                                           

Summary: 37 packages finished [41.9s]
  1 package failed: object_map
  3 packages aborted: imm_ukf_pda_track kitti_player sick_ldmrs_tools
  1 package had stderr output: object_map
  98 packages not processed

解决方法:
ld(链接库问题)在CmakeList.txt里添加opencv的链接库

add_library(object_map_utils_lib
        include/object_map/object_map_utils.cpp
        include/object_map/object_map_utils.hpp
        )
target_link_libraries(object_map_utils_lib
        ${vector_map_LIBRARIES}
        ${catkin_LIBRARIES}
        ${OpenCV_LIBS}
        )

你可能感兴趣的:(opencv常见问题整理)