Ask Your Question
0

opencv with ros kinetic

asked 2017-03-13 05:00:45 -0500

bennypi gravatar image

Hello, I'm trying to use opencv with ros kinetic. I can run catkin build successfully, but when the method cv::imwrite("image", cv_ptr->image, compression_params); is called, my node dies.

The console shows the following output:

OpenCV Error: Unspecified error (could not find a writer for the specified extension) in imwrite_, file /tmp/binarydeb/ros-kinetic-opencv3-3.2.0/modules/imgcodecs/src/loadsave.cpp, line 531
terminate called after throwing an instance of 'cv::Exception'
what():  /tmp/binarydeb/ros-kinetic-opencv3-3.2.0/modules/imgcodecs/src/loadsave.cpp:531: error: (-2) could not find a writer for the specified extension in function imwrite_

[caltab_detector_node-2] process has died [pid 30212, exit code -6, cmd /home/benny/xenial_ws/devel/lib/caltab_detector/caltab_detector_node caltab_detector_node/image_in:=/webcam/image_raw __name:=caltab_detector_node __log:=/home/benny/.ros/log/2ef1c64e-07d0-11e7-8d74-5c514fc42bc4/caltab_detector_node-2.log].
log file: /home/benny/.ros/log/2ef1c64e-07d0-11e7-8d74-5c514fc42bc4/caltab_detector_node-2*.log

In my C++ node I'm including <opencv2/opencv.hpp>. Is this the correct include for ros kinetic?

My package.xml:

<depend>roscpp</depend>
<depend>cv_bridge</depend>
<depend>sensor_msgs</depend>

My CMakeLists.xml:

cmake_minimum_required(VERSION 2.8.3)
project(caltab_detector)

## Make sure HALCONROOT is set
if(NOT DEFINED ENV{HALCONROOT})
  message( FATAL_ERROR "PLEASE SET HALCONROOT" )
endif()

add_definitions(-std=c++11)

find_package(catkin REQUIRED COMPONENTS roscpp cv_bridge sensor_msgs)
find_package(OpenCV 3 REQUIRED)

catkin_package(
  INCLUDE_DIRS include $ENV{HALCONROOT}/include $ENV{HALCONROOT}/include/halconcpp
  CATKIN_DEPENDS roscpp cv_bridge sensor_msgs
)

include_directories(include $ENV{HALCONROOT}/include $ENV{HALCONROOT}/include/halconcpp  ${catkin_INCLUDE_DIRS} ${OpenCV_INCLUDE_DIRS})

link_directories($ENV{HALCONROOT}/lib/$ENV{HALCONARCH})

add_executable(${PROJECT_NAME}_node src/caltab_detector_node.cpp)

add_dependencies(${PROJECT_NAME}_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})

target_link_libraries(${PROJECT_NAME}_node
   halconcpp
   halcon
   X11
   ${catkin_LIBRARIES}
   ${OpenCV_LIBRARIES}
)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2017-03-13 23:46:37 -0500

Wolf gravatar image

As The exception says: no writer For File Type. Acutally no File type in your case. Make "image" an e.g. "image.png" to tell opencv to save the File in png format

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2017-03-13 05:00:45 -0500

Seen: 934 times

Last updated: Mar 13 '17