xdspacelab / openvslam

OpenVSLAM: A Versatile Visual SLAM Framework
https://openvslam.readthedocs.io/
2.97k stars 868 forks source link

Porting ORB_SLAM2_CUDA to openVSLAM #445

Open surfii3z opened 4 years ago

surfii3z commented 4 years ago

Hi all

I have been trying to make openVSLAM cuda enable following the work of yunchih and I have seen some discussion here #261.

I tried to put together the work of ORB_SLAM2 CUDA at my repro. It seems like the major change is only in orb_extractor.cc file.

However, when I ran the program, I got this error.

OpenCV Error: Gpu API call (an illegal memory access was encountered) in download, file /home/jedsadakorn/git/opencv-3.4.0/modules/core/src/cuda/gpu_mat.cu, line 260
terminate called after throwing an instance of 'cv::Exception'
  what():  /home/jedsadakorn/git/opencv-3.4.0/modules/core/src/cuda/gpu_mat.cu:260: error: (-217) an illegal memory access was encountered in function download

*** Aborted at 1600090278 (unix time) try "date -d @1600090278" if you are using GNU date ***
PC: @     0x7f06f039ef47 gsignal
*** SIGABRT (@0x3e8000035ec) received by PID 13804 (TID 0x7f0649fff700) from PID 13804; stack trace: ***
    @     0x7f06f35ea8a0 (unknown)
    @     0x7f06f039ef47 gsignal
    @     0x7f06f03a08b1 abort
    @     0x7f06f09f5957 (unknown)
    @     0x7f06f09fbae6 (unknown)
    @     0x7f06f09fbb21 std::terminate()
    @     0x7f06f09fbd54 __cxa_throw
    @     0x7f06f19c6742 cv::error()
    @     0x7f06f19c689f cv::error()
    @     0x7f06f1a47c99 cv::cuda::GpuMat::download()
    @     0x7f06f3a223aa openvslam::cuda::GpuOrb::join()
    @     0x7f06f391293c openvslam::feature::orb_extractor::extract()
    @     0x7f06f38ddb0a openvslam::data::frame::extract_orb()
    @     0x7f06f38e0397 openvslam::data::frame::frame()
    @     0x7f06f38af219 openvslam::tracking_module::track_monocular_image()
    @     0x7f06f38a1e3c openvslam::system::feed_monocular_frame()
    @     0x555c348fc455 _ZNSt6thread11_State_implINS_8_InvokerISt5tupleIJZ13mono_trackingRKSt10shared_ptrIN9openvslam6configEERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESG_SG_jbbbSG_EUlvE_EEEEE6_M_runEv
    @     0x7f06f0a266df (unknown)
    @     0x7f06f35df6db start_thread
    @     0x7f06f0481a3f clone
Aborted (core dumped)

which I believe arise from this line.

If anyone could help with the debug, I would really appreciate.


One thing that I know is if I comment line157 ~ 167.

The function gpuOrb.join() at line159 will ALWAYS be executed two times before the program terminate with the same error. gpuOrb.join(descriptors_at_level);

If I change line 153 from gpuOrb.launch_async(blurred_image, keypts_at_level.data(), keypts_at_level.size()); to gpuOrb.launch_async(blurred_image, keypts.data(), keypts.size()); The above error disappeared. However, it could not track the feature (which is expected).

My opinion is that it is probably something about keypts and keypts_at_level that behave differently from ORB_SLAM2 code (I used the exact same code (?)). If any of you would like me to try any idea to debug, please let me know.

TIA

greymfm commented 3 years ago

Your code looks correct to me. Some ideas for debugging: