Computing Variance/Covariance in Bundle Adjustment

353 views
Skip to first unread message

Alan Buchanan

unread,
Aug 14, 2017, 10:39:00 AM8/14/17
to Ceres Solver
Hello Sameer,

I am able to compute Variance/Covariance on a simple adjustment (not a BA) following the instructions on the website so I am reasonably confident that I am using the correct method. I am also using SuiteSparse.

However I am having trouble getting this to work on a Bundle Adjustment> I am using the openMVG framework. I am not using any SetParameterBlockConstant blocks.

What I am finding is that the    " int index1 = FindOrDie(parameter_block_to_row_index_, block_pair.first);" fails in  ComputeCovarianceSparsity

This function fails completely on the Intrinsics and Pose variance/covariances but will work for a while with the Structure data before falling over when I assume the pointers can't be found.

The only thing that I can think of that is different between a simple adjustment and my BA is the use of  Loss Functions. I am using  (HuberLoss). I was wondering whether this has some effect.

Do you have any suggestions on what I need to look at.

Alan
 






Sameer Agarwal

unread,
Aug 14, 2017, 10:42:59 AM8/14/17
to Ceres Solver
Alan,
I doubt this has anything to do with loss functions. Is it possible to create a small reproduction?  Hard to debug this without looking at what is going on.
Sameer


--
You received this message because you are subscribed to the Google Groups "Ceres Solver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ceres-solver...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceres-solver/b565c3b8-a21d-4e2b-be98-8109062adb02%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alan Buchanan

unread,
Aug 14, 2017, 1:26:43 PM8/14/17
to ceres-...@googlegroups.com
I will try and down sample my model down to minimalistic data set and forward.



On 14 Aug 2017 22:43, "'Sameer Agarwal' via Ceres Solver" <ceres-...@googlegroups.com> wrote:
Alan,
I doubt this has anything to do with loss functions. Is it possible to create a small reproduction?  Hard to debug this without looking at what is going on.
Sameer


On Mon, Aug 14, 2017 at 7:39 AM Alan Buchanan <abuc...@gmail.com> wrote:
Hello Sameer,

I am able to compute Variance/Covariance on a simple adjustment (not a BA) following the instructions on the website so I am reasonably confident that I am using the correct method. I am also using SuiteSparse.

However I am having trouble getting this to work on a Bundle Adjustment> I am using the openMVG framework. I am not using any SetParameterBlockConstant blocks.

What I am finding is that the    " int index1 = FindOrDie(parameter_block_to_row_index_, block_pair.first);" fails in  ComputeCovarianceSparsity

This function fails completely on the Intrinsics and Pose variance/covariances but will work for a while with the Structure data before falling over when I assume the pointers can't be found.

The only thing that I can think of that is different between a simple adjustment and my BA is the use of  Loss Functions. I am using  (HuberLoss). I was wondering whether this has some effect.

Do you have any suggestions on what I need to look at.

Alan
 






--
You received this message because you are subscribed to the Google Groups "Ceres Solver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ceres-solver+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "Ceres Solver" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ceres-solver/eeYo20t8kf8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ceres-solver+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceres-solver/CABqdRUDiC5pzmGXOSOGvUW2DDaHCQ5%2BCV%3DvG6jiWjNBf8%2BDT4A%40mail.gmail.com.

Sameer Agarwal

unread,
Aug 14, 2017, 1:33:20 PM8/14/17
to ceres-...@googlegroups.com
SGTM

On Mon, Aug 14, 2017 at 10:26 AM Alan Buchanan <abuc...@gmail.com> wrote:
I will try and down sample my model down to minimalistic data set and forward.



On 14 Aug 2017 22:43, "'Sameer Agarwal' via Ceres Solver" <ceres-...@googlegroups.com> wrote:
Alan,
I doubt this has anything to do with loss functions. Is it possible to create a small reproduction?  Hard to debug this without looking at what is going on.
Sameer


On Mon, Aug 14, 2017 at 7:39 AM Alan Buchanan <abuc...@gmail.com> wrote:
Hello Sameer,

I am able to compute Variance/Covariance on a simple adjustment (not a BA) following the instructions on the website so I am reasonably confident that I am using the correct method. I am also using SuiteSparse.

However I am having trouble getting this to work on a Bundle Adjustment> I am using the openMVG framework. I am not using any SetParameterBlockConstant blocks.

What I am finding is that the    " int index1 = FindOrDie(parameter_block_to_row_index_, block_pair.first);" fails in  ComputeCovarianceSparsity

This function fails completely on the Intrinsics and Pose variance/covariances but will work for a while with the Structure data before falling over when I assume the pointers can't be found.

The only thing that I can think of that is different between a simple adjustment and my BA is the use of  Loss Functions. I am using  (HuberLoss). I was wondering whether this has some effect.

Do you have any suggestions on what I need to look at.

Alan
 






--
You received this message because you are subscribed to the Google Groups "Ceres Solver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ceres-solver...@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "Ceres Solver" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ceres-solver/eeYo20t8kf8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ceres-solver...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Ceres Solver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ceres-solver...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceres-solver/CAORuK71AQ88UOHNVmmutwZe6R2DuPKvfJee3ADma0CGvoaQPKQ%40mail.gmail.com.

Sameer Agarwal

unread,
Aug 14, 2017, 5:25:25 PM8/14/17
to ceres-...@googlegroups.com
btw, the values don't matter, only the sparsity structure which triggers this.
Sameer


Alan Buchanan

unread,
Aug 15, 2017, 8:47:22 AM8/15/17
to Ceres Solver
Sameer,

I have a minimal bundle adjustment.   What information should I send to you ?

I have stepped through the code and the actual crash is related to the logging (falls over in MessageLogger).

Nevertheless it fails because it can't detect the key in

FindOrDie(const Collection& collection,
          const typename Collection::value_type::first_type& key) {
  typename Collection::const_iterator it = collection.find(key);
  CHECK(it != collection.end()) << "Map key not found: " << key;                // Crashes here
  return it->second;
}

The key is in the collection but for some reason collection.find(key) doesn't find it.
 I have checked and the collection.first value is the same as the key value. So not sure what would cause this to fail

Alan




Alex Stewart

unread,
Aug 15, 2017, 9:10:04 AM8/15/17
to ceres-...@googlegroups.com
Hi Alan,

The key is in the collection but for some reason collection.find(key) doesn't find it.

The container here is just a std::map, so either there is a memory corruption issue, or that key is not in the container.  How did you verify that it was in the container?

The most likely explanation for this is that you are calling Compute with pointers that are not parameter blocks in the problem, are you sure that:

problem.HasParameterBlock(<parameter_block>);

returns true for every parameter block pointer that you add to the covariance_blocks you are calling Compute() with?

-Alex

--
You received this message because you are subscribed to the Google Groups "Ceres Solver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ceres-solver...@googlegroups.com.

Sameer Agarwal

unread,
Aug 15, 2017, 9:13:24 AM8/15/17
to ceres-...@googlegroups.com
if you have a code fragment that can replicate it, that I can run would be the best.

Alan Buchanan

unread,
Aug 15, 2017, 10:41:31 AM8/15/17
to Ceres Solver
Thanks fro you reply,

I agree it must be a pointer problem but hard for me to trace.

I was able to very the value in container against the key value using my debugger. 

I will try  problem.HasParameterBlock(<parameter_block>); to narrow it down.

Alan Buchanan

unread,
Aug 15, 2017, 12:23:42 PM8/15/17
to Ceres Solver
Lex,

Using problem.HasParameterBlock(<parameter_block>); help me track this down.

I was passing my parameters (map_poses, map_intrinsics) to my covariance function  by value rather than as pointers !
Hash_Map<IndexT, std::vector<double> > map_poses;
Hash_Map<IndexT, std::vector<double> > map_intrinsics;

So it computes but the solution I provided is failing because it is rank deficient !  Not sure why it has come up with.that. I am using SuiteSparse and I guess I could try a DENSE_SVD. 

Another question is to do with  problem.AddParameterBlock.

I am using the openMVG pipeline. They AddParameterBlocks for the Intrinsics and Poses and then set SetParameterBlockConstant if required.
However for the structure parameters they do not call  AddParameterBlocks. Do I need to explicity call this funtcion if I need to extract Var/Cov for the structure points ? Does this add any overhead to the Solve function ? Could this be a cause for the rank deficiciency issue ?

Regards,

Alan







On Tuesday, 15 August 2017 21:10:04 UTC+8, Lex wrote:

Sameer Agarwal

unread,
Aug 15, 2017, 12:32:34 PM8/15/17
to Ceres Solver
If you are solving a normal bundle adjustment problem, then the jacobian is rank deficient because of the gauge ambiguity.

Alex Stewart

unread,
Aug 15, 2017, 12:42:25 PM8/15/17
to ceres-...@googlegroups.com
Alan,

Do I need to explicity call this funtcion if I need to extract Var/Cov for the structure points ?

No, AddResidualBlock() will implicitly add the parameter blocks if they are not already registered with the problem:


Does this add any overhead to the Solve function ?

No.

Could this be a cause for the rank deficiciency issue ?

No, as Sameer said that is likely gauge ambiguity.

-Alex

Alan Buchanan

unread,
Aug 16, 2017, 3:29:12 AM8/16/17
to Ceres Solver
Thanks for all your help,

I have now got this working after reading what gauge  invariance means and looking at the data closely.

Bascially, my understanding is that rank deficiency occurs in a free BA adjustment because the model is floating and has not been placed on control.

My  example had a difference between rank and columns of 7 which corresponds to requiring 2x2D (horizontal) control points and 3 x 1D (vertical) to place on a datum. In other words enough control to solve a similarity transformation.

So it makes perfect sense to me now !  In my work I would only require the variance/covariance matrix on  a controlled model (not a free adjustment model).

Thanks again,

Alan

Sameer Agarwal

unread,
Aug 16, 2017, 12:10:19 PM8/16/17
to Ceres Solver
Great!

--
You received this message because you are subscribed to the Google Groups "Ceres Solver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ceres-solver...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages