Skip to content

Commit

Permalink
Merge branch 'master' into mpd
Browse files Browse the repository at this point in the history
  • Loading branch information
deseilligny committed Dec 11, 2024
2 parents 0dcfcda + 14b3dca commit 77cdfb5
Show file tree
Hide file tree
Showing 25 changed files with 67 additions and 75 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -270,11 +270,9 @@ struct sparse_solve_triangular_sparse_selector<Lhs,Rhs,Mode,UpLo,ColMajor>
}


Index count = 0;
// FIXME compute a reference value to filter zeros
for (typename AmbiVector<Scalar,StorageIndex>::Iterator it(tempVector/*,1e-12*/); it; ++it)
{
++ count;
// std::cerr << "fill " << it.index() << ", " << col << "\n";
// std::cout << it.value() << " ";
// FIXME use insertBack
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ void SparseLUImpl<Scalar,StorageIndex>::heap_relax_snode (const Index n, IndexVe
// Identify the relaxed supernodes by postorder traversal of the etree
Index snode_start; // beginning of a snode
StorageIndex k;
Index nsuper_et_post = 0; // Number of relaxed snodes in postordered etree
Index nsuper_et = 0; // Number of relaxed snodes in the original etree
[[maybe_unused]] Index nsuper_et_post = 0; // Number of relaxed snodes in postordered etree
[[maybe_unused]] Index nsuper_et = 0; // Number of relaxed snodes in the original etree
StorageIndex l;
for (j = 0; j < n; )
{
Expand Down
4 changes: 3 additions & 1 deletion MMVII/include/MMVII_Image2D.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ class cDataFileIm2D : public cRect2
static cDataFileIm2D Create(const std::string & aName,eForceGray);
/// Create the file before returning the descriptor
static cDataFileIm2D Create(const std::string & aName,eTyNums,const cPt2di & aSz, int aNbChan=1);
/// Options depends on each format driver and may be not applied if the file already exits ...
static cDataFileIm2D Create(const std::string & aName,eTyNums,const cPt2di & aSz, const tOptions& aOptions, int aNbChan=1);

// Special creation for full write (non updatable) format : jpeg, png, ...
// Special creation for fully write format : jpeg, png, ... File will be (re)created on each write and the full file must be written at once
// This function guarantees that the options will be applied (if driver allows them ...)
static cDataFileIm2D CreateOnWrite(const std::string & aName,eTyNums,const cPt2di & aSz, const tOptions& aOptions={}, int aNbChan=1);
static cDataFileIm2D CreateOnWrite(const std::string & aName,eTyNums,const cPt2di & aSz, int aNbChan=1);

Expand Down
4 changes: 1 addition & 3 deletions MMVII/include/V1VII.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void MakeStdIm8BIts(cIm2D<tREAL4> aImIn,const std::string& aName);



//FIXME CM->MPD: Must replace cMMV1_Conv::ImToMMV1
//FIXME CM->MPD: Mail MPD fichier xmmlV1.cpp Must replace cMMV1_Conv::ImToMMV1
template <class Type> class cMMV1_Conv
{
public :
Expand All @@ -64,8 +64,6 @@ template <class Type> class cMMV1_Conv
#endif
};

std::string V1NameMasqOfIm(const std::string & aName);

// Call V1 Fast kth value extraction
double KthVal(std::vector<double> &, double aProportion);
// Idem but indicate a number and not a proportion
Expand Down
2 changes: 1 addition & 1 deletion MMVII/src/Appli/cMMVII_Appli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1726,7 +1726,7 @@ cParamCallSys cMMVII_Appli::StrCallMMVII

// std::string aComGlob = mFullBin + " ";
aRes.AddArgs(mFullBin);
int aNbSubst=0;
[[maybe_unused]] int aNbSubst=0;
std::vector<bool> aVUsedSubst(aSubst.V().size(),false);
/*
cSpecMMVII_Appli* aSpec = cSpecMMVII_Appli::SpecOfName(aCom2007,false); // false => dont accept no match
Expand Down
2 changes: 1 addition & 1 deletion MMVII/src/Appli/cMMVII_GenArgsSpec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ static const std::vector<eTA2007> prjSubDirList = // c

static const std::map<eTA2007,std::vector<std::string>> fileList = // clazy:exclude=non-pod-global-static
{
{eTA2007::FileImage,{".tif",".tiff",".jpg",".jpeg",".png",".cr2",".crw",".nef"}},
{eTA2007::FileImage,{".tif",".tiff",".jpg",".jpeg",".png",".jp2",".bmp",".cr2",".crw",".nef"}},
{eTA2007::FileCloud,{".ply"}},
{eTA2007::File3DRegion,{""}},
{eTA2007::XmlOfTopTag,{".xml",".json"}},
Expand Down
2 changes: 0 additions & 2 deletions MMVII/src/CodedTarget/cCdts_CheckBoardTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,6 @@ cCdRadiom::cCdRadiom
mCostCorrel (2.001), // over maximal theoreticall value
mRatioBW (0)
{
static int aCpt=0 ; aCpt++;

int aNbIn0=0,aNbIn1=0;

cMatIner2Var<tREAL8> aCorGrayAll;
Expand Down
6 changes: 1 addition & 5 deletions MMVII/src/CodedTarget/cCheckBoardTargetExtract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ void cAppliCheckBoardTargetExtract::SetLabel(const cPt2dr& aPt,tU_INT1 aLabel)
cCdRadiom cAppliCheckBoardTargetExtract::MakeCdtRadiom(cScoreTetaLine & aSTL,const cCdSym & aCdSym,tREAL8 aThickness)
{
bool IsMarqed = IsPtTest(aCdSym.mC);
static int aCptGlob=0 ; aCptGlob++;
// static int aCptGlob=0 ; aCptGlob++;
static int aCptMarq=0 ; if (IsMarqed) aCptMarq++;
DebugCB = (aCptMarq == mNumDebugMT) && IsMarqed;

Expand Down Expand Up @@ -431,15 +431,13 @@ void cAppliCheckBoardTargetExtract::ComputeTopoSadles()
// select 1 point in conected component

cAutoTimerSegm aTSMaxCC(mTimeSegm,"2.1-MaxCCSad");
int aNbCCSad=0;
std::vector<cPt2di> aVCC;
const std::vector<cPt2di> & aV8 = Alloc8Neighbourhood();

for (const auto& aPix : *mDImLabel)
{
if (mDImLabel->GetV(aPix)==eTopo0)
{
aNbCCSad++;
ConnectedComponent(aVCC,*mDImLabel,aV8,aPix,eTopo0,eTopoTmpCC);
cWhichMax<cPt2di,tREAL8> aBestPInCC;
for (const auto & aPixCC : aVCC)
Expand Down Expand Up @@ -664,7 +662,6 @@ void cAppliCheckBoardTargetExtract::DoOneImageAndScale(tREAL8 aScale,const tIm
int aNbEllWCode = 0;
cAutoTimerSegm aTSEllipse(mTimeSegm,"Ellipse");
{
int aCpt=0;
for (const auto & aCdtRad : aVCdtRad)
{
std::vector<bool> TryCE = {false}; // Do we do the try in circle or ellipse mode
Expand All @@ -688,7 +685,6 @@ void cAppliCheckBoardTargetExtract::DoOneImageAndScale(tREAL8 aScale,const tIm
AddCdtE(aCDE);
}
}
aCpt++;
}
}

Expand Down
6 changes: 6 additions & 0 deletions MMVII/src/DenseMatch/EpipGenDenseMatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,12 @@ struct cParam1Match
/* */
/* ============================================== */

static std::string V1NameMasqOfIm(const std::string & aName)
{
return LastPrefix(aName) + "_Masq.tif";
}


std::string cOneLevel::StdFullName(const std::string & aName) const
{
return (mLevel==0) ?
Expand Down
2 changes: 1 addition & 1 deletion MMVII/src/Geom2D/Delaunay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ Delaunator::Delaunator(SafeVector<double> const& in_coords)

hull_start = i0;

size_t hull_size = 3;
[[maybe_unused]] size_t hull_size = 3;

hull_next[i0] = hull_prev[i2] = i1;
hull_next[i1] = hull_prev[i0] = i2;
Expand Down
4 changes: 0 additions & 4 deletions MMVII/src/Geom3D/cZBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,10 @@ cZBuffer::cZBuffer(cTri3DIterator & aMesh,const tSet & aSetIn,const tMap & aMap
cPt3dr aPIn;

mMesh.ResetAll();
int aCptTot=0;
int aCptIn=0;
while (mMesh.GetNextPoint(aPIn))
{
aCptTot++;
if (mSetIn.InsideWithBox(aPIn))
{
aCptIn++;
cPt3dr aPOut = mMapI2O.Value(aPIn);

if (mSetOut.InsideWithBox(aPOut))
Expand Down
2 changes: 1 addition & 1 deletion MMVII/src/Geoms/TilesIndexGeom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ void OneBenchSpatialIndex()
aVerif2.Add(aPt->GetPrimGeom(),aDistSegPt);
}

int aNbIn=0;
[[maybe_unused]] int aNbIn=0;
for (const auto & aPt : aLPt)
{
tREAL8 aDistSegPt = aSeg.Seg().DistClosedSeg(aPt) ;
Expand Down
19 changes: 7 additions & 12 deletions MMVII/src/ImagesBase/FileImages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ extern std::string MM3DFixeByMMVII; // Declared in MMV1 for its own stuff
namespace MMVII
{

// FIXME CM->MPD: A virer ? A mettre dans EpipGenDenseMatch ou ImageFilterMMV1 ?
std::string V1NameMasqOfIm(const std::string & aName)
{
return LastPrefix(aName) + "_Masq.tif";
}

#ifdef MMVII_KEEP_MMV1_IMAGE
static GenIm::type_el ToMMV1(eTyNums aV2)
Expand Down Expand Up @@ -172,7 +167,8 @@ cDataFileIm2D cDataFileIm2D::Create(const std::string & aName,eTyNums aType,con
{
MMVII_INTERNAL_ASSERT_strong(false,"Incoherent channel number");
}
cDataFileIm2D aDataFileIm2D(aName, aType, aSz, aNbChan, aOptions, eForceGray::No, eCreationState::Created);
// eCreationState::AtFirstWrite: If needed, file will be created with a null image and new state will be Created or CreatedNoUpdate
cDataFileIm2D aDataFileIm2D(aName, aType, aSz, aNbChan, aOptions, eForceGray::No, eCreationState::AtFirstWrite);
cGdalApi::CreateFileIfNeeded(aDataFileIm2D);
return aDataFileIm2D;
#ifdef MMVII_KEEP_MMV1_IMAGE
Expand All @@ -185,7 +181,6 @@ cDataFileIm2D cDataFileIm2D::Create(const std::string & aName,eTyNums aType,con
return Create(aName,aType,aSz,{},aNbChan);
}


cDataFileIm2D cDataFileIm2D::CreateOnWrite(const std::string & aName,eTyNums aType,const cPt2di & aSz, const tOptions& aOptions, int aNbChan)
{
if (aNbChan!=1 && aNbChan!=3)
Expand Down Expand Up @@ -228,9 +223,7 @@ void cDataFileIm2D::SetCreatedNoUpdate() const

bool cDataFileIm2D::IsPostFixNameImage(const std::string & aPost)
{
static std::vector<std::string> aVNames({"jpg","jpeg","tif","tiff"});

return UCaseMember(aVNames,aPost);
return cGdalApi::IsPostFixNameImage(aPost);
}

bool cDataFileIm2D::IsNameWith_PostFixImage(const std::string & aName)
Expand Down Expand Up @@ -467,13 +460,15 @@ template <class Type> void cIm2D<Type>::Write(const cDataFileIm2D & aFile,cons



// FIXME CM->MPD: check correctness
double DifAbsInVal(const std::string & aN1,const std::string & aN2,double aDef)
{
auto aIm1 = cIm2D<tREAL8>::FromFile(aN1);
auto aIm2 = cIm2D<tREAL8>::FromFile(aN2);
double aSom = 0;



// ELISE_COPY(aF1.all_pts(),Abs(aF1.in()-aF2.in()),sigma(aSom));

if (aIm1.DIm().Sz()!=aIm2.DIm().Sz())
{
MMVII_INTERNAL_ASSERT_always(aDef!=0.0,"Diff sz and bad def in DifAbsInVal");
Expand Down
54 changes: 41 additions & 13 deletions MMVII/src/ImagesBase/cGdalApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class cGdalApi {

static void InitGDAL();

static bool IsPostFixNameImage(const std::string& aPost);

static void GetFileInfo(const std::string& aName, eTyNums& aType, cPt2di& aSz, int& aNbChannel);
static void CreateFileIfNeeded(const cDataFileIm2D& aDataFileIm2D);

Expand Down Expand Up @@ -75,6 +77,8 @@ class cGdalApi {
// Avoid printing of error message => each API call must test and handle error case.
static void GdalErrorHandler(CPLErr aErrorCat, CPLErrorNum aErrorNum, const char *aMesg);
static GDALDriver* GetDriver(const std::string& aName);
static const std::map<std::string, std::string> &SupportedDrivers();
static bool GDalDriverCanCreate(GDALDriver *aGdalDriver);

static CPLStringList GetCreateOptions(GDALDriver* aGdalDriver, const cDataFileIm2D::tOptions& aOptions);

Expand Down Expand Up @@ -382,7 +386,6 @@ void cGdalApi::GetFileInfo(const std::string& aName, eTyNums& aType, cPt2di& aSz
}


// FIXME CM: rendre possible +ieurs ecriture pour un tiff meme avec CreateWriteOn (i.e. si GDAL_DCAP_CREATE est true)
GDALDataset* cGdalApi::CreateDataset(const cDataFileIm2D& aDataFileIm2D, bool *createdInMemory)
{
auto aName = aDataFileIm2D.Name();
Expand All @@ -395,10 +398,11 @@ GDALDataset* cGdalApi::CreateDataset(const cDataFileIm2D& aDataFileIm2D, bool *c
GDALDataset* aGdalDataset;
auto aGdalDriver = cGdalApi::GetDriver(aName);

// Determinine if we can create the file and then write to it
// or if we must use an intermiediate in memory image in GDAL format.
bool createFileNow = true;
if (aDataFileIm2D.IsCreateAtFirstWrite() || aDataFileIm2D.IsCreatedNoUpdate()) {
auto capabilityCreate = aGdalDriver->GetMetadataItem(GDAL_DCAP_CREATE);
createFileNow = (capabilityCreate != nullptr) && (strcmp(capabilityCreate,"YES") == 0);
createFileNow = GDalDriverCanCreate(aGdalDriver);
}

if (createFileNow) {
Expand All @@ -425,6 +429,7 @@ GDALDataset* cGdalApi::CreateDataset(const cDataFileIm2D& aDataFileIm2D, bool *c
void cGdalApi::CreateFileIfNeeded(const cDataFileIm2D& aDataFileIm2D)
{
InitGDAL();
MMVII_INTERNAL_ASSERT_always(aDataFileIm2D.IsCreateAtFirstWrite(),"GDAL: Invalid use of GDAL API for image file creation");
auto aName = aDataFileIm2D.Name();
auto aType = aDataFileIm2D.Type();
auto aSz = aDataFileIm2D.Sz();
Expand All @@ -434,18 +439,20 @@ void cGdalApi::CreateFileIfNeeded(const cDataFileIm2D& aDataFileIm2D)
cPt2di fileSz = cPt2di(aDataset->GetRasterXSize(), aDataset->GetRasterYSize());
auto fileNbChan = aDataset->GetRasterCount();
auto fileType = ToMMVII( aDataset->GetRasterBand( 1 )->GetRasterDataType());
auto aGdalDriver = aDataset->GetDriver();
CloseDataset(aDataset);
if (fileSz == aSz && fileNbChan == aNbChannel && fileType == aType) {
if (GDalDriverCanCreate(aGdalDriver)) {
aDataFileIm2D.SetCreated();
} else {
aDataFileIm2D.SetCreatedNoUpdate();
}
return; // No need to create
}
}
// aDataset is null here, no need to close it

// Create the file
aDataset = CreateDataset(aDataFileIm2D, nullptr);
CloseDataset(aDataset);
// aDataset is either null here either already closed, no need to close it

// Init the image file with a blank image
// Create and Init the image file with a blank image
cIm2D<tU_INT1> anEmptyImg(aSz,nullptr,eModeInitImage::eMIA_Null);
cGdalApi::ReadWrite(IoMode::Write,anEmptyImg.DIm(),aDataFileIm2D,cPt2di(0,0),1,cRect2::TheEmptyBox);
}
Expand Down Expand Up @@ -604,9 +611,10 @@ void cGdalApi::CloseDataset(GDALDataset *aGdalDataset)
GDALClose(GDALDataset::ToHandle(aGdalDataset));
}

GDALDriver* cGdalApi::GetDriver(const std::string& aName)

const std::map<std::string, std::string> &cGdalApi::SupportedDrivers()
{
static std::map<std::string, std::string> DriverNames = {
static std::map<std::string, std::string> cSupportedDrivers= {
{"tif", "GTiff"},
{"tiff", "GTiff"},
{"dng", "GTiff"},
Expand All @@ -618,9 +626,22 @@ GDALDriver* cGdalApi::GetDriver(const std::string& aName)
{"pnm","PNM"},
{"gif","GIF"},
};
return cSupportedDrivers;
}

bool cGdalApi::IsPostFixNameImage(const std::string &aPost)
{
const auto aDriverList = SupportedDrivers();
auto aDriverIt = aDriverList.find(ToLower(aPost));
return aDriverIt != aDriverList.end();
}


auto aDriverIt = DriverNames.find(ToLower(LastPostfix(aName,'.')));
if (aDriverIt == DriverNames.end())
GDALDriver* cGdalApi::GetDriver(const std::string& aName)
{
const auto aDriverList = SupportedDrivers();
auto aDriverIt = aDriverList.find(ToLower(LastPostfix(aName,'.')));
if (aDriverIt == aDriverList.end())
{
MMVII_INTERNAL_ERROR("MMVIITOGDal: Unsupported image format for " + aName);
return nullptr; // never happens
Expand All @@ -635,6 +656,13 @@ GDALDriver* cGdalApi::GetDriver(const std::string& aName)
}


bool cGdalApi::GDalDriverCanCreate(GDALDriver* aGdalDriver)
{
auto capabilityCreate = aGdalDriver->GetMetadataItem(GDAL_DCAP_CREATE);
return (capabilityCreate != nullptr) && (strcmp(capabilityCreate,"YES") == 0);
}



} // namespace MMVII

Expand Down
4 changes: 0 additions & 4 deletions MMVII/src/ImagesInfoExtract/InfoPonctuelles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ double CubGaussWeightStandardDev(const cDataIm2D<Type> &anIm,const cPt2di& aC,d
double aSqRad = Square(aRadius);
cUB_ComputeStdDev<1> aCSD;

int aNbOk = 0;


for (const auto & aDP : aDBox)
{
double aN2 = SqN2(aDP); // Square norm of displacement
Expand All @@ -23,7 +20,6 @@ double CubGaussWeightStandardDev(const cDataIm2D<Type> &anIm,const cPt2di& aC,d
cPt2di aP = aC + aDP;
if (anIm.Inside(aP))
{
aNbOk++;
double aRatio = std::sqrt(aN2) / aRadius;
double aWeight = CubAppGaussVal(aRatio);
double aVal = anIm.GetV(aP);
Expand Down
2 changes: 0 additions & 2 deletions MMVII/src/ImagesInfoExtract/cAppliExtractLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -510,14 +510,12 @@ void cAppliExtractLine::MakeVisu(const std::string & aNameIm)
if (mGenVisu>=3)
{
cRGBImage aVisAccum = RGBImFromGray(aDAccum,255.0/aVMax);
int aK=0;
for (const auto & aPS : mVPS)
{
//aVisAccum.SetRGBrectWithAlpha(ToI(aPS->IndTetaRho()) ,15,cRGBImage::Red,0.5);
cPt2dr aC=aPS.IndTetaRho();
cPt2dr aSz(7,7);
aVisAccum.FillRectangle(cRGBImage::Red,ToI(aC-aSz),ToI(aC+aSz),cPt3dr(0.5,1.0,1.0));
aK++;
}
aVisAccum.ToJpgFileDeZoom(mPhProj.DirVisuAppli() + "Accum_" + aNameTif,1);
aDAccum.ToFile(mPhProj.DirVisuAppli() + "RawAccum_" + aNameTif);
Expand Down
1 change: 0 additions & 1 deletion MMVII/src/ImagesInfoExtract/cHoughTransform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ void ShowImProfile(const cDataIm1D<tREAL8> & anIm,const std::string & aName)
void cParalLine::ComputeRadiomHomog(const cDataGenUnTypedIm<2> & anIm,cPerspCamIntrCalib * aCalib,const std::string & aNameFile)
{
// StdOut() << "aNameFileaNameFileaNameFileaNameFile " << aNameFile << "\n";
static int aCPT=0; aCPT++;

cSegment2DCompiled<tREAL8> aSegFull = aCalib->ExtenSegUndistIncluded(false,mMidleSeg,0.05,1.0,5.0);

Expand Down
Loading

0 comments on commit 77cdfb5

Please sign in to comment.