1, first install the opencv-3.20 under Linux, want to see a blog.
2, OpenCV installed, in the Ros under the compiler to use OPENCV library function files, always appear below the error, or similar, is Ros find OpenCV library function, the solution is that we can add ourselves.
CMAKEFILES/BUTTON.DIR/SRC/BUTTON.CPP.O: In function ' main ':/home/liuqiqi/dev/dobot_ws/src/opencv_image/src/button.cpp : 75: References not defined for ' cv::imshow (cv::string const& Cv::_inputarray const&) '/home/liuqiqi/dev/dobot_ws/src/opencv_ Image/src/button.cpp:77: References not defined for ' cv::waitkey (int) ' CMAKEFILES/CREATE_TEMPLATE.DIR/SRC/CREATE_TEMPLATE.CPP.O: in function ' Main ':/home/liuqiqi/dev/dobot_ws/src/opencv_image/src/create_template.cpp:103: To ' Cv::namedwindow ' (cv::String Const&, int) ' Undefined reference/home/liuqiqi/dev/dobot_ws/src/opencv_image/src/create_template.cpp:105: To ' CV:: Setmousecallback (cv::string const&, Void (*) (int, int, int, int, void*), void*) ' undefined reference/home/liuqiqi/dev/dobot_ws/ src/opencv_image/src/create_template.cpp:111: To ' cv::imshow (cv::string const& Cv::_inputarray const&) ' Undefined reference/home/liuqiqi/dev/dobot_ws/src/opencv_image/src/create_template.cpp:112: Reference not defined for ' cv::waitkey (int) '/home/ liuqiqi/dev/dobot_ws/src/opencv_image/src/create_template.cpp:114: To ' CV::d Estroywindow (cv::String const&) ' Undefined reference/home/liuqiqi/dev/dobot_ws/src/opencv_image/src/create_template.cpp:117: To ' cv::imshow (cv::String const&, cv::_ Inputarray const&) ' undefined reference
3. Open the CMakeLists.txt file of the feature Pack and add the OpenCV library to the file:
Find_package (OpenCV REQUIRED)
Then add the OpenCV Library when you build the node
Target_link_libraries (xxxx ${catkin_libraries} ${opencv_libraries})
Recompile the file.