mapillary / OpenSfM

Open source Structure-from-Motion pipeline
https://www.opensfm.org/
BSD 2-Clause "Simplified" License
3.38k stars 858 forks source link

equirectangular compute_depthmaps #174

Closed happyfrank closed 7 years ago

happyfrank commented 7 years ago

Hello @paulinus Thanks for you share this amazing SFM algorithm code. I have a question wanna ask you. When I use equiretangular images to compute_depthmaps. OpenSfM slice this image to 6 cube images. then use these cube images to compute depthmap. I have 12 equiretangular image,s so slice to 72 cube images. But only 20 cube images are computed when I compute_depthmaps. I wanna ask, can OpenSfM use more or all cube images to compute depthmap or just use equiretangular images to compute depthmap?

paulinus commented 7 years ago

In principle, all images could be used. What can be happening is that for some images, it is not finding a good set matching images. I've seen this happening with panoramas before. Could you share the images for me to give it a try? Thanks!

happyfrank commented 7 years ago

That's all right. https://drive.google.com/open?id=0B6dyxmuu06BAYWJfNFhDV3NQaVE Thanks.

paulinus commented 7 years ago

We only use images that have at least 20 features in common with other images. I that dataset, many of the cube faces end up not having features in common with other images, so we skip dense matching for those.

I did a test and it seems that is what is happening for your dataset, mostly because of the uniform texture on the walls. Got this point cloud image

While testing I've discovered a bug in the resampling of the panoramas to cube faces. So please be sure to checkout current master. Thanks.

happyfrank commented 7 years ago

Thanks. Yes our build wall is white. So it's a little hard-to-match. Today I got two different results(which one is right, which one is wrong) when I test same dataset. I test 8 times. 5 times was right.

right result (double room) right

wrong result (double room) wrong Could you help me take a look at it? I already upload the dataset and it's OpenSfM result. this is the link: https://drive.google.com/open?id=0B6dyxmuu06BAWFIyWXBKY1lfUTQ Thanks.

paulinus commented 7 years ago

In that dataset the camera moves from one room to another via a corridor. What is happening is that there is too little overlap between the pictures of the corridor and the pictures of the rooms. It is actually surprising that it works at all ;-)

The fact that it only works sometimes in RANSAC. Something to be improved.

The times you get it wrong, what you are getting is 2 independent reconstructions. Each one is ok, but they are not aligned with each other. You can select to view only one of the reconstruction on the viewer.

If you want to get better results, take more pictures, especially when crossing doors to be sure that there is enough information to connect the two sides of the door.

Also for panoramas you may want to increase the resolution of the images and the number of features adding

feature_min_frames: 16000
feature_process_size: 4096

to config.yaml

happyfrank commented 7 years ago

That's all right. Thank you very much. ;-)

happyfrank commented 7 years ago

Hello @paulinus, sorry to disturb you. I have a question wanna ask you. Now I test multi_room and wanna get the relationship between all of the images.

So I print this value--common_tracks in function incremental_reconstruction of file reconstruction.py common_tracks = matching.all_common_tracks(graph, tracks) And save it to common_tracks.txt.

But I found there is no common tracks between corridor_07.JPG and corridor_08.JPG. and can't find a relationship through another image like door_03.JPG, corrdor_06.JPG and corridor_09.JPG. But those positions is correct. This confuse me a lot. Could you help me take a look at it? I already upload the dataset and it's OpenSfM result. this is the link: https://drive.google.com/open?id=0B6dyxmuu06BAY18xQzlEUHFJT3c Thanks. Sorry for the image quality. because the camera has a bad fall by accident recently. It is actually surprising that it works.

paulinus commented 7 years ago

all_common_tracks only return image pairs with at leas 50 tracks in common. I guess that that pair of images has less than 50 common tracks. You can change that threshold when calling the function to also get pairs with fewer common tracks.

happyfrank commented 7 years ago

That's all right. Thank you. @paulinus Today I got a problem when I test mutil_room. All camera position it looks very good through brower. Just like this. image But when I check the camera position at reconstruction.json. I found door_01.JPG and room1_16.JPG was too close.(it looks not close at brower.)

            "room1_16.JPG": {
                "orientation": 1, 
                "camera": "v2 ricoh ricoh theta s 5376 2688 equirectangular 0", 
                "gps_position": [
                    0.0, 
                    0.0, 
                    0.0
                ], 
                "gps_dop": 999999.0, 
                "rotation": [
                    1.5753300257121461, 
                    -0.045562139064856774, 
                    0.072121416942792699
                ], 
                "translation": [
                    -97.17499417605768, 
                    -1.649793996484316, 
                    -33.648642681248553
                ], 

            "door_01.JPG": {
                "orientation": 1, 
                "camera": "v2 ricoh ricoh theta s 5376 2688 equirectangular 0", 
                "gps_position": [
                    0.0, 
                    0.0, 
                    0.0
                ], 
                "gps_dop": 999999.0, 
                "rotation": [
                    1.5795909872238292, 
                    0.097949276410803032, 
                    -0.084070964667901857
                ], 
                "translation": [
                    -102.06346314772115, 
                    -0.63273220760993054, 
                    -33.063966938606001
                ],

Then I check image corridor_01.JPG position. The distance between corridor_01.JPG and door_01.JPG is correct.

            "corridor_01.JPG": {
                "orientation": 1, 
                "camera": "v2 ricoh ricoh theta s 5376 2688 equirectangular 0", 
                "gps_position": [
                    0.0, 
                    0.0, 
                    0.0
                ], 
                "gps_dop": 999999.0, 
                "rotation": [
                    1.5769811223822072, 
                    0.040113110714784378, 
                    0.0080933751840542648
                ], 
                "translation": [
                    -99.302863854906576, 
                    -2.7596445840104153, 
                    -62.023921867953057
                ], 

I wanna ask , is the brower get camera position through another file or translation is not the camera position? File: reconstruction.json reconstruction.json.txt

data project https://drive.google.com/open?id=0B6dyxmuu06BAeTZibGlKa1pHMzQ

paulinus commented 7 years ago

Note that reconstruction.json contains the translation vector, t. The camera position, o, can be computed as o=-R^T t

happyfrank commented 7 years ago

@paulinus Thanks for your reply. I just want to get the camera (X,Y,Z) at the coordinate system. So I didn't compute the camera position. Just use the translation vector. Am I wrong?