naver / kapture

kapture is a file format as well as a set of tools for manipulating datasets, and in particular Visual Localization and Structure from Motion data.
BSD 3-Clause "New" or "Revised" License
466 stars 66 forks source link

Improve kapture_import_image_folder.py #32

Closed Keunmo closed 3 years ago

Keunmo commented 3 years ago

When I use kapture_import_image_folder.py, It feels bit uncomfortable that I can't assign a specific camera model and the following parameters. So I modify this code a little. It allows user assign specific sensor information about images.

I think people will store images in same folder if those are taken from same sensor. So, If user write sensors.txt about their image data, this will make kapture data with specified sensor info. sensors.txt should locate at images_path and sensors.txt's sensor_id should be each image folder's name.

For example:

images
├─ sensors.txt
├─ cam0
│  ├─ img1.jpg
│  ├─ img2.jpg         
│  ├─ ...
│  └─ imgN.jpg
├─ cam1   
│  ├─ img1.jpg
│  ├─ img2.jpg         
│  ├─ ...
│  └─ imgN.jpg
└─ cam2  
   ├─ img1.jpg
   ├─ img2.jpg         
   ├─ ...
   └─ imgN.jpg  

in this case, sensos.txt should be look like this:

# kapture format: 1.1
# sensor_id, name, sensor_type, [sensor_params]+
cam0, , camera, SENSOR_TYPE, P1, P2, P3, ...
cam1, , camera, SENSOR_TYPE, P1, P2, P3, ...
cam2, , camera, SENSOR_TYPE, P1, P2, P3, ...

or

cam0
├─ sensors.txt
├─ img1.jpg
├─ img2.jpg         
├─ ...
└─ imgN.jpg

in this case, sensors.txt should be look like this:

# kapture format: 1.1
# sensor_id, name, sensor_type, [sensor_params]+
cam0, , camera, SENSOR_TYPE, P1, P2, P3, ...

if user doesn't know sensor type and param about images, it's okay. If image folder doesn't have sensors.txt, it works in the old way. If sensors.txt only have partitial info(ex. only have cam0 in case1), it gives that params only for those images.

I send pr about this issue, so I'd be happy if you give any feedback.

Keunmo commented 3 years ago

33

jujumo commented 3 years ago

for your information I added tests and small refactor of import_image_folder (use existing code to load sensors.txt).

Keunmo commented 3 years ago

Wow. I learned a lot. Thank you!