diff --git a/MMVII/src/CodedTarget/CodedTarget.h b/MMVII/src/CodedTarget/CodedTarget.h index a63657c8ca..704b9a9dfd 100755 --- a/MMVII/src/CodedTarget/CodedTarget.h +++ b/MMVII/src/CodedTarget/CodedTarget.h @@ -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 ; @@ -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); diff --git a/MMVII/src/CodedTarget/cSimulTarget.cpp b/MMVII/src/CodedTarget/cSimulTarget.cpp index 3f9c8fb132..cb5c363929 100755 --- a/MMVII/src/CodedTarget/cSimulTarget.cpp +++ b/MMVII/src/CodedTarget/cSimulTarget.cpp @@ -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) { } @@ -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); @@ -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); @@ -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);