From 9eef5b65ba0ff11a1b4e67050eee16d2122a5d09 Mon Sep 17 00:00:00 2001 From: deseilligny Date: Wed, 15 May 2024 16:53:47 +0200 Subject: [PATCH 1/2] Before retrospection 4 debug --- MMVII/src/CodedTarget/cGenerateTarget.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/MMVII/src/CodedTarget/cGenerateTarget.cpp b/MMVII/src/CodedTarget/cGenerateTarget.cpp index 7fc601c1ea..5becbcecd3 100755 --- a/MMVII/src/CodedTarget/cGenerateTarget.cpp +++ b/MMVII/src/CodedTarget/cGenerateTarget.cpp @@ -979,7 +979,8 @@ eTyCodeTarget cAppliGenCodedTarget::Type() {return mBE.Specs().mType ;} cAppliGenCodedTarget::cAppliGenCodedTarget(const std::vector & aVArgs,const cSpecMMVII_Appli & aSpec) : cMMVII_Appli (aVArgs,aSpec), mPerGen (10), - mDoMarkC (false) + mDoMarkC (false), + mNbPixBin (1800) { } @@ -1011,7 +1012,7 @@ cCollecSpecArg2007 & cAppliGenCodedTarget::ArgOpt(cCollecSpecArg2007 & anArgOpt) << AOpt2007(mPCT.mRayOrientTablet,"SzOrFig","Size of \"diamond\" for orientation") << AOpt2007(mDoMarkC,"MarkC","Mark center of bits, just for verif ",{eTA2007::HDV,eTA2007::Tuning}) << AOpt2007(mZoomShow,"ZoomShow","Zoom to generate a high resolution check images",{eTA2007::Tuning}) - << AOpt2007(mNbPixBin,"NbPixBin","Size of binary image when printing") + << AOpt2007(mNbPixBin,"NbPixBin","Size of binary image when printing",{eTA2007::HDV}) ; } @@ -1022,8 +1023,8 @@ int cAppliGenCodedTarget::Exe() // anAppli.SetIfNotInit(mWithParity,false); - if (IsInit(&mNbPixBin)) - mPCT.SetNbPixBin(mNbPixBin); + //if (IsInit(&mNbPixBin)) + mPCT.SetNbPixBin(mNbPixBin); ReadFromFile(mBE,mNameBE); mPCT.FinishInitOfSpec(mBE.Specs()); From 729e08234b177f8317b7cae5a82466e64a6369da Mon Sep 17 00:00:00 2001 From: deseilligny Date: Thu, 16 May 2024 14:54:56 +0200 Subject: [PATCH 2/2] Bug Generate encoding 1000 code in "hard" --- MMVII/include/MMVII_Sensor.h | 5 +++- MMVII/src/CodedTarget/cCircTargetExtract.cpp | 18 ++++++++----- MMVII/src/CodedTarget/cGenerateEncoding.cpp | 9 ++++--- MMVII/src/CodedTarget/cSimulTarget.cpp | 4 ++- MMVII/src/Geom3D/cRotation3D.cpp | 27 +++++++++++++++++++ .../src/ImagesInfoExtract/ExtractBWTarget.cpp | 13 +++++++++ MMVII/src/Sensors/cPhotogrammetricProject.cpp | 8 +++++- MMVII/src/Serial/SerialByTree.cpp | 4 +-- 8 files changed, 73 insertions(+), 15 deletions(-) diff --git a/MMVII/include/MMVII_Sensor.h b/MMVII/include/MMVII_Sensor.h index 182bd888c6..932082e7b2 100755 --- a/MMVII/include/MMVII_Sensor.h +++ b/MMVII/include/MMVII_Sensor.h @@ -526,7 +526,10 @@ class cPhotogrammetricProject /// Does the image has an existing mask : Dir is init + file exist bool ImageHasMask(const std::string & aNameImage) const; - cIm2D MaskWithDef(const std::string & aNameImage,const cBox2di & aBox,bool DefVal) const; + // read masq of image, if OkNoMasq accept masq dont exist, return a masq full or empty if file dont exist (depend DefVal) + cIm2D MaskWithDef(const std::string & aNameImage,const cBox2di & aBox,bool DefVal,bool OkNoMasq=true) const; + // read masq , generate error if dont exist + cIm2D MaskOfImage(const std::string & aNameImage,const cBox2di & aBox) const; //=================================================================== //================== PointsMeasures ============================= diff --git a/MMVII/src/CodedTarget/cCircTargetExtract.cpp b/MMVII/src/CodedTarget/cCircTargetExtract.cpp index 98803f8391..c87ea7334e 100755 --- a/MMVII/src/CodedTarget/cCircTargetExtract.cpp +++ b/MMVII/src/CodedTarget/cCircTargetExtract.cpp @@ -76,6 +76,7 @@ cCircTargExtr::cCircTargExtr(const cExtractedEllipse & anEE) : mWithCode (false), mCardDetect (1) // By default, let be optimistic { + } @@ -141,7 +142,7 @@ class cCCDecode cCCDecode(cCircTargExtr & anEE,tCDIm & aDIm,tCDIm & aDGx , tCDIm & aDGy,const cFullSpecifTarget &,const cThresholdCircTarget &); - void Show(const std::string & aPrefix); + void ShowCDecoded(const std::string & aPrefix); /// Compute phase minimizing standard deviation, make a decision if its low enough void ComputePhaseTeta() ; @@ -206,6 +207,7 @@ class cCCDecode tREAL8 mWhite; tREAL8 mBWAmpl; tREAL8 mBWAvg; + size_t mFlagCode; const cOneEncoding * mEnCode; bool mOkGrad; bool mMarked4Test; @@ -455,11 +457,12 @@ void cCCDecode::ComputeCode() // flag for coding must be eventually inverted, depending of orientation convention { - size_t aFlagCode = aFlag; + mFlagCode = aFlag; + if (! mSpec.AntiClockWiseBit()) - aFlagCode = BitMirror(aFlag,size_t(1)<DGx(),mExtrEll->DGy(),*mSpec,mThresh); if (anEE->mMarked4Test) { - aCCD.Show(mPrefixOut); + aCCD.ShowCDecoded(mPrefixOut); } } diff --git a/MMVII/src/CodedTarget/cGenerateEncoding.cpp b/MMVII/src/CodedTarget/cGenerateEncoding.cpp index 34c26a799f..1bb81502ce 100755 --- a/MMVII/src/CodedTarget/cGenerateEncoding.cpp +++ b/MMVII/src/CodedTarget/cGenerateEncoding.cpp @@ -395,9 +395,12 @@ int cAppliGenerateEncoding::Exe() if (mUseAiconCode) { + // Read the file in ressources MMVII std::vector aVCode ; ReadCodesTarget(aVCode,cCompEquiCodes::NameCERNLookUpTable(mSpec.mNbBits)); + // In this case, by default, take all the code that were specified + SetIfNotInit(mSpec.mMaxNb,aVCode.size()); std::list aLamb = mCEC->AmbiguousCode(aVCode); if (!aLamb.empty()) @@ -528,10 +531,10 @@ int cAppliGenerateEncoding::Exe() SortOnCriteria(mVOC,[](auto aPCel){return aPCel->mLowCode;}); { cBitEncoding aBE; - for (size_t aK=0 ; aKmLowCode; + size_t aNum = aK1 + Num000; + size_t aCode = mVOC[aK1]->mLowCode; aBE.AddOneEncoding(aNum,aCode); // add a new encoding // Update all ranges diff --git a/MMVII/src/CodedTarget/cSimulTarget.cpp b/MMVII/src/CodedTarget/cSimulTarget.cpp index 222e9f04e8..38398f669a 100755 --- a/MMVII/src/CodedTarget/cSimulTarget.cpp +++ b/MMVII/src/CodedTarget/cSimulTarget.cpp @@ -73,7 +73,9 @@ double cResSimul::BorderGlob() const void AddData(const cAuxAr2007 & anAux,cResSimul & aRS) { - MMVII::AddData(cAuxAr2007("Com",anAux),aRS.mCom); + // Modif MPD, know that commande are quoted, they cannot be used as tag => "MMVII "toto" "b=3" " => PB!! + // MMVII::AddData(cAuxAr2007("Com",anAux),aRS.mCom); + anAux.Ar().AddComment(aRS.mCom); MMVII::AddData(cAuxAr2007("RayMinMax",anAux),aRS.mRayMinMax); MMVII::AddData(cAuxAr2007("RatioMax",anAux),aRS.mRatioMax); MMVII::AddData(cAuxAr2007("Geoms",anAux),aRS.mVG); diff --git a/MMVII/src/Geom3D/cRotation3D.cpp b/MMVII/src/Geom3D/cRotation3D.cpp index 0470073c12..3a8e129c18 100755 --- a/MMVII/src/Geom3D/cRotation3D.cpp +++ b/MMVII/src/Geom3D/cRotation3D.cpp @@ -261,6 +261,33 @@ template cRotation3D::cRotation3D(const cDenseMatrix & { mMat = mMat.ClosestOrthog(); } + else + { +#if (The_MMVII_DebugLevel>=The_MMVII_DebugLevel_InternalError_tiny ) + cPtxd aI = AxeI(); + cPtxd aJ = AxeJ(); + cPtxd aK = AxeK(); + + // "Epsilon value" set empirically taking into account the value obseved on current bench + + // are the vector unitar, take into account accuracy of type + tREAL8 aDifN = (std::abs(SqN2(aI)-1)+std::abs(SqN2(aJ)-1)+std::abs(SqN2(aK)-1)) / tElemNumTrait::Accuracy() ; + MMVII_INTERNAL_ASSERT_tiny(aDifN<1e-3,"Rotation 3D init non norm w/o RefineIt"); + + // are the vector orthognal, take into account accuracy of type + tREAL8 aDifS = (std::abs(Scal(aI,aJ))) / tElemNumTrait::Accuracy() ; + MMVII_INTERNAL_ASSERT_tiny(aDifS<1e-4,"Rotation 3D init non orthog w/o RefineIt"); + + /* + static tREAL8 aMaxDif=0; + if (aDifS> aMaxDif) + { + aMaxDif = aDifS; + StdOut() << "*********************** ******************** DIFFSSS=" << tNumTrait::NameType() << " "<< aMaxDif << "\n"; + } + */ +#endif + } // MMVII_INTERNAL_ASSERT_always((! RefineIt),"Refine to write in Rotation ..."); } diff --git a/MMVII/src/ImagesInfoExtract/ExtractBWTarget.cpp b/MMVII/src/ImagesInfoExtract/ExtractBWTarget.cpp index 7198712c74..076be8631d 100755 --- a/MMVII/src/ImagesInfoExtract/ExtractBWTarget.cpp +++ b/MMVII/src/ImagesInfoExtract/ExtractBWTarget.cpp @@ -268,6 +268,9 @@ bool cExtract_BW_Target::AnalyseOneConnectedComponents(cSeedBWTarget & aSeed) // if the point has been explored or is in border if (! MarqFree(aP0)) { + if (aSeed.mMarked4Test) + StdOut() << "### For Marked point " << aSeed.mPixW << " Point has already been explored ###" << std::endl; + aSeed.mOk = false; return false; } @@ -315,6 +318,16 @@ bool cExtract_BW_Target::AnalyseOneConnectedComponents(cSeedBWTarget & aSeed) if ((mPtsCC.size() >= aMaxNbPts) || touchOther || (int(mPtsCC.size()) < mPBWT.NbMinPtsCC())) { + if (aSeed.mMarked4Test) + { + if (mPtsCC.size() >= aMaxNbPts) + StdOut() << "====> ### For Marked point " << aSeed.mPixW << " too many points:" << mPtsCC.size() << " ###" << std::endl; + if (touchOther) + StdOut() << "====> ### For Marked point " << aSeed.mPixW << " touchOther " << " ###" << std::endl; + if (int(mPtsCC.size()) < mPBWT.NbMinPtsCC()) + StdOut() << "====> ### For Marked point " << aSeed.mPixW << " not enough point:" << mPtsCC.size() << " ###" << std::endl; + } + CC_SetMarq(eEEBW_Lab::eBadZ); return false; } diff --git a/MMVII/src/Sensors/cPhotogrammetricProject.cpp b/MMVII/src/Sensors/cPhotogrammetricProject.cpp index 807a24859a..b1ea2d6026 100644 --- a/MMVII/src/Sensors/cPhotogrammetricProject.cpp +++ b/MMVII/src/Sensors/cPhotogrammetricProject.cpp @@ -675,16 +675,22 @@ bool cPhotogrammetricProject::ImageHasMask(const std::string & aNameImage) cons && ExistFile(NameMaskOfImage(aNameImage)) ; } -cIm2D cPhotogrammetricProject::MaskWithDef(const std::string & aNameImage,const cBox2di & aBox,bool DefVal) const +cIm2D cPhotogrammetricProject::MaskWithDef(const std::string & aNameImage,const cBox2di & aBox,bool DefVal,bool OkNoMasq) const { if (ImageHasMask( aNameImage)) { return cIm2D::FromFile(NameMaskOfImage(aNameImage),aBox); } + MMVII_INTERNAL_ASSERT_always(OkNoMasq,"Masq dont exist for image : " + aNameImage); + return cIm2D (aBox.Sz(),nullptr, (DefVal ? eModeInitImage::eMIA_V1 : eModeInitImage::eMIA_Null)) ; } +cIm2D cPhotogrammetricProject::MaskOfImage(const std::string & aNameImage,const cBox2di & aBox) const +{ + return MaskWithDef(aNameImage,aBox,false,false); +} // ============= PointsMeasures ================= diff --git a/MMVII/src/Serial/SerialByTree.cpp b/MMVII/src/Serial/SerialByTree.cpp index 29b9c73d7c..0177804dc9 100755 --- a/MMVII/src/Serial/SerialByTree.cpp +++ b/MMVII/src/Serial/SerialByTree.cpp @@ -392,8 +392,8 @@ void cXmlSerialTokenParser::CheckOnClose(const cSerialTree & aTree,const std::st { if (aTree.Value() != aStr) { - StdOut()<< "Expected : [" << aStr << "], Got : [" << aTree.Value()<< "] " << std::endl; - MMVII_INTERNAL_ASSERT_tiny(false,"Close tag unexpected"); + StdOut()<< "Expected : [" << aTree.Value() << "], Got : [" << aStr << "] " << std::endl; + MMVII_INTERNAL_ASSERT_tiny(false,"Close tag unexpected in file "+ mMMIs.Name()); } }