0
$\begingroup$

Rosanswers logo

Hello,

I developed a ball detection algorithm first outside ROS, using the opencv library I installed on my system (Ubuntu 10.4, opencv 2.3). I installed it as a shared object and I can use it without any problem outside ROS. As I included it into a ROS node, I could actually compile it, but it gave me some warnings:

Scanning dependencies of target BlobDetector
make[3]: Leaving directory `/home/ferraraf/Wazowski/mWazowski/ball_detection/build'                                                                                                                                                                
make[3]: Entering directory `/home/ferraraf/Wazowski/mWazowski/ball_detection/build'
[ 20%] Building CXX object CMakeFiles/BlobDetector.dir/src/BlobDetector.o
/home/ferraraf/Wazowski/mWazowski/ball_detection/src/BlobDetector.cpp: In member function ‘void BlobDetector::detectionCallback(const sensor_msgs::ImageConstPtr&)’:                                                                               
/home/ferraraf/Wazowski/mWazowski/ball_detection/src/BlobDetector.cpp:182: warning: unused variable ‘r’
/home/ferraraf/Wazowski/mWazowski/ball_detection/src/BlobDetector.cpp:194: warning: ‘y_c’ may be used uninitialized in this function
/home/ferraraf/Wazowski/mWazowski/ball_detection/src/BlobDetector.cpp:208: warning: ‘x_c’ may be used uninitialized in this function
Linking CXX executable ../bin/BlobDetector
/usr/bin/ld: warning: libopencv_core.so.2.3, needed by /usr/local/share/opencv/../../lib/libblob_detection.so, may conflict with libopencv_core.so.2.2                                                                                             
/usr/bin/ld: warning: libopencv_imgproc.so.2.3, needed by /usr/local/share/opencv/../../lib/libblob_detection.so, may conflict with libopencv_imgproc.so.2.2
/usr/bin/ld: warning: libopencv_features2d.so.2.3, needed by /usr/local/share/opencv/../../lib/libblob_detection.so, may conflict with libopencv_features2d.so.2.2
/usr/bin/ld: warning: libopencv_calib3d.so.2.3, needed by /usr/local/share/opencv/../../lib/libblob_detection.so, may conflict with libopencv_calib3d.so.2.2
/usr/bin/ld: warning: libopencv_objdetect.so.2.3, needed by /usr/local/share/opencv/../../lib/libblob_detection.so, may conflict with libopencv_objdetect.so.2.2
/usr/bin/ld: warning: libopencv_video.so.2.3, needed by /usr/local/share/opencv/../../lib/libblob_detection.so, may conflict with libopencv_video.so.2.2
/usr/bin/ld: warning: libopencv_highgui.so.2.3, needed by /usr/local/share/opencv/../../lib/libblob_detection.so, may conflict with libopencv_highgui.so.2.2
/usr/bin/ld: warning: libopencv_ml.so.2.3, needed by /usr/local/share/opencv/../../lib/libblob_detection.so, may conflict with libopencv_ml.so.2.2
/usr/bin/ld: warning: libopencv_legacy.so.2.3, needed by /usr/local/share/opencv/../../lib/libblob_detection.so, may conflict with libopencv_legacy.so.2.2
/usr/bin/ld: warning: libopencv_contrib.so.2.3, needed by /usr/local/share/opencv/../../lib/libblob_detection.so, may conflict with libopencv_contrib.so.2.2
make[3]: Leaving directory `/home/ferraraf/Wazowski/mWazowski/ball_detection/build'
[ 20%] Built target BlobDetector

(The rest is not important, it is other nodes which are successfully compiled and run.)

When I run the ROS node, there is a segmentation fault before the program enters the main function. I ran the node using gdb and it gives me the following output when I do a backtrace:

Starting program: /home/ferraraf/Wazowski/mWazowski/ball_detection/bin/BlobDetector __name:=BlobDetector __log:=/home/ferraraf/.ros/log/5dbf29ea-2b2a-11e1-b4e2-001b21b8241e/BlobDetector-1.log
[Thread debugging using libthread_db enabled]

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff2cb158a in std::_Rb_tree_decrement(std::_Rb_tree_node_base*) ()
from /usr/lib/libstdc++.so.6
(gdb) backtrace
#0  0x00007ffff2cb158a in std::_Rb_tree_decrement(std::_Rb_tree_node_base*) ()
from /usr/lib/libstdc++.so.6
#1  0x00007fffeea2e70e in std::_Rb_tree_iterator<std::pair<cvflann::flann_algorithm_t const, cvflann::IndexParams* (*)()> >::operator-- (this=0x7fffeec30180, 
__v=...) at /usr/include/c++/4.4/bits/stl_tree.h:199
#2  std::_Rb_tree<cvflann::flann_algorithm_t, std::pair<cvflann::flann_algorithm_t const, cvflann::IndexParams* (*)()>, std::_Select1st<std::pair<cvflann::flann_algorithm_t const, cvflann::IndexParams* (*)()> >, std::less<cvflann::flann_algorithm_t>, std::allocator<std::pair<cvflann::flann_algorithm_t const, cvflann::IndexParams* (*)()> > >::_M_insert_unique (this=0x7fffeec30180, __v=...)
at /usr/include/c++/4.4/bits/stl_tree.h:1179
#3  0x00007fffeea2e88b in std::_Rb_tree<cvflann::flann_algorithm_t, std::pair<cvflann::flann_algorithm_t const, cvflann::IndexParams* (*)()>, std::_Select1st<std::pair<cvflann::flann_algorithm_t const, cvflann::IndexParams* (*)()> >, std::less<cvflann::flann_algorithm_t>, std::allocator<std::pair<cvflann::flann_algorithm_t const, cvflann::IndexParams* (*)()> > >::_M_insert_unique_ (
this=0x7fffeec30180, __position=..., __v=...)
at /usr/include/c++/4.4/bits/stl_tree.h:1254
#4  0x00007fffeea2e9b1 in std::map<cvflann::flann_algorithm_t, cvflann::IndexParams* (*)(), std::less<cvflann::flann_algorithm_t>, std::allocator<std::pair<cvflann::flann_algorithm_t const, cvflann::IndexParams* (*)()> > >::insert (
this=0x7fffeec30188, __k=<value optimized out>)
at /usr/include/c++/4.4/bits/stl_map.h:540
---Type <return> to continue, or q <return> to quit---
#5  std::map<cvflann::flann_algorithm_t, cvflann::IndexParams* (*)(), std::less<cvflann::flann_algorithm_t>, std::allocator<std::pair<cvflann::flann_algorithm_t const, cvflann::IndexParams* (*)()> > >::operator[] (this=0x7fffeec30188, 
__k=<value optimized out>) at /usr/include/c++/4.4/bits/stl_map.h:450                                                                                   
#6  0x00007fffeb480a1d in global constructors keyed to flann.cpp ()
from /usr/local/share/opencv/../../lib/libopencv_flann.so.2.3
#7  0x00007fffeb480ad6 in __do_global_ctors_aux ()
from /usr/local/share/opencv/../../lib/libopencv_flann.so.2.3
#8  0x00007fffeb47f17b in _init ()
from /usr/local/share/opencv/../../lib/libopencv_flann.so.2.3
#9  0x00007ffff7fc2988 in ?? ()
#10 0x00007ffff7debd25 in call_init (main_map=0x7ffff7ffe128, argc=-345499104, 
argv=0x7fffffffdbe8, env=0x7fffffffdc08) at dl-init.c:70
#11 _dl_init (main_map=0x7ffff7ffe128, argc=-345499104, argv=0x7fffffffdbe8, 
env=0x7fffffffdc08) at dl-init.c:134
#12 0x00007ffff7dddb2a in _dl_start_user () from /lib64/ld-linux-x86-64.so.2
#13 0x0000000000000003 in ?? ()
#14 0x00007fffffffdf3b in ?? ()
#15 0x00007fffffffdf7d in ?? ()
#16 0x00007fffffffdf92 in ?? ()
#17 0x0000000000000000 in ?? ()

Now, I don't know exactly what is going on here, but since the problem occurs after something is done with libopencv_flann.so.2.3, I assume there is an actual conflict between the opencv library installed on the system and the opencv library that is used by ROS.

Do you have any clue about what happens and how I could solve it?

Best,

Francesco


Originally posted by frferrara on ROS Answers with karma: 13 on 2011-12-20

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Why don't you just re-compile it in the ROS package you are developing? There are differences between OpenCV 2.2 and 2.3 so you are probably having some binary incompatibility issue. I also see references to flann to, so maybe there is an issue with your setup of OpenCV 2.3/flann and ROS's 2.2/flann.

I think the simplest answer is just re-compile using ROS libraries.


Originally posted by Kevin with karma: 2962 on 2011-12-29

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by frferrara on 2012-01-12:
This worked! Thanks a lot!!

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.