Skip to content

Commit

Permalink
Scales interpolator by string
Browse files Browse the repository at this point in the history
  • Loading branch information
deseilligny committed Jan 20, 2025
1 parent 8d45593 commit 7b179cb
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 23 deletions.
1 change: 1 addition & 0 deletions MMVII/include/MMVII_Interpolators.h
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ class cTabulatedDiffInterpolator : public cDiffInterpolator1D
class cScaledInterpolator : public cInterpolator1D
{
public :
static const std::string TheNameInterpol;

virtual ~ cScaledInterpolator();
tREAL8 Weight(tREAL8 anX) const override;
Expand Down
51 changes: 29 additions & 22 deletions MMVII/src/BundleAdjustment/Bundle_LidarPhotogra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ cBA_LidarPhotogra::cBA_LidarPhotogra(cMMVII_BundleAdj& aBA,const std::vector<std
}
// create the interpaltor itself
mInterp = cDiffInterpolator1D::AllocFromNames(aParamInt);
// delete mInterp;
// mInterp = cScaledInterpolator::AllocTab(cCubicInterpolator(-0.5),3,1000);

// parse the camera and create images
for (const auto aPtrCam : aBA.VSIm())
Expand Down Expand Up @@ -161,6 +163,30 @@ void cBA_LidarPhotogra::SetVUkVObs
int aKPt
)
{
cSensorCamPC * aCam = mVCam.at(aData.mKIm); // extract the camera
cPt3dr aPCam = aCam->Pt_W2L(aPGround); // coordinate of point in image system
tProjImAndGrad aPImGr = aCam->InternalCalib()->DiffGround2Im(aPCam); // compute proj & gradient

// Vector of indexes of unknwons
if (aVIndUk)
{
* aVIndUk = std::vector<int> {-1} ; // first one is a temporary (convention < 0)
aCam->PushIndexes(*aVIndUk); // add the unknowns [C,R] of the camera
}


// vector that will contains values of observation at this step
aCam->Pose_WU().PushObs(aVObs,true); // true because we transpose: we use W->C, which is the transposition of IJK : C->W

aPGround.PushInStdVector(aVObs); //
aPCam.PushInStdVector(aVObs);

aPImGr.mGradI.PushInStdVector(aVObs); // Grad Proj/PCam
aPImGr.mGradJ.PushInStdVector(aVObs);

auto [aRad0,aGradIm] = aData.mVGr.at(aKPt); // Radiom & grad
aVObs.push_back(aRad0);
aGradIm.PushInStdVector(aVObs);
}


Expand Down Expand Up @@ -225,28 +251,9 @@ void cBA_LidarPhotogra::Add1Patch(tREAL8 aWeight,const std::vector<cPt3dr> & aV
// parse the data of the patch
for (const auto & aData : aVData)
{
cSensorCamPC * aCam = mVCam.at(aData.mKIm); // extract the camera
cPt3dr aPCam = aCam->Pt_W2L(aPGround); // coordinate of point in image system
tProjImAndGrad aPImGr = aCam->InternalCalib()->DiffGround2Im(aPCam); // compute proj & gradient

// Vector of indexes of unknwons
std::vector<int> aVIndUk{-1} ; // first one is a temporary (convention < 0)
aCam->PushIndexes(aVIndUk); // add the unknowns [C,R] of the camera


// vector that will contains values of observation at this step
std::vector<tREAL8> aVObs;
aCam->Pose_WU().PushObs(aVObs,true); // true because we transpose: we use W->C, which is the transposition of IJK : C->W

aPGround.PushInStdVector(aVObs); //
aPCam.PushInStdVector(aVObs);

aPImGr.mGradI.PushInStdVector(aVObs); // Grad Proj/PCam
aPImGr.mGradJ.PushInStdVector(aVObs);

auto [aRad0,aGradIm] = aData.mVGr.at(0); // Radiom & grad
aVObs.push_back(aRad0);
aGradIm.PushInStdVector(aVObs);
std::vector<int> aVIndUk;
std::vector<tREAL8> aVObs;
SetVUkVObs (aPGround,&aVIndUk,aVObs,aData,0);

// accumulate the equation involving the radiom
aSys->R_AddEq2Subst(aStrSubst,mEqLidPhgr,aVIndUk,aVObs,aWeight);
Expand Down
14 changes: 13 additions & 1 deletion MMVII/src/UtiMaths/Interpolators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,15 @@ cDiffInterpolator1D * cDiffInterpolator1D::AllocFromNames(const std::vector<std:
delete anInt;
return aRes;
}
if (aN0== cScaledInterpolator::TheNameInterpol)
{
tREAL8 aScale = cStrIO<tREAL8>::FromStr(Get(aVName,aK+1));
int aNbTabul = cStrIO<int>::FromStr(Get(aVName,aK+2));
cDiffInterpolator1D * anInt = AllocFromNames(aVName,aK+3);
cTabulatedDiffInterpolator * aRes = cScaledInterpolator::AllocTab(*anInt,aScale,aNbTabul) ;
delete anInt;
return aRes;
}
if (aN0== cLinearInterpolator::TheNameInterpol)
{
AssertEndParse(aVName,aK);
Expand Down Expand Up @@ -630,14 +639,17 @@ cScaledInterpolator::cScaledInterpolator
cInterpolator1D
(
aInterp->SzKernel() * aScale,
Append(std::vector<std::string>{"Scale",ToStr(aScale)},aInterp->VNames())
Append(std::vector<std::string>{TheNameInterpol,ToStr(aScale)},aInterp->VNames())
),
mInterp (aInterp),
mScale (aScale),
mToDelete (isToDelete)
{
}

const std::string cScaledInterpolator::TheNameInterpol("Scale");


cScaledInterpolator::~cScaledInterpolator()
{
if (mToDelete)
Expand Down

0 comments on commit 7b179cb

Please sign in to comment.