openMVG / openMVG

open Multiple View Geometry library. Basis for 3D computer vision and Structure from Motion.
Mozilla Public License 2.0
5.71k stars 1.68k forks source link

Global SfM problem #720

Closed MEGA728 closed 7 years ago

MEGA728 commented 7 years ago

I used IncrementalSfM with pre-calculated correspondences , and it worked fine. But when I used GlobalSfM, this happened "-- #Relative triplet of translations estimates: 0 computed from 969 triplets."

Can anybody tell me why it became 0 ?

Thanks!

pmoulon commented 7 years ago

Hi @MEGA728 Can you share the reconstruction log?

The cause could be due to some data intrinsic that are too bad or due to the fact that the computed global rotations are false.

MEGA728 commented 7 years ago

Hi @pmoulon

Thank you for your fast reply !

What do you mean by "reconstruction log"? I found this "Reconstruction_Report.html" and attached it. reconstruction_report

Another question: after calibrating my camera, I got two focal length, fx and fy, but in sfm_data.json there is only one "focal" in the intrinsics, how do I use the pre-calibrated fx and fy?

pmoulon commented 7 years ago

I mean the log that is shown on the console output.

You can use f = (fx+fy)/2 +> must be in pixels Be sure to configure also the principal point position

MEGA728 commented 7 years ago

Ah, the log is as follows: GlobalSfM.txt

pmoulon commented 7 years ago

From the log I saw that the rotation averaging for your dataset produce a large residual error for the triplet composition error => median: 17.3482

Often the value is below 5 or 2 degree. Do not know what is happening without playing with your data.

MEGA728 commented 7 years ago

Some days ago, I used Global SfM to deal with another pre-calculated correspondences dataset, residual error for the triplet composition error => median: 15.4145, which is also quite large, but I can still get a good result from Global SfM.

About the current problem, the data is as follows, you can take a look at it, if it is not too much trouble :) input.zip

I was just thinking that maybe this problem occurred because I used too few matches? I only used 15 points from the target shown bellow . 918871312192725581

pmoulon commented 7 years ago

@MEGA728 I made a fast test on your dataset, and I was able to get a nice result with the Incremental pipeline. For the globalSfM pipeline the default settings ask more points per pair than that you have (more than 15).

The incremental pipeline seems to provide a very nice result (according the median residuals (0.0245262) and the produced point cloud)

-------------------------------
-- Structure from Motion (statistics):
-- #Camera calibrated: 19 from 19 input images.
-- #Tracks, #3D points: 15
-------------------------------

SequentialSfMReconstructionEngine::ComputeResidualsMSE.
    -- #Tracks: 15
    -- Residual min:    9.45625e-05
    -- Residual median: 0.0245262
    -- Residual max:     0.219888
    -- Residual mean:    0.032899
./openMVG_main_IncrementalSfM -i /home/pierre/Pictures/Datasets/mega72
8/input/sfm_data.json -m /home/pierre/Pictures/Datasets/mega728/input/ -o /home/pierre/Pictures/Datasets/mega728/output_inc

snapshot00 snapshot01 snapshot02

Here as ortho view snapshot_ortho03 snapshot_ortho04

For the GlobalSfM failure (15 degree mean error for cycle relative rotation composition) => Seems like your point configuration is perfectly planar, it looks like a degenerate configuration that I think make some relative essential matrix decomposition fail. Perhaps a Homography fit plus homography decomposition would provide a better results.

MEGA728 commented 7 years ago

I get it, the GlobalSfM may not be suitable for planar object. THX !

pmoulon commented 7 years ago

It may if we have the right initial Relative rotation decomposition for planar object ;-)

MEGA728 commented 7 years ago

So sometimes we get the the right initial relative rotation decomposition, sometimes we don't. Is there any method to assure that we have the right initial relative rotation decomposition for planar object every time?

pmoulon commented 7 years ago

Using Homography and Homography (R|t) decomposition.

MEGA728 commented 7 years ago

Thanks for your advice!