Ask Your Question
2

Example Stitching_detailed and refine_mask

asked 2015-06-12 10:41:39 -0600

LBerger gravatar image

Hi,

I have tried example opencv\samples\cpp\stitching_detailed.cpp and I have got an problem with parameters --ba_refine_mask (mask). in this sample five parameters are defined at line 534-538

if (ba_refine_mask[0] == 'x') refine_mask(0, 0) = 1;
if (ba_refine_mask[1] == 'x') refine_mask(0, 1) = 1;
if (ba_refine_mask[2] == 'x') refine_mask(0, 2) = 1;
if (ba_refine_mask[3] == 'x') refine_mask(1, 1) = 1;
if (ba_refine_mask[4] == 'x') refine_mask(1, 2) = 1;

If we look now in code of opencv\modules\stitching\src\motion_estimators.cpp at line 407, 417, 427 and 437 only refine_mask(0, 0), refine_mask(0, 2), refine_mask(1, 1) and refine_mask(1, 2) are used.

So In opencv\samples\cpp\stitching_detailed.cpp parameter ba_refine_mask[1] seems to be unused. Is ir right?

Thanks for your answer.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2016-10-26 13:41:56 -0600

DaePa gravatar image

updated 2016-10-26 16:17:22 -0600

No, that is not right. If you need a confirm, you can look at the very beginning of the tutorial, where the printUsage() function is. Right after, you can see the default setting is xxxxx.

The refinement mask contains five parameters (in this order):

<fx>
<skew>
<ppx>
<aspect>
<ppy>

if set to x the parameter is corrected by the adjuster (if the adjuster can do so, otherwise the parameter is skipped).

As you are stating, thanks for having the patience to discuss this, even if the <skew> parameter is set in the stitching_detailed tutorial, only BundleAdjusterReproj, out of all the types of BundleAdjusters actually cares for the values of the mask, and it does not take into account the <skew> possibility.

Thus yes, the parameter is set, but actually not used by any class.


Some more thoughts: the BundleAdjusterRay description opens a way of possible future implementation of the refine_mask. That was true in opencv 2.4 and it is still the same in opencv 3.1 documentation.

In Line 172 of motion_estimators.hpp, the file from where the documentation is derived, the refinement_mask is described by a 3x3 matrix. That is not right, right? Shouldn't it be a 2x3, instead? Am I missing something now?

edit flag offensive delete link more

Comments

This message is rather old. take care about file history of stitching_detailed and stitching module too in git

LBerger gravatar imageLBerger ( 2016-10-26 13:58:18 -0600 )edit

Last commit for stitching is 4 days ago. I think your answer is wrong and my comments is good because at those lines only four values are used. Where value refine_mask(0,1) is used in source code ?

LBerger gravatar imageLBerger ( 2016-10-26 15:07:05 -0600 )edit

I see your point, now. I was assuming another type of bundleAdjuster would have used the refine_mask(0,1) parameter, but, as far as I can understand (and research with provided tools), refinement_mask is a parameter only BundleAdjusterReproj is aware of. I am editing my answer to reflect this.

Also, one should notice that refine_mask is a 3x3 matrix, thus one row of values is always set to 0 and never accessed. (what have I just read?)

DaePa gravatar imageDaePa ( 2016-10-26 15:59:40 -0600 )edit

I think refinement_mask was introduced 5 years ago in 2.4.0. And it is written

"If bundle\n"
        "      adjustment doesn't support estimation of selected parameter then\n"
        "      the respective flag is ignored.\n"

mean some options are in progress...but not finished yet

LBerger gravatar imageLBerger ( 2016-10-27 02:11:09 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2015-06-12 10:41:39 -0600

Seen: 793 times

Last updated: Oct 26 '16