Robotics StackExchange | Archived questions

OpenCV error 'CAIRO_STATUS_SUCCESS failed' under ROS. Bug?

Dear fellow ROS developers,

I have encountered an OpenCV related bug that causes a crash when run in the context of ROS bindings.

My setup:

My self written catkin-based ROS node has the following dependencies specified in its CMakeLists.txt:

find_package(catkin REQUIRED COMPONENTS cv_bridge ...)
find_package(OpenCV REQUIRED)
...
include_directories(include
  ${catkin_INCLUDE_DIRS}
  ${OpenCV_INCLUDE_DIRS}
)

Through debugging I figured out which call actually causes the crash. Somewhere in my code I call:

cvFindContours(...)

the resulting error message is:

opencv_ros_node: /build/buildd/cairo-1.10.2/src/cairo-surface.c:1287: cairo_surface_set_device_offset: Assertion `status == CAIRO_STATUS_SUCCESS' failed.

The same code works if it is compiled stand alone, without any ROS bindings/includes, using a self-compiled version of OpenCV. However, if I link the stand alone build against the OpenCV installation that come with ROS, I get the same error.

I have spent many hours trying to resolve this issue, but no luck so far. Here is a link where someone else encounters the same error:

http://answers.opencv.org/question/14394/findcontours-error-with-cairo/

I also tried what is described in here http://answers.ros.org/question/61923/how-to-use-newer-versions-of-opencv-in-fuerte/ and here http://answers.ros.org/question/47249/problem-with-using-opencv_gpu-inside-ros/ without luck.

Any help would be appreciated.

Regards,

Heiko

Asked by Huibuh on 2013-08-22 03:31:22 UTC

Comments

Hi I believe I have the same issue, although I haven't tested it stand alone with OpenCV and not ROS.

I tried removing any calls to cv::waitKey and cv::imshow from my code and this at least superficially resolved the issue. I assume it is a concurrency issue of some sort.

Asked by NickT on 2013-09-02 23:55:11 UTC

Hello Nick, I will try the same on Monday and post back whether it also resolved my issue. Thanks for the tip!

Asked by Huibuh on 2013-09-15 00:14:19 UTC

Hm, when I do this (remove waitkey) no windows show up. (Since waitkey calls imshow, this may make sense). But I can't tell if FindContours is working, then.

Asked by KevinNickels on 2013-09-30 09:12:10 UTC

Hello Kevin, Im my case, uncommenting cv::waitKey and cv::imshow did not do the trick - same crash, same error message.

However, I am convinced now that this, at least in my case with ROS running at the same time, must be a concurrency issue. I tried to debug using gdb and other tools, but to no avail. This also explains while my code runs fine stand-alone, i,e, without being executed as part of a ROS node.

If anyone can give me any hints on how I could get to the bottom of this and come up with a fix, that would be highly appreciated!

Asked by Huibuh on 2013-09-30 22:06:31 UTC

Answers