CPPxDIC
C++ Digital Image Correlation library for fingertip 3D reconstruction
Loading...
Searching...
No Matches
cppxdic::MatWriter Class Reference

MatWriter class Provides utilities for writing MAT files with proper xDIC structure. More...

#include <mat_writer.h>

Static Public Member Functions

static bool writeMatchingFile (const std::string &filename, const cv::Mat &ref_img, const cv::Mat &cur_img, const cv::Mat &ref_roi, const cv::Mat &cur_roi, const ncorr::DIC_analysis_output &dic_output, const std::map< std::string, double > &dispinfo)
 Write MATCHING2xxx_pair.mat file Structure:
 
static bool writeMatchingFile (const std::string &filename, const cv::Mat &ref_img, const cv::Mat &cur_img, const cv::Mat &ref_roi, const cv::Mat &cur_roi, const ncorr::DIC_analysis_output &dic_lagrangian, const ncorr::DIC_analysis_output &dic_eulerian, const std::map< std::string, double > &dispinfo)
 Write MATCHING2xxx_pair.mat file with both Lagrangian and Eulerian perspectives.
 
static bool writeROIMaskFile (const std::string &filename, const cv::Mat &mask)
 Write REF_MASK_xxx_phase_pairX.mat file Simple structure: refmask (uint8 2D array)
 
static bool writeSeedFile (const std::string &filename, int seed_x, int seed_y)
 Write REF_SEED_xxx_phase_pairX.mat file Simple structure: seed_point (uint16 1D array [x, y])
 
static bool writeTrialInfoFile (const std::string &filename, double fps, const std::vector< int > &frame_indices)
 Write dic_info_data_target_pairX.mat file Structure:
 
static bool writeMultiFrameNcorrFile (const std::string &filename, const cv::Mat &ref_img, const std::vector< cv::Mat > &cur_imgs, const cv::Mat &ref_roi, const std::vector< cv::Mat > &cur_rois, const std::vector< ncorr::DIC_analysis_output > &dic_outputs, const std::map< std::string, double > &dispinfo, const std::string &type_str="load", const std::string &ref_name="reference")
 Write multi-frame ncorr files (ncorr1.mat, ncorr2.mat, etc.) For tracking DIC with multiple current frames.
 
static bool writeDICResultFile (const std::string &filename, const ncorr::DIC_analysis_input &dic_input, const ncorr::DIC_analysis_output &dic_output)
 Write ncorr1.mat / ncorr2.mat / ncorr12.mat files Full DIC results with dispinfo and displacements Structure matches xDIC output format with:
 
static bool convertBinToMat (const std::string &bin_path, const std::string &mat_path, const ncorr::DIC_analysis_input &dic_input)
 Convert ncorr .bin output to .mat format Wrapper to load .bin and save as MATLAB-compatible .mat.
 
static bool writeDIC2DPairResults (const std::string &filename, const DIC2DPairResults &results)
 Write myDIC2DpairResults_C_X_C_Y.mat file Contains processed 2D DIC results with triangulation.
 
static bool write3DCombinedResults (const std::string &filename, const DIC3Dcombined &combined, const std::string &struct_name="DIC3Dcombined")
 Write DIC3Dcombined_XPairs_stitched.mat file Contains 3D reconstruction results.
 
static matvar_t * buildCombinedStructFields (mat_t *matfp, const DIC3Dcombined &combined, const std::string &struct_name, const std::vector< std::string > &extra_fields={})
 Build combined struct fields as a matvar_t* (for embedding in parent struct) Does NOT write to file.
 
static bool write3DPPresults (const std::string &filename, const DIC3DPPresults &ppresults)
 Write DIC3DPPresults_XPairs_Y_v1.mat file Contains deformation and strain analysis results.
 
static bool writeDeformationGroup (mat_t *matfp, const std::string &group_name, const FrameDeformationResult &deform_data)
 Write deformation fields to HDF5 group Writes all 36 deformation measures as cell arrays.
 
static matvar_t * buildDeformationStruct (const std::string &group_name, const FrameDeformationResult &deform_data)
 Build deformation struct as matvar_t* for embedding in parent struct Does NOT write to file.
 
static bool writeDisplacementGroup (mat_t *matfp, const std::vector< std::vector< Eigen::Vector3d > > &disp_vec, const std::vector< std::vector< double > > &disp_mgn, size_t n_frames)
 Write displacement group (DispVec, DispMgn)
 
static bool writeFaceArrays (mat_t *matfp, const std::vector< std::vector< Eigen::Vector3d > > &face_centroids, const std::vector< std::vector< double > > &face_corr_comb, const std::vector< std::vector< double > > &face_iso_ind, size_t n_frames)
 Write face-based cell arrays (FaceCentroids, FaceCorrComb, FaceIsoInd)
 
static bool writeCalibrationGroup (mat_t *matfp, const CalibrationData &calibration)
 Write calibration group (DLTparameters, DLTpath)
 
static bool writeDistortionGroup (mat_t *matfp, const DistortionData &distortion)
 Write distortion group (distortionModel, distortionPath)
 
static matvar_t * buildAllPairsResultsVar (const std::vector< DIC3DpairResults > &all_pairs)
 Build the AllPairsResults cell array (full DIC3DpairResults structs) purely in memory — the caller attaches it to a struct and owns it.
 
static matvar_t * buildDIC2DinfoVar (const std::vector< DIC2DPairResults > &dic2d_info)
 Build the DIC2Dinfo cell array of DIC2DPairResults purely in memory — the caller attaches it to a struct and owns it.
 

Detailed Description

MatWriter class Provides utilities for writing MAT files with proper xDIC structure.

Definition at line 26 of file mat_writer.h.

Member Function Documentation

◆ buildAllPairsResultsVar()

matvar_t * cppxdic::MatWriter::buildAllPairsResultsVar ( const std::vector< DIC3DpairResults > &  all_pairs)
static

Build the AllPairsResults cell array (full DIC3DpairResults structs) purely in memory — the caller attaches it to a struct and owns it.

Parameters
all_pairsVector of DIC3DpairResults (individual pair results)
Returns
New matvar (caller owns), or nullptr when empty/failed

Definition at line 2023 of file mat_writer.cpp.

◆ buildCombinedStructFields()

matvar_t * cppxdic::MatWriter::buildCombinedStructFields ( mat_t *  matfp,
const DIC3Dcombined &  combined,
const std::string &  struct_name,
const std::vector< std::string > &  extra_fields = {} 
)
static

Build combined struct fields as a matvar_t* (for embedding in parent struct) Does NOT write to file.

Caller is responsible for writing and freeing.

Parameters
matfpMAT file pointer (needed for AllPairsResults/DIC2Dinfo)
combined3D combined results structure
struct_nameName of the wrapping struct
extra_fieldsAdditional field names to add to the struct
Returns
matvar_t* struct with all fields populated (caller must write+free)

Definition at line 1331 of file mat_writer.cpp.

◆ buildDeformationStruct()

matvar_t * cppxdic::MatWriter::buildDeformationStruct ( const std::string &  group_name,
const FrameDeformationResult &  deform_data 
)
static

Build deformation struct as matvar_t* for embedding in parent struct Does NOT write to file.

Caller owns the returned pointer.

Definition at line 1651 of file mat_writer.cpp.

◆ buildDIC2DinfoVar()

matvar_t * cppxdic::MatWriter::buildDIC2DinfoVar ( const std::vector< DIC2DPairResults > &  dic2d_info)
static

Build the DIC2Dinfo cell array of DIC2DPairResults purely in memory — the caller attaches it to a struct and owns it.

Parameters
dic2d_infoVector of 2D DIC results
Returns
New matvar (caller owns), or nullptr when empty/failed

Definition at line 2289 of file mat_writer.cpp.

◆ convertBinToMat()

bool cppxdic::MatWriter::convertBinToMat ( const std::string &  bin_path,
const std::string &  mat_path,
const ncorr::DIC_analysis_input &  dic_input 
)
static

Convert ncorr .bin output to .mat format Wrapper to load .bin and save as MATLAB-compatible .mat.

Parameters
bin_pathPath to .bin file
mat_pathOutput .mat file path
dic_inputDIC input parameters
Returns
Success status

Definition at line 1104 of file mat_writer.cpp.

◆ write3DCombinedResults()

bool cppxdic::MatWriter::write3DCombinedResults ( const std::string &  filename,
const DIC3Dcombined &  combined,
const std::string &  struct_name = "DIC3Dcombined" 
)
static

Write DIC3Dcombined_XPairs_stitched.mat file Contains 3D reconstruction results.

Parameters
filenameOutput MAT filename
combined3D combined results structure
Returns
Success status

Definition at line 1566 of file mat_writer.cpp.

◆ write3DPPresults()

bool cppxdic::MatWriter::write3DPPresults ( const std::string &  filename,
const DIC3DPPresults &  ppresults 
)
static

Write DIC3DPPresults_XPairs_Y_v1.mat file Contains deformation and strain analysis results.

Parameters
filenameOutput MAT filename
ppresultsPost-processing results structure
Returns
Success status

Definition at line 1588 of file mat_writer.cpp.

◆ writeCalibrationGroup()

bool cppxdic::MatWriter::writeCalibrationGroup ( mat_t *  matfp,
const CalibrationData &  calibration 
)
static

Write calibration group (DLTparameters, DLTpath)

Parameters
matfpMAT file pointer (must be open for writing)
calibrationCalibration data structure
Returns
Success status

Definition at line 1906 of file mat_writer.cpp.

◆ writeDeformationGroup()

bool cppxdic::MatWriter::writeDeformationGroup ( mat_t *  matfp,
const std::string &  group_name,
const FrameDeformationResult &  deform_data 
)
static

Write deformation fields to HDF5 group Writes all 36 deformation measures as cell arrays.

Parameters
matfpMAT file pointer (must be open for writing)
group_nameName of the group (e.g., "Deform")
deform_dataFrame-based deformation results
Returns
Success status

Definition at line 1797 of file mat_writer.cpp.

◆ writeDIC2DPairResults()

bool cppxdic::MatWriter::writeDIC2DPairResults ( const std::string &  filename,
const DIC2DPairResults &  results 
)
static

Write myDIC2DpairResults_C_X_C_Y.mat file Contains processed 2D DIC results with triangulation.

Parameters
filenameOutput MAT filename
resultsDIC 2D pair results structure
Returns
Success status

Definition at line 1126 of file mat_writer.cpp.

◆ writeDICResultFile()

bool cppxdic::MatWriter::writeDICResultFile ( const std::string &  filename,
const ncorr::DIC_analysis_input &  dic_input,
const ncorr::DIC_analysis_output &  dic_output 
)
static

Write ncorr1.mat / ncorr2.mat / ncorr12.mat files Full DIC results with dispinfo and displacements Structure matches xDIC output format with:

  • input (DIC parameters)
  • output (displacement fields, correlation coefficients)
Parameters
filenameOutput MAT filename
dic_inputDIC analysis input parameters
dic_outputDIC analysis output
Returns
Success status

Definition at line 466 of file mat_writer.cpp.

◆ writeDisplacementGroup()

bool cppxdic::MatWriter::writeDisplacementGroup ( mat_t *  matfp,
const std::vector< std::vector< Eigen::Vector3d > > &  disp_vec,
const std::vector< std::vector< double > > &  disp_mgn,
size_t  n_frames 
)
static

Write displacement group (DispVec, DispMgn)

Parameters
matfpMAT file pointer (must be open for writing)
disp_vecDisplacement vectors per frame (Nx3 per frame)
disp_mgnDisplacement magnitudes per frame (Nx1 per frame)
n_framesNumber of frames
Returns
Success status

Definition at line 1818 of file mat_writer.cpp.

◆ writeDistortionGroup()

bool cppxdic::MatWriter::writeDistortionGroup ( mat_t *  matfp,
const DistortionData &  distortion 
)
static

Write distortion group (distortionModel, distortionPath)

Parameters
matfpMAT file pointer (must be open for writing)
distortionDistortion data structure
Returns
Success status

Definition at line 1961 of file mat_writer.cpp.

◆ writeFaceArrays()

bool cppxdic::MatWriter::writeFaceArrays ( mat_t *  matfp,
const std::vector< std::vector< Eigen::Vector3d > > &  face_centroids,
const std::vector< std::vector< double > > &  face_corr_comb,
const std::vector< std::vector< double > > &  face_iso_ind,
size_t  n_frames 
)
static

Write face-based cell arrays (FaceCentroids, FaceCorrComb, FaceIsoInd)

Parameters
matfpMAT file pointer (must be open for writing)
face_centroidsFace centroids per frame (Mx3 per frame)
face_corr_combFace correlation coefficients per frame (Mx1 per frame)
face_iso_indFace isotropy indices per frame (Mx1 per frame)
n_framesNumber of frames
Returns
Success status

Definition at line 1856 of file mat_writer.cpp.

◆ writeMatchingFile() [1/2]

bool cppxdic::MatWriter::writeMatchingFile ( const std::string &  filename,
const cv::Mat &  ref_img,
const cv::Mat &  cur_img,
const cv::Mat &  ref_roi,
const cv::Mat &  cur_roi,
const ncorr::DIC_analysis_output &  dic_lagrangian,
const ncorr::DIC_analysis_output &  dic_eulerian,
const std::map< std::string, double > &  dispinfo 
)
static

Write MATCHING2xxx_pair.mat file with both Lagrangian and Eulerian perspectives.

Parameters
filenameOutput MAT filename
ref_imgReference image
cur_imgCurrent image
ref_roiReference ROI
cur_roiCurrent ROI
dic_lagrangianLagrangian (reference) DIC output
dic_eulerianEulerian (current) DIC output
dispinfoDIC parameters
Returns
Success status

Definition at line 53 of file mat_writer.cpp.

◆ writeMatchingFile() [2/2]

bool cppxdic::MatWriter::writeMatchingFile ( const std::string &  filename,
const cv::Mat &  ref_img,
const cv::Mat &  cur_img,
const cv::Mat &  ref_roi,
const cv::Mat &  cur_roi,
const ncorr::DIC_analysis_output &  dic_output,
const std::map< std::string, double > &  dispinfo 
)
static

Write MATCHING2xxx_pair.mat file Structure:

  • current_save (group)
    • gs, name, path, roi, type
  • data_dic_save (group)
    • dispinfo, displacements, straininfo, strains
  • reference_save (group)
    • gs, name, path, roi, type
Parameters
filenameOutput MAT filename
ref_imgReference image
cur_imgCurrent image
ref_roiReference ROI
cur_roiCurrent ROI
dic_outputDIC analysis output
dispinfoDIC parameters
Returns
Success status

Definition at line 30 of file mat_writer.cpp.

◆ writeMultiFrameNcorrFile()

bool cppxdic::MatWriter::writeMultiFrameNcorrFile ( const std::string &  filename,
const cv::Mat &  ref_img,
const std::vector< cv::Mat > &  cur_imgs,
const cv::Mat &  ref_roi,
const std::vector< cv::Mat > &  cur_rois,
const std::vector< ncorr::DIC_analysis_output > &  dic_outputs,
const std::map< std::string, double > &  dispinfo,
const std::string &  type_str = "load",
const std::string &  ref_name = "reference" 
)
static

Write multi-frame ncorr files (ncorr1.mat, ncorr2.mat, etc.) For tracking DIC with multiple current frames.

Parameters
filenameOutput MAT filename
ref_imgReference image
cur_imgsVector of current images (one per frame)
ref_roiReference ROI
cur_roisVector of current ROIs (one per frame)
dic_outputsVector of DIC outputs (one per frame)
dispinfoDIC parameters
type_strType string for all frames (default: "load")
ref_nameReference image name (default: "reference")
Returns
Success status

Definition at line 188 of file mat_writer.cpp.

◆ writeROIMaskFile()

bool cppxdic::MatWriter::writeROIMaskFile ( const std::string &  filename,
const cv::Mat &  mask 
)
static

Write REF_MASK_xxx_phase_pairX.mat file Simple structure: refmask (uint8 2D array)

Parameters
filenameOutput MAT filename
maskROI mask
Returns
Success status

Definition at line 405 of file mat_writer.cpp.

◆ writeSeedFile()

bool cppxdic::MatWriter::writeSeedFile ( const std::string &  filename,
int  seed_x,
int  seed_y 
)
static

Write REF_SEED_xxx_phase_pairX.mat file Simple structure: seed_point (uint16 1D array [x, y])

Parameters
filenameOutput MAT filename
seed_xX coordinate
seed_yY coordinate
Returns
Success status

Definition at line 420 of file mat_writer.cpp.

◆ writeTrialInfoFile()

bool cppxdic::MatWriter::writeTrialInfoFile ( const std::string &  filename,
double  fps,
const std::vector< int > &  frame_indices 
)
static

Write dic_info_data_target_pairX.mat file Structure:

  • actual_fps_meas (int)
  • idxframe (uint8 1D array)
Parameters
filenameOutput MAT filename
fpsFPS value
frame_indicesFrame indices
Returns
Success status

Definition at line 440 of file mat_writer.cpp.


The documentation for this class was generated from the following files: