cdcseacave / openMVS

open Multi-View Stereo reconstruction library
http://cdcseacave.github.io
GNU Affero General Public License v3.0
3.16k stars 890 forks source link

SGM Parameter #1103

Open Rongke-Wei opened 4 months ago

Rongke-Wei commented 4 months ago

I would like to ask about the SGM method, where the formulas for the P1 and P2 penalty terms come from, and how the parameters in the formula are determined.

openMVS/libs/MVS /SemiGlobalMatcher.cpp

// - P1 and P2s are algorithm constants very similar to those from the original SGM algorithm; // they are set to defaults according to the patch size // - alpha & beta form the final P2 as P2(1+alphae^(-DI^2/(2*beta^2))) // where DI is the difference in image intensity I(x)-I(x_prev) in [0,255] range // - subpixelSteps represents how much sub-pixel accuracy is searched/stored; // if 1 no sub-pixel precision, if for example 4 a 0.25 sub-pixel accuracy is stored; // the stored value is quantized and represented as integer: val=(float)valStored/subpixelSteps SemiGlobalMatcher::SemiGlobalMatcher(SgmSubpixelMode _subpixelMode, Disparity _subpixelSteps, AccumCost _P1, AccumCost P2, float P2alpha, float P2beta) : subpixelMode(_subpixelMode), subpixelSteps(_subpixelSteps), P1(_P1), P2s(GenerateP2s(P2, P2alpha, P2beta)) { }

openMVS/libs/MVS /SemiGlobalMatcher.h

SemiGlobalMatcher(SgmSubpixelMode subpixelMode=SUBPIXEL_LC_BLEND, Disparity subpixelSteps=4, AccumCost P1=3, AccumCost P2=4, float P2alpha=14, float P2beta=38);

cdcseacave commented 4 months ago

this code is following the paper SemiGlobalMatcher

Rongke-Wei commented 4 months ago

Thank you very much for your reply.

But there is a difference between P2 in this paper and P2 in the code.

In this paper: 图片2

In code: 图片1