Quantcast
Channel: ROS Answers: Open Source Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 348

OpenCV 3 runtime error "Invalid pointer to file storage" cv_bridge + third party library

$
0
0
I'm trying to publish the image of a [picozense camera](https://www.pico-interactive.com/zense) in a ROS node in **ROS kinetic, Ubuntu 16.04**. I build a catkin package and included the camera's API (.h and .so files) which is OpenCV3 compatible. This works fine, i can call the API functions in the c++ source code. However, OpenCV crashes at runtime with an error that after some research most posts argue is a conflict between OpenCV2 and OpenCV3. But my installed **OpenCV version is 3.3.1** and i don't have any OpenCV 2.x installed. (Also i'm using cv_bridge which [depends on OpenCV3](https://github.com/ros-perception/vision_opencv/blob/kinetic/cv_bridge/CMakeLists.txt) components) The only OpenCV package i added to my dependencies and in my code is the *highgui* package. If i leave it out, the node does not crash at all. But even with the highgui package the node runs successfully sometimes. How can i fix the error? **OpenCV Runtime Error** rosusr@ubuntu:~/catkin_ws$ rosrun picozense publisher 1 OpenCV Error: Bad argument (Invalid pointer to file storage) in cvGetFileNodeByName, file /tmp/binarydeb/ros-kinetic-opencv3-3.3.1/modules/core/src/persistence.cpp, line 861 terminate called after throwing an instance of 'cv::Exception' what(): /tmp/binarydeb/ros-kinetic-opencv3-3.3.1/modules/core/src/persistence.cpp:861: error: (-5) Invalid pointer to file storage in function cvGetFileNodeByName Aborted (core dumped) **Running the node works sometimes** (the initialization just fails because the camera is not connected) rosusr@ubuntu:~/catkin_ws$ rosrun picozense publisher 1 2 PsInitialize status: -1 Initialize failed! Shutdown status: 0 **publisher.cpp** #include #include #include #include "PicoZense_api.h" int main(int argc, char** argv){ ros::init(argc, argv, "publisher"); ros::NodeHandle nh; PsReturnStatus status; std::cout << "1" << std::endl; status = PsInitialize(); std::cout << "2" << std::endl; std::cout << "PsInitialize status: " << status << std::endl; if (status != PsReturnStatus::PsRetOK){ std::cout << "Initialize failed!" << std::endl; status = PsShutdown(); std::cout << "Shutdown status: " << status << std::endl; return -1; } // ... // using opencv highgui etc. here // return 0; } **CMakeLists.txt** cmake_minimum_required(VERSION 2.8.3) project(picozense) add_compile_options(-std=c++11) find_package(catkin REQUIRED COMPONENTS cv_bridge image_transport sensor_msgs message_generation ) find_package(OpenCV 3 REQUIRED COMPONENTS highgui) generate_messages( DEPENDENCIES sensor_msgs ) catkin_package( CATKIN_DEPENDS cv_bridge image_transport sensor_msgs message_runtime ) include_directories( include ${catkin_INCLUDE_DIRS} #picoZense API header file is here (/picozense/include/) ${OpenCV_INCLUDE_DIRS} ) message(STATUS "catkin_include_dirs: " ${catkin_INCLUDE_DIRS}) message(STATUS "opencv_include_dirs: " ${OpenCV_INCLUDE_DIRS}) add_executable(publisher src/publisher.cpp) add_dependencies(publisher ${catkin_EXPORTED_TARGETS} ${${PROJECT_NAME}_EXPORTED_TARGETS}) target_link_libraries(publisher ${catkin_LIBRARIES} ${OpenCV_LIBRARIES} ${PROJECT_SOURCE_DIR}/lib/x64/libpicozense_api.so) message(STATUS "opencv_libraries: " ${OpenCV_LIBRARIES}) **package.xml** picozense0.0.0The picozense packagerosusrTODOcatkincv_bridgeimage_transportsensor_msgsmessage_generationcv_bridgeimage_transportsensor_msgsmessage_generationcv_bridgeimage_transportsensor_msgsmessage_runtime **ldd libpicozense_api.so** linux-vdso.so.1 => (0x00007ffc19ea8000) libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007ff34274c000) libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007ff3423ca000) libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007ff3420c1000) libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007ff341eaa000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007ff341ae0000) /lib64/ld-linux-x86-64.so.2 (0x000055f87df4e000) I've already searched and tried a lot but any help is very much appreciated!

Viewing all articles
Browse latest Browse all 348

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>