Correctly linking local OpenCV library in ROS as TesseractOCR is not found in ROS OpenCV library

asked 2018-08-03 15:33:41 -0600

Ivan the student gravatar image

I'm doing an OpenCV project to identify signs for hazardous substances. I also have to be able identify the UN numbers, for that I'm using TesseractOCR. My problem is that when working in gedit without ROS Tesseract works fine, but in ROS (kinetic) after I launch the program and run it (no compilation errors) i get the following error in the command line:

OCRTesseract(00): Tesseract not found.

Strangely enough all the other OpenCV functions are found and work. As TesseractOCR is in the ocr.hpp, it should find Tesseract once the local OpenCV library is linked correctly, which it isn't.

I have already read this answer and also tried to link to the local OpenCV library (/usr/local/include/opencv2) as explained in the answer. I changed CMakeLists.txt and also CMakeCache.txt. This is my CMakeLists.txt:

cmake_minimum_required(VERSION 2.8.3)
project(ELROB_2018)
find_package(catkin REQUIRED COMPONENTS
  cv_bridge
  image_transport
  roscpp
  sensor_msgs
  std_msgs
)

find_package(OpenCV REQUIRED
   NO_MODULE #Should be optional, tells CMake to use config mode
   PATHS /usr/local # Tells CMake to look here
   NO_DEFAULT_PATH #and don't look anywhere else
)
find_package( PkgConfig REQUIRED)
catkin_package(CATKIN_DEPENDS sensor_msgs
               DEPENDS OpenCV
               INCLUDE_DIRS include
               LIBRARIES ${PROJECT_NAME}
)

include_directories(
# include
  ${catkin_INCLUDE_DIRS}
  ${OpenCV_INCLUDE_DIRS}
#set(OpenCV_INCLUDE_DIRS /usr/local/include/opencv2)
#set(OpenCV_LIBS /usr/local/lib/libopencv_core.so)
  #${Tesseract_INCLUDE_DIRS}
)

add_executable(ELROB_2018_node src/main.cpp src/image_processing1.cpp src/checklist1.cpp src/checklist2.cpp) 
add_dependencies(ELROB_2018_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_link_libraries(ELROB_2018_node ${catkin_LIBRARIES} ${OpenCV_LIBRARIES})
#target_link_libraries( ELROB_2018_node ${OpenCV_LIBS} )
#target_link_libraries(ELROB_2018_node ${catkin_LIBRARIES} )
target_link_libraries(ELROB_2018_node lept tesseract)

I have tried changing CMakeCache.txt to /usr/local/include/opencv2, but it always changes back to this after catkin_make:

//The directory containing a CMake configuration file for OpenCV.
OpenCV_DIR:PATH=/opt/ros/kinetic/share/OpenCV-3.3.1

Now I'm not quite sure what to do next as Tesseract is still not found when when I roslaunch my node and run my program. As mentioned strangely enough all of the other OpenCV functions work.

edit retag flag offensive close merge delete