ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

opencv2/opencv.hpp no such file or directory [closed]

asked 2021-09-17 15:04:29 -0500

Flash gravatar image

updated 2021-09-20 10:00:44 -0500

Hi, I am on jetson using ROS melodic version. I am receiving no such file or directory for opencv2/opencv.hpp. I know I am not linking it properly but not sure how to fix it.

cmake_minimum_required(VERSION 2.8.3)
project(camera)

find_package(catkin REQUIRED COMPONENTS
  cv_bridge
  image_transport
  roscpp
  rospy
  sensor_msgs
  std_msgs
  message_generation
  message_runtime
)


generate_messages(
   DEPENDENCIES
   std_msgs
)

catkin_package(
   CATKIN_DEPENDS cv_bridge image_transport roscpp rospy sensor_msgs std_msgs message_generation
  message_runtime
)

include_directories( 
    ${catkin_INCLUDE_DIRS} 
    ${OpenCV_INCLUDE_DIRS} 

)

link_directories(
        /opt/ros/melodic/lib
)

set(CATKIN_LIBS cv_bridge.so image_transport.so message_filters.so class_loader.so dl.so roslib.so rospack.so python2.7.so             boost_program_options.so tinyxml2.so roscpp.so boost_filesystem.so rosconsole.so rosconsole_log4cxx.so rosconsole_backend_interface.so log4cxx.so boost_regex.so xmlrpcpp.so roscpp_serialization.so rostime.so cpp_common.so boost_system.so boost_thread.so boost_chrono.so boost_date_time.so boost_atomic.so pthread.so console_bridge.so)


find_package(OpenCV REQUIRED)
find_package(PkgConfig REQUIRED)
pkg_search_module(PKG_OPENCV REQUIRED opencv)

add_executable(capture src/camera_node.cpp )
add_dependencies(capture ${catkin_EXPORTED_TARGETS} ${${PROJECT_NAME}_EXPORTED_TARGETS})
target_link_libraries(capture ${CATKIN_LIBS} ${PKG_OPENCV_LDFLAGS} ${V4l2_LIBRARIES})

add_executable(detect src/person_detection_node.cpp )
add_dependencies(detect ${catkin_EXPORTED_TARGETS} ${${PROJECT_NAME}_EXPORTED_TARGETS})
target_link_libraries(detect ${CATKIN_LIBS} ${PKG_OPENCV_LDFLAGS} ${V4l2_LIBRARIES})

add_executable(sample_detection_sub src/sample_detection_sub.cpp )
add_dependencies(sample_detection_sub ${catkin_EXPORTED_TARGETS} ${${PROJECT_NAME}_EXPORTED_TARGETS})
target_link_libraries(sample_detection_sub ${CATKIN_LIBS}  ${PKG_OPENCV_LDFLAGS} ${V4l2_LIBRARIES})

Above is my Cmakelist.txt Below is my opencv Installation procedure

image description

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Flash
close date 2021-10-07 15:03:26.200080

Comments

Please show us the command you used to install the opencv development package.

Mike Scheutzow gravatar image Mike Scheutzow  ( 2021-09-17 16:15:47 -0500 )edit

Hi Mike, I had attached the image for OpenCV installation.

Flash gravatar image Flash  ( 2021-09-20 10:01:48 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-09-20 11:58:43 -0500

Flash gravatar image

Fixed problem by changing path in cv_bridgeConfig.cmake file on line 94 and line 96 form /usr/include/opencv or /usr/include/opencv4/opencv2 to /usr/include/opencv4 and then it worked. Not proper path was mentioned

edit flag offensive delete link more

Comments

Each release of ros is very specific about the version of opencv the binary packages use. For melodic, it wants v3.2.0. By installing a different version of opencv, you may discover down the road that you have created a conflict that will need to be resolved.

Mike Scheutzow gravatar image Mike Scheutzow  ( 2021-09-20 14:04:24 -0500 )edit

got it, I will see if I can go lower version for OpenCV thanks

Flash gravatar image Flash  ( 2021-09-20 14:13:37 -0500 )edit

For ubuntu 18, opencv is in the ubuntu package repository, so you don't have to build it from source. Have you tried installing ubuntu package libopencv-dev?

Mike Scheutzow gravatar image Mike Scheutzow  ( 2021-09-20 16:23:01 -0500 )edit

Actually, I am integrating with another SDK that needs OpenCV version 4.4.0 due to which I cannot go back or change my installation procedure.

Flash gravatar image Flash  ( 2021-09-21 08:25:19 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2021-09-17 15:04:29 -0500

Seen: 1,419 times

Last updated: Sep 20 '21