Ask Your Question
2

cv_bridge segmentation fault OpenCV 3.0

asked 2015-10-17 11:51:59 -0500

Mago Nick gravatar image

updated 2015-10-19 03:52:06 -0500

Hello everybody, I have compiled and installed from source OpenCV 3.0 and the project I had now throws a segmentation fault error. I tracked down the callback that causes it

void imageCallback(const sensor_msgs::ImageConstPtr &msg){
  cv_bridge::CvImagePtr cv_image;
  cv_image = cv_bridge::toCvCopy(msg, sensor_msgs::image_encodings::RGB8);
  (cv_image->image).copyTo(frame_);
}

It seems that cv_bridge has a problem with the new version of the library.

For this specific project I can use OpenCV 2.x without any problem, however for other projects (both ROS and non-ROS) I have to use OpenCV 3.0.

How can I solve the problem?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2015-10-18 05:07:44 -0500

gvdhoorn gravatar image

updated 2015-10-19 03:05:40 -0500

Is this with cv_bridge installed from ros-jade-cv-bridge and your from-source OpenCV? If so, that is most likely the issue: binary compatibility is only guaranteed when all packages that depend on OpenCV depend on the exact same version.


Edit:

Yes, this is the case. Is there any way I can edit my CMakeList.txt to force link with another OpenCV version?

There is (something like find_package(OpenCV 3.0 REQUIRED)), but I'm not sure that is what you want.

I can install the 2.x one along with the 3.0 Do you believe is a good idea?

If you installed any ROS Jade packages that depend on cv_bridge, you should already have an OpenCV 2 version installed. The issue is that you are probably linking your executable with cv_bridge, which pulls in OpenCV 2 dependencies, but also with OpenCV 3, which won't work.

If I remember correctly, @Vincent Rabaud has been working on OpenCV 3 ROS integration. He might be able to work out the best way to do this.

edit flag offensive delete link more

Comments

Yes, this is the case. Is there any way I can edit my CMakeList.txt to force link with another OpenCV version? I can install the 2.x one along with the 3.0 Do you believe is a good idea?

Mago Nick gravatar image Mago Nick  ( 2015-10-19 02:56:45 -0500 )edit

I see. What I meant was not to force link to OpenCV 3.0 but to the built in OpenCV of ros

Mago Nick gravatar image Mago Nick  ( 2015-10-19 03:24:04 -0500 )edit

Unfortunately downgrading OpenCV is not an option

and

What I meant was not to force link to OpenCV 3.0 but to the built in OpenCV of ros

This seems conflicting to me: if you can actually use OpenCV2, then there would be no issue, right?

gvdhoorn gravatar image gvdhoorn  ( 2015-10-19 03:29:58 -0500 )edit

No, there would not. I probably explained myself wrong. What I meant was that I could not unistall OpenCV 3.0. At the moment I do not know how to link to the built in version of ros. The OpenCV 3.0 are needed for another project. Therefore, is fine to me to use the older ones to compile this package

Mago Nick gravatar image Mago Nick  ( 2015-10-19 03:37:29 -0500 )edit

Ok, so could you please update your original question with some more details? If I understand you correctly, you have:

  1. ROS nodes that should just use OpenCV2
  2. an installation of OpenCV3 which you only need for non-ROS projects?
gvdhoorn gravatar image gvdhoorn  ( 2015-10-19 03:44:31 -0500 )edit

Not exactly. I have:

  1. A ROS project with independent ROS workspace that requires (apparently) OpenCV 2
  2. Other project bot ROS (that will have their own workspace) and non-ROS

hope this cleared out a bit

Mago Nick gravatar image Mago Nick  ( 2015-10-19 03:50:26 -0500 )edit

hope this cleared out a bit

Not really. I'm not sure how a binary ros-jade-cv-bridge could be linked at runtime against your from-source OpenCV 3, unless you are also doing find_package(OpenCV) in your CMakeLists.txt, and that is pulling in CV3 libs.

gvdhoorn gravatar image gvdhoorn  ( 2015-10-19 04:12:38 -0500 )edit

Ok. I am actually doing as you are suggesting, but this implies that the software links to the new version of OpenCV. How should I do to link it to the old version?

Mago Nick gravatar image Mago Nick  ( 2015-10-19 04:31:58 -0500 )edit

Your Answer

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

Add Answer

Question Tools

2 followers

Stats

Asked: 2015-10-17 11:51:59 -0500

Seen: 2,611 times

Last updated: Oct 19 '15