cvg / limap

A toolbox for mapping and localization with line features.
BSD 3-Clause "New" or "Revised" License
691 stars 68 forks source link

Minimal example on line detection, description and matching #40

Closed adricostas closed 1 year ago

adricostas commented 1 year ago

Hello,

First of all, thank you for sharing this amazing work. I was trying to create a very simple example based on this tutorial http://b1ueber2y.me/projects/LIMAP/docs/tutorials/line2d.html to detect, describe and match lines. I have solved some errors taking a look at the code in line_triagulation.py and functions.py but it is still not working. It ends up with an Aborted error.

Here is the code:

import limap.util.config
import limap.base
import limap.line2d

cfg = limap.util.config.load_config("/data/libraries/limap/cfgs/triangulation/default.yaml") # example config file
view1 = limap.base.CameraView(limap.base.Camera("PINHOLE", 0), "/data/libraries/limap/data/ai_001_001/images/scene_cam_00_final_preview/frame.0000.color.jpg") # initiate an limap.base.CameraView instance for detection. You can specify the height and width to resize into in the limap.base.Camera instance at initialization.
view2 = limap.base.CameraView(limap.base.Camera("PINHOLE", 1), "/data/libraries/limap/data/ai_001_001/images/scene_cam_00_final_preview/frame.0001.color.jpg") 
detector = limap.line2d.get_detector(cfg["line2d"]["detector"]) # get a line detector
segs1 = detector.detect(view1) # detection
desc1 = detector.extract(view1, segs1) # description
segs2 = detector.detect(view2) # detection
desc2 = detector.extract(view2, segs1) # description

extractor = limap.line2d.get_detector(cfg) # get a line extractor
matcher = limap.line2d.get_matcher(cfg["line2d"]["matcher"], extractor) # initiate a line matcher
matches = matcher.match_pair(desc1, desc2) # matching  

It seems that execution stops when the method segs1 = detector.detect(view1) is called. Any idea on how to solve the problem?

Thank you very much in advance!

B1ueber2y commented 1 year ago

Hi. Thanks for the interest!

From the provided information I guess it is either a torch problem at inference (the torch is not correctly installed), or that the directory to the images is incorrect. Could you look into this or provide more error messages?

Thanks!

adricostas commented 1 year ago

Hi,

Thanks for the quick reply. It doesn't seem a problem with torch because I can execute the line mapping example without any problem http://b1ueber2y.me/projects/LIMAP/docs/tutorials/triangulation.html. I don't have more information about the error but it seems that the problem is in this function img = camview.read_image(set_gray=True) that is inside the detect function.

B1ueber2y commented 1 year ago

I see. This is due to an error in the docs and an unsupported feature. This is fixed in the new update here: https://github.com/cvg/limap/pull/41. Thanks so much for reporting and contributing here. And let me know if there are still issues in your demo.

Thanks again!

adricostas commented 1 year ago

Thank you! Now it is working.