fixstars / libSGM

Stereo Semi Global Matching by cuda
Apache License 2.0
623 stars 189 forks source link

Tread safety and ROS compatibility #50

Closed lingjiankong closed 5 years ago

lingjiankong commented 5 years ago

I tried to run different StereoSGM instances in parallel in ROS, so each can compute disparity for different sizes of image pairs. However, it is giving me weird disparity values (shown below).

On the other hand, when I run a simple test in the sample, everything works just fine (see below). My images are just an empty filed with an object on the left.

It seems to me that it is not safe to initialize multiple instance of StereoSGM and run them in parallel. Is this the case? How can we have the library support ROS?

Any idea on why am I seeing below disparity in ROS? I've checked the data type for disparity (16SC1 normalized to 8UC1), version of OpenCV is the same (3.3.1 for ROS Kinetic). The images below was not even generated on ROS messages. They are actually exact duplication and the image pairs were simply being imread from file.

Update 08/29 I magically got ROS working. I don't remember what things I changed. I run the program overnight and it didn't crash at all, and the disparity quality is very good. I'll test again and see if the problem occurs again, or it could just be bugs in my code that I didn't catch...

Good disparity in sample test:

normal

Bad disparity in ROS:

ros