Skip to content

Commit

Permalink
MMVII: Use GDAL to read/write image files
Browse files Browse the repository at this point in the history
Set MMVII_USE_MMV1_IMAGE environment var to fallback to legacy read/write
(i.e. use micmac v1)

Co-authored-by: Celestin Huet <[email protected]>
  • Loading branch information
meynardc and CelestinHuet committed Nov 14, 2024
1 parent 40b003e commit 7586b51
Show file tree
Hide file tree
Showing 11 changed files with 978 additions and 496 deletions.
15 changes: 12 additions & 3 deletions .github/workflows/build_mmvii.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Install Qt and clang
run: |
sudo apt update
sudo apt install qtbase5-dev clang-14
sudo apt install qtbase5-dev clang-14 libgdal-dev
- name: Install libproj
run: sudo apt install libproj-dev proj-data
Expand Down Expand Up @@ -85,8 +85,8 @@ jobs:
with:
auto-update-conda: true

- name: Install PROJ with miniconda
run: conda install -y proj
- name: Install GDAL,PROJ with miniconda
run: conda install -y proj gdal
if: steps.cache-conda-gdal.outputs.cache-hit != 'true'

- name: Install Qt
Expand Down Expand Up @@ -144,7 +144,16 @@ jobs:
MM3D_BINDIR=$(pwd)/micmac/bin
cp ${Qt5_Dir}/plugins/platforms/qwindows.dll ${MMVII_BINDIR}/platforms/
cd /C/Miniconda/envs/test/Library/bin/
# dll for PROJ
cp deflate.dll Lerc.dll libcrypto-3-x64.dll libcurl.dll liblzma.dll libssh2.dll proj_9_3.dll sqlite3.dll tiff.dll zlib.dll zstd.dll ${MMVII_BINDIR}/
# dll for GDAL (CGDAL require PROJ too)
cp blosc.dll cfitsio.dll charset.dll comerr64.dll freetype.dll freexl.dll gdal.dll geos.dll geos_c.dll geotiff.dll gssapi64.dll ${MMVII_BINDIR}/
cp hdf.dll hdf5.dll hdf5_cpp.dll hdf5_hl.dll ${MMVII_BINDIR}/
cp iconv.dll k5sprt64.dll krb5_64.dll lcms2.dll libbz2.dll libexpat.dll libkea.dll liblz4.dll libminizip.dll libpng16.dll ${MMVII_BINDIR}/
cp libpq.dll libsharpyuv.dll libssl-3-x64.dll libwebp.dll libxml2.dll ${MMVII_BINDIR}/
cp mfhdf.dll netcdf.dll openjp2.dll pcre2-8.dll poppler.dll spatialite.dll tiledb.dll xdr.dll xerces-c_3_2.dll zip.dll ${MMVII_BINDIR}/
cd $Qt5_Dir/bin
cp Qt5Core.dll Qt5Gui.dll Qt5Xml.dll Qt5OpenGL.dll Qt5Widgets.dll ${MM3D_BINDIR}/
cd $Qt5_Dir/plugins
Expand Down
11 changes: 9 additions & 2 deletions MMVII/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ if (PROJ_FOUND AND CMAKE_HOST_WIN32)
file(COPY ${PROJ_PROJ_DB_FILE} DESTINATION ${MMVII_SOURCE_DIR}/share/proj)
endif()

# GDAL
find_package(GDAL 3.4 REQUIRED)

# Threads
set(THREADS_PREFER_PTHREAD_FLAG ON)
Expand Down Expand Up @@ -129,14 +131,19 @@ file(GLOB mmv2_headers "${mmv2_include_dir}/*.h" "${mmv2_include_dir}/*/*.h" "${
## libP2007 buid (MMVII library)
#######################################################
add_library(P2007 "${mmv2_libsrcs}" "${mmv2_headers}")
target_include_directories(P2007 PRIVATE "${mmv2_include_dir};${mmv1_include_dir};${EIGEN3_INCLUDE_PATH};${PROJ_INCLUDE_DIRS}")
target_link_libraries(P2007 PRIVATE MMVII_compiler_flags Threads::Threads ${PROJ_LIBRARIES})
target_include_directories(P2007 PRIVATE "${mmv2_include_dir};${mmv1_include_dir};${EIGEN3_INCLUDE_PATH};${PROJ_INCLUDE_DIRS};${GDAL_INCLUDE_DIRS}")
target_link_libraries(P2007 PRIVATE MMVII_compiler_flags Threads::Threads ${PROJ_LIBRARIES} ${GDAL_LIBRARIES})

# Force parallel compilation with MSVC
if(MSVC)
target_compile_options(P2007 PRIVATE "/MP")
endif()

option(MMVII_KEEP_MMV1_IMAGE "If OFF, MMVII will use GDAL only to read/write image" ON)
if(MMVII_KEEP_MMV1_IMAGE)
target_compile_definitions(P2007 PUBLIC MMVII_KEEP_MMV1_IMAGE)
endif()

#######################################################
## MMVII build (executable)
#######################################################
Expand Down
3 changes: 2 additions & 1 deletion MMVII/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Some external tools need to be present on your system for **MMVII** to run prope
- **[make](http://www.gnu.org/software/make)** for parallel processes management
- **[PROJ](http://trac.osgeo.org/proj/)** for coordinate system conversion and coordinate reference system transformation
- **[PROJ additional data](https://download.osgeo.org/proj/)** grids for coordinates tranformations (optional, see doc)
- **[GDAL](https://gdal.org/)** for image files handling
- **[ccache](https://ccache.dev/)** for recompilation optimization (optional)
- **[OpenMP](https://www.openmp.org/)** multi-platform parallel programming (optionnal)
- **[Doxygen](https://www.doxygen.nl/)** documentation generator (optional)
Expand All @@ -52,7 +53,7 @@ Under Linux (Ubuntu) distribution the installation procedure is as follows:

- Install dependancies specific to MMVII:
```bash
sudo apt install pkg-config libproj-dev
sudo apt install pkg-config libproj-dev libgdal-dev
```

- Access the folder:
Expand Down
2 changes: 1 addition & 1 deletion MMVII/include/MMVII_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ std::string Postfix(const std::string & aStr,char aSep='.',bool SVP=false,bool P
std::string LastPostfix(const std::string & aStr,char aSep='.'); ///< No error: a=> "" a.b.c => "c"

bool starts_with(const std::string & aFullStr,const std::string & aBegining); /// as c++20 std::string.starts_with
bool ends_with(const std::string & aFullStr,const std::string & aEnding); /// as c++20 std::string.starts_with TO IMPLEMENT
bool ends_with(const std::string & aFullStr,const std::string & aEnding); /// as c++20 std::string.ends_with
bool contains(const std::string & aFullStr,const std::string & aEnding); /// as c++23 std::string.contains TO IMPLEMENT
bool contains(const std::string & aFullStr,char); /// does the string contain the char (use find)

Expand Down
8 changes: 3 additions & 5 deletions MMVII/include/V1VII.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,14 @@ template <class Type> std::string ToStrComMMV1(const cTplBox<Type,2> & aBox)



GenIm::type_el ToMMV1(eTyNums aV2);
eTyNums ToMMVII( GenIm::type_el );

void ExportHomMMV1(const std::string & aIm1,const std::string & aIm2,const std::string & SH,const std::vector<cPt2di> & aVP);
void ExportHomMMV1(const std::string & aIm1,const std::string & aIm2,const std::string & SH,const std::vector<cPt2dr> & aVP);

void MakeStdIm8BIts(cIm2D<tREAL4> aImIn,const std::string& aName);




//FIXME CM->MPD: Must replace cMMV1_Conv::ImToMMV1
template <class Type> class cMMV1_Conv
{
public :
Expand All @@ -55,7 +52,7 @@ template <class Type> class cMMV1_Conv
return tImMMV1(aDL,nullptr,aImV2.Sz().x(),aImV2.Sz().y());
};


#ifdef MMVII_KEEP_MMV1_IMAGE
// For gray level
static void ReadWrite(bool ReadMode,const tImMMVII &aImV2,const cDataFileIm2D & aDF,const cPt2di & aP0File,double aDyn,const cRect2& aR2Init);

Expand All @@ -64,6 +61,7 @@ template <class Type> class cMMV1_Conv
private :
// Generik function, real implemantation
static void ReadWrite(bool ReadMode,const std::vector<const tImMMVII*>& ,const cDataFileIm2D &aDF,const cPt2di & aP0File,double aDyn,const cRect2& aR2Init);
#endif
};

std::string V1NameMasqOfIm(const std::string & aName);
Expand Down
Loading

0 comments on commit 7586b51

Please sign in to comment.