Skip to content

Commit

Permalink
SimulTarget more deterministic
Browse files Browse the repository at this point in the history
  • Loading branch information
jmmuller committed Nov 14, 2024
1 parent c0ccf6d commit ac16f4a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
4 changes: 2 additions & 2 deletions MMVII/src/CodedTarget/CodedTarget.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class cGeomSimDCT
/// defaut constructor usefull for serialization
cGeomSimDCT();
/// constructor used afetr randoming generating parameters
cGeomSimDCT(const cOneEncoding & anEncod,const cPt2dr& aC,const double& aR1,const double& aR2);
cGeomSimDCT(const cOneEncoding & anEncod,const cPt2dr& aC,const double& aR1,const double& aR2, const std::string & aName);
/// Do to simulated target intersect, used to avoid overlapping target in images
bool Intersect(const cGeomSimDCT & aG2) const ;

Expand All @@ -148,7 +148,7 @@ class cGeomSimDCT
cPt2dr mCornEl2; ///< Theoreticall corner 2 of ellipse
double mR1; ///< "small" size of deformaed rectangle
double mR2; ///< "big " size ....
// std::string mName;
std::string mName;
};
/// method for serializing cGeomSimDCT
void AddData(const cAuxAr2007 & anAux,cGeomSimDCT & aGSD);
Expand Down
17 changes: 13 additions & 4 deletions MMVII/src/CodedTarget/cSimulTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,14 @@ void cGeomSimDCT::Translate(const cPt2dr & aTr)
}


cGeomSimDCT::cGeomSimDCT(const cOneEncoding & anEncod,const cPt2dr& aC,const double& aR1,const double& aR2):
cGeomSimDCT::cGeomSimDCT(const cOneEncoding & anEncod, const cPt2dr& aC, const double& aR1, const double& aR2, const std::string &aName):
mResExtr (nullptr),
mEncod (anEncod),
// mNum (aNum),
mC (aC),
mR1 (aR1),
mR2 (aR2)
mR2 (aR2),
mName(aName)
{
}

Expand Down Expand Up @@ -215,7 +216,7 @@ void cAppliSimulCodeTarget::AddPosTarget(const cOneEncoding & anEncod)
double aRsmall = aRbig*RandInInterval(mRS.mRatioMinMax);

// check if there is already a selected target overlaping
cGeomSimDCT aGSD(anEncod,aC,aRsmall,aRbig);
cGeomSimDCT aGSD(anEncod,aC,aRsmall,aRbig,anEncod.Name());
bool GotClose = false;
for (const auto& aG2 : mRS.mVG)
GotClose = GotClose || aG2.Intersect(aGSD);
Expand All @@ -230,6 +231,9 @@ void cAppliSimulCodeTarget::AddPosTarget(const cOneEncoding & anEncod)

void cAppliSimulCodeTarget::IncrustTarget(cGeomSimDCT & aGSD)
{
// We want that random is different for each image, but deterministic, independent of number of pixel noise drawn
cRandGenerator::TheOne()->setSeed(HashValue(mNameIm+"*"+aGSD.mName,true));

// [1] -- Load and scale image of target
tIm aImT = Convert((tElem*)nullptr,mSpec->OneImTarget(aGSD.mEncod).DIm());
aImT = aImT.GaussDeZoom(mDownScale,5);
Expand Down Expand Up @@ -369,11 +373,16 @@ int cAppliSimulCodeTarget::Exe()
{
if (MatchRegex(anEncod.Name(),mPatternNames))
{
// We want that random is different for each image, but deterministic for one given image
cRandGenerator::TheOne()->setSeed(HashValue(mNameIm+"/"+anEncod.Name(),true));
AddPosTarget(anEncod);
StdOut() << "Target " << anEncod.Name() << " " << mRS.mVG.back().mC << std::endl;
//StdOut() << "Target " << anEncod.Name() << " " << mRS.mVG.back().mC << std::endl;
}
}

if (!mRS.mVG.empty())
StdOut() << "1st target " << mRS.mVG[0].mName << " " << mRS.mVG[0].mC << std::endl;

for (auto & aG : mRS.mVG)
{
IncrustTarget(aG);
Expand Down

0 comments on commit ac16f4a

Please sign in to comment.