CPPxDIC
C++ Digital Image Correlation library for fingertip 3D reconstruction
Loading...
Searching...
No Matches
dic_structures.h
Go to the documentation of this file.
1
6#ifndef DIC_STRUCTURES_H
7#define DIC_STRUCTURES_H
8
9#include <opencv2/opencv.hpp>
10#include <vector>
11#include <string>
12#include <map>
13#include "strain_computation.h" // For FrameDeformationResult
14
15namespace cppxdic {
16
21 bool enabled; // high_strain_analysis
22 std::string type; // seed_propagation type
23 bool auto_update; // auto_ref_change
24 int step; // step_ref_change
25
27 enabled(true), type("seed"),
28 auto_update(true), step(10) {}
29};
30
35struct DICInfo {
36 std::vector<double> cutoff_corrcoef; // Array of cutoff values (301 elements)
39 std::vector<std::string> imgcorr; // Cell array of image names (length 2)
41 double pixtounits; // Pixels to units conversion
42 int radius;
44 StepAnalysisInfo stepanalysis; // Step analysis parameters
47 std::string type;
48 std::string units;
49};
50
54struct Points2D {
55 std::vector<double> x; // X coordinates
56 std::vector<double> y; // Y coordinates
57};
58
63 std::vector<double> x; // X coordinates
64 std::vector<double> y; // Y coordinates
65 std::vector<double> z; // Z coordinates
66};
67
71struct DispData {
72 std::vector<std::vector<double>> DispVec; // Displacement vectors per frame
73 std::vector<std::vector<double>> DispMgn; // Displacement magnitudes per frame
74};
75
80 // 2x2 arrays for stereo pairs (rows=cameras, cols=pairs)
81 std::vector<std::vector<std::string>> DLT_paths; // 2x2 cell array of paths
82 std::vector<std::vector<std::vector<double>>> DLT_params; // 2x2 cell array of parameter vectors
83};
84
90 int nCamRef; // Reference camera number
91 int nCamDef; // Deformed camera number
92 int nImages; // Number of images
93 std::vector<int> pairOrder; // Trial-level stitch order metadata
94 bool pairForced = false; // Trial-level forced-stitch metadata
95 cv::Mat ROImask; // ROI mask
96 DICInfo ncorrInfo; // DIC parameters
97 std::vector<Points2D> Points; // Points per frame (cell array in MATLAB: each cell is Nx2 array)
98 std::vector<std::vector<double>> CorCoeffVec; // Correlation coefficients per frame (cell array: each cell is Nx1 array)
99 std::vector<int> Faces; // Triangular mesh faces (Nx3 flattened)
100 std::vector<double> FaceColors; // Face color values
101};
102
107 // 2x2 arrays for stereo pairs (rows=cameras, cols=pairs)
108 std::vector<std::vector<std::string>> distortion_models; // 2x2 cell array of model names
109 std::vector<std::vector<std::string>> distortion_paths; // 2x2 cell array of paths
110};
111
118 std::vector<int> cameraPairInd; // [cam1, cam2] - Camera pair indices
119
120 // Calibration for this pair (2x1 cell arrays)
121 std::vector<std::string> DLTpath; // {path_cam1, path_cam2}
122 std::vector<std::vector<double>> DLTparameters; // {L1, L2}
123
124 // Distortion for this pair (2x1 cell arrays)
125 std::vector<std::string> distortionModel; // {model_cam1, model_cam2}
126 std::vector<std::string> distortionPath; // {path_cam1, path_cam2}
127
128 // Geometry
129 std::vector<int> Faces; // Triangle connectivity (3 x nFaces flattened)
130 std::vector<double> FaceColors; // Face colors (1 x nFaces)
131
132 // Per-frame data (cell arrays nImages x 1)
133 std::vector<Point3DFrame> Points3D; // 3D points per frame
134 DispData Disp; // DispVec, DispMgn per frame
135 std::vector<std::vector<double>> FaceCentroids; // Face centroids per frame (nFrames x (nFaces*3))
136 std::vector<std::vector<double>> corrComb; // Combined correlation per frame
137 std::vector<std::vector<double>> FaceCorrComb; // Face correlation per frame
138};
139
146 std::vector<int> pairIndices; // Camera pair indices
147 std::vector<Point3DFrame> Points3D; // 3D points per frame (cell array in MATLAB)
148 std::vector<int> Faces; // Triangular mesh faces (Nx3 flattened)
149 std::vector<double> FaceColors; // Face colors
150 std::vector<std::vector<double>> corrComb; // Combined correlation coefficients per frame
151 std::vector<std::vector<double>> FaceCorrComb; // Face correlation coefficients per frame
152 std::vector<std::vector<double>> FaceCentroids; // Triangle centroids per frame (nFrames x nFaces x 3)
153 DispData Disp; // Displacement data
154 CalibrationData calibration; // Calibration info
155 DistortionData distortion; // Distortion model and paths
156
157 // Multi-pair stitching metadata
158 std::vector<int> FacePairInds; // Which stereo pair each face belongs to (1-indexed)
159 std::vector<int> PointPairInds; // Which stereo pair each point belongs to (1-indexed)
160
161 // Original DIC 2D info (cell array nPairs x 1)
162 std::vector<DIC2DPairResults> DIC2Dinfo;
163
164 // Individual pair results before stitching (cell array 1 x nPairs)
165 std::vector<DIC3DpairResults> AllPairsResults;
166
167 // Binary serialization methods
168 void saveBinary(const std::string& filepath) const;
169 static DIC3Dcombined loadBinary(const std::string& filepath);
170};
171
176 std::vector<double> F11, F12, F13;
177 std::vector<double> F21, F22, F23;
178 std::vector<double> F31, F32, F33;
179};
180
185 std::vector<double> E11, E12, E13;
186 std::vector<double> E21, E22, E23;
187 std::vector<double> E31, E32, E33;
188};
189
194 std::vector<DeformGradient> F; // Deformation gradients per frame
195 std::vector<StrainTensor> strain; // Strain tensors per frame (Green-Lagrange)
196 std::vector<std::vector<double>> princStrain; // Principal strains per frame
197 std::vector<std::vector<double>> maxShearStrain; // Max shear strain per frame
198};
199
203struct RBMData {
204 std::vector<std::vector<double>> RotMat; // Rotation matrices per frame (9 values each)
205 std::vector<std::vector<double>> TransVec; // Translation vectors per frame (3 values each)
206};
207
213 DeformData Deform; // Deformation and strain data (with RBM) - simplified format
214 DeformData Deform_ARBM; // Deformation and strain data after RBM removal
215 RBMData RBM; // Rigid body motion transformation data
216 std::vector<std::vector<double>> Points3D_ARBM_x; // 3D points after RBM per frame
217 std::vector<std::vector<double>> Points3D_ARBM_y;
218 std::vector<std::vector<double>> Points3D_ARBM_z;
219 std::vector<std::vector<double>> FaceIsoInd; // Face isotropy index per frame
220 std::string deftype; // "cum" (cumulative) or "rate"
221 size_t n_frames; // Number of frames processed
222
223 // Full deformation result (all 36 fields) for MAT file writing
225};
226
227} // namespace cppxdic
228
229#endif // DIC_STRUCTURES_H
DataSerializer - Abstract base class for format-agnostic DIC data I/O.
std::vector< std::vector< std::string > > DLT_paths
std::vector< std::vector< std::vector< double > > > DLT_params
DIC 2D Pair Results Equivalent to MATLAB's DIC2DpairResults.
std::vector< int > pairOrder
std::vector< Points2D > Points
std::vector< std::vector< double > > CorCoeffVec
std::vector< double > FaceColors
std::vector< int > Faces
DIC 3D Post-Processing Results Equivalent to MATLAB's DIC3DPPresults.
std::vector< std::vector< double > > FaceIsoInd
std::vector< std::vector< double > > Points3D_ARBM_y
std::vector< std::vector< double > > Points3D_ARBM_x
FrameDeformationResult deform_full
std::vector< std::vector< double > > Points3D_ARBM_z
DIC 3D Combined Results Equivalent to MATLAB's DIC3Dcombined This represents stitched results from mu...
std::vector< int > FacePairInds
DistortionData distortion
std::vector< int > PointPairInds
std::vector< DIC3DpairResults > AllPairsResults
std::vector< Point3DFrame > Points3D
std::vector< int > pairIndices
std::vector< double > FaceColors
std::vector< std::vector< double > > FaceCorrComb
static DIC3Dcombined loadBinary(const std::string &filepath)
std::vector< std::vector< double > > corrComb
void saveBinary(const std::string &filepath) const
std::vector< DIC2DPairResults > DIC2Dinfo
CalibrationData calibration
std::vector< int > Faces
std::vector< std::vector< double > > FaceCentroids
DIC 3D Pair Results (Individual stereo pair) Equivalent to MATLAB's DIC3DpairResults This represents ...
std::vector< std::vector< double > > DLTparameters
std::vector< std::vector< double > > corrComb
std::vector< int > Faces
std::vector< std::vector< double > > FaceCentroids
std::vector< double > FaceColors
std::vector< Point3DFrame > Points3D
std::vector< std::string > DLTpath
std::vector< std::vector< double > > FaceCorrComb
std::vector< std::string > distortionPath
std::vector< std::string > distortionModel
std::vector< int > cameraPairInd
DIC Info structure (parameters) Matches MATLAB ncorrInfo structure.
std::string units
std::vector< std::string > imgcorr
std::vector< double > cutoff_corrcoef
StepAnalysisInfo stepanalysis
Deformation data.
std::vector< DeformGradient > F
std::vector< StrainTensor > strain
std::vector< std::vector< double > > princStrain
std::vector< std::vector< double > > maxShearStrain
Deformation gradient tensor.
std::vector< double > F13
std::vector< double > F23
std::vector< double > F12
std::vector< double > F22
std::vector< double > F21
std::vector< double > F32
std::vector< double > F31
std::vector< double > F33
std::vector< double > F11
Displacement data.
std::vector< std::vector< double > > DispVec
std::vector< std::vector< double > > DispMgn
std::vector< std::vector< std::string > > distortion_models
std::vector< std::vector< std::string > > distortion_paths
Frame-based deformation result Contains deformation results for all frames.
3D Points per frame
std::vector< double > z
std::vector< double > x
std::vector< double > y
2D Points per frame
std::vector< double > x
std::vector< double > y
Rigid Body Motion (RBM) data.
std::vector< std::vector< double > > TransVec
std::vector< std::vector< double > > RotMat
Step Analysis parameters (for high strain analysis)
std::vector< double > E11
std::vector< double > E12
std::vector< double > E13
std::vector< double > E21
std::vector< double > E31
std::vector< double > E32
std::vector< double > E23
std::vector< double > E22
std::vector< double > E33