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

DataSerializer - Abstract base class for format-agnostic DIC data I/O. More...

Namespaces

namespace  detail
 
namespace  input
 
namespace  log
 
namespace  stepsABC
 

Classes

struct  BaseParameters
 Base parameters structure Contains fundamental paths and settings for DIC analysis Equivalent to base_parameters struct in Matlab. More...
 
class  BinarySerializer
 
struct  CalibrationData
 Calibration data. More...
 
struct  CuncorrDicConfig
 Tunables mirrored onto cuncorr::SessionConfig. More...
 
struct  CuncorrDicInfo
 Which backend actually ran. More...
 
class  DataSerializer
 
struct  DeformationResult
 Deformation result structure Contains all computed deformation and strain measures. More...
 
struct  DeformData
 Deformation data. More...
 
struct  DeformGradient
 Deformation gradient tensor. More...
 
class  DelaunayTriangulation
 DelaunayTriangulation class Provides Delaunay triangulation utilities using CGAL. More...
 
struct  DIC2DPairResults
 DIC 2D Pair Results Equivalent to MATLAB's DIC2DpairResults. More...
 
struct  DIC3Dcombined
 DIC 3D Combined Results Equivalent to MATLAB's DIC3Dcombined This represents stitched results from multiple stereo pairs. More...
 
struct  DIC3DpairResults
 DIC 3D Pair Results (Individual stereo pair) Equivalent to MATLAB's DIC3DpairResults This represents the 3D reconstruction for a single stereo pair. More...
 
struct  DIC3DPPresults
 DIC 3D Post-Processing Results Equivalent to MATLAB's DIC3DPPresults. More...
 
struct  DICConstants
 DIC constants Global constants used throughout the DIC analysis. More...
 
struct  DICInfo
 DIC Info structure (parameters) Matches MATLAB ncorrInfo structure. More...
 
struct  DispData
 Displacement data. More...
 
struct  DistortionData
 Distortion data. More...
 
struct  DLTCalibrationData
 
struct  FrameDeformationResult
 Frame-based deformation result Contains deformation results for all frames. More...
 
class  ImageProcessor
 ImageProcessor class Provides image preprocessing operations for DIC analysis. More...
 
class  JsonSerializer
 
class  MatReader
 MatReader class Provides utilities for reading MAT files. More...
 
class  MatSerializer
 
class  MatWriter
 MatWriter class Provides utilities for writing MAT files with proper xDIC structure. More...
 
struct  Point3DFrame
 3D Points per frame More...
 
struct  Points2D
 2D Points per frame More...
 
struct  ProtocolFileData
 
struct  ProtocolInfo
 Protocol information structure Contains trial condition information from protocol MAT file. More...
 
struct  RBMData
 Rigid Body Motion (RBM) data. More...
 
class  ROIManager
 ROIManager class Manages ROI masks and seed points for DIC analysis. More...
 
struct  SeedPoint
 Seed point structure Stores seed points in both pixel world (pw) and subset world (sw) coordinates. More...
 
struct  StepAnalysisInfo
 Step Analysis parameters (for high strain analysis) More...
 
struct  StepAnalysisParams
 Step analysis parameters structure Contains high strain analysis settings. More...
 
class  StepDWorkflow
 StepDWorkflow class Implements the complete 2D DIC analysis workflow Equivalent to stepD_2DDIC.m in Matlab. More...
 
struct  StepParameters
 Step parameters structure for DIC analysis Contains DIC-specific parameters like radius, spacing, cutoff Equivalent to step1_parameters, step2_parameters, step1_2_parameters in Matlab. More...
 
struct  StrainTensor
 Strain tensor. More...
 
struct  SubjectTrial
 A single (subject, trial) row, e.g. More...
 
struct  VisData
 Visualization data container Holds filtered and processed data ready for export. More...
 
class  Visualization
 Visualization manager class Handles loading, filtering, and exporting DIC results. More...
 

Typedefs

typedef CGAL::Exact_predicates_inexact_constructions_kernel K
 
typedef CGAL::Triangulation_vertex_base_with_info_2< size_t, K > Vb
 
typedef CGAL::Triangulation_data_structure_2< Vb > Tds
 
typedef CGAL::Delaunay_triangulation_2< K, Tds > Delaunay
 
typedef K::Point_2 Point_2
 

Enumerations

enum class  ExportFormat { VTK , PLY , CSV }
 Visualization export formats. More...
 

Functions

bool cuncorr_cuda_available ()
 True if cuNCorr was built with CUDA and a device is present at runtime.
 
ncorr::DIC_analysis_output run_cuncorr_dic (const std::vector< ncorr::Image2D > &imgs, const ncorr::ROI2D &roi, const CuncorrDicConfig &cfg, CuncorrDicInfo *info=nullptr)
 Run cuNCorr in sequence mode (fixed reference = imgs[0], warm-start each frame) over the stack against the full-resolution roi.
 
std::vector< double > computeFaceIsotropyIndex (const std::vector< int > &faces, const std::vector< Eigen::Vector3d > &vertices)
 Compute isotropy index for triangular faces.
 
double computeSingleFaceIsotropyIndex (const Eigen::Vector3d &v0, const Eigen::Vector3d &v1, const Eigen::Vector3d &v2)
 Compute isotropy index for a single triangle.
 
int matlab_replacebadcorr (ncorr::DIC_analysis_output &data, double level_corr_coef=1.0, double sigma_spatial=1.0, double sigma_temporal=2.0, double shrink_factor=0.9)
 Replaces badly correlated displacement data with spatiotemporally filtered values.
 
std::vector< cv::Mat > matlab_imgaussfilt3 (const std::vector< cv::Mat > &volume, double sigma_spatial, double sigma_temporal)
 Applies a 3D Gaussian filter (spatial + temporal) to a volume of 2D fields.
 
cv::Mat matlab_shrink_mask (const cv::Mat &mask, double factor)
 Shrinks a binary mask by a scale factor around its centroid.
 
FrameDeformationResult computeTriSurfaceDeformation (const std::vector< int > &faces, const std::vector< Eigen::Vector3d > &vertices_ref, const std::vector< std::vector< Eigen::Vector3d > > &vertices_def, bool cumulative=true)
 Compute deformation and strain for triangular surface elements.
 
DeformationResult computeSingleFrameDeformation (const std::vector< int > &faces, const std::vector< Eigen::Vector3d > &vertices_ref, const std::vector< Eigen::Vector3d > &vertices_cur)
 Compute deformation for a single frame.
 
DIC3Dcombined stitchPairsSimple (const std::vector< DIC3DpairResults > &all_pairs)
 Simple append-based stitching for multiple stereo pairs.
 
DIC3Dcombined stitchPairsGeometric (const std::vector< DIC3DpairResults > &all_pairs, const std::vector< int > &pair_order, bool pair_forced=false)
 Geometric stitching with overlap removal and boundary zipping Matches MATLAB's DIC3DsurfaceStitch.m with geometric stitching enabled.
 
void setStitchRayAccel (bool enabled)
 Enable/disable the AABB-hierarchy prefilter used by the overlap-removal ray casts.
 
bool stitchRayAccel ()
 Current state of the ray-cast prefilter (see setStitchRayAccel).
 
std::vector< int > computeMeshBoundary (const std::vector< int > &faces, const std::vector< Eigen::Vector3d > &vertices)
 Compute boundary edges of a triangular mesh Matches MATLAB: patchBoundary(F, V)
 
std::vector< double > computeEdgeLengths (const std::vector< int > &faces, const std::vector< Eigen::Vector3d > &vertices)
 Compute edge lengths for all triangles Matches MATLAB: patchEdgeLengths(F, V)
 
std::pair< std::vector< bool >, std::vector< bool > > removeOverlapSurfaces (const std::vector< int > &faces1, const std::vector< int > &faces2, const std::vector< Eigen::Vector3d > &vertices1, const std::vector< Eigen::Vector3d > &vertices2, double min_gap, bool pair_forced=false)
 Remove overlapping regions from two surfaces Matches MATLAB: removeOverlapSurface_temp_2018_10_30(F1, F2, V1, V2, [], [], minGap, pairforced)
 
std::vector< std::vector< int > > groupBoundaryEdges (const std::vector< int > &boundary_edges)
 Group boundary edges into connected components.
 
std::vector< int > edgeListToCurve (const std::vector< int > &edges)
 Convert an unordered list of edges into an ordered curve of vertex indices.
 
std::vector< int > zipBoundaryCurves (const std::vector< int > &curve1, const std::vector< int > &curve2, const std::vector< Eigen::Vector3d > &V_combined)
 Zip two boundary curves together by creating a triangle strip.
 
std::vector< bool > findAllBoundaryFaces (const std::vector< int > &faces, const std::vector< int > &boundary_edges)
 Remove faces where all 3 edges are on the boundary (degenerate boundary triangles).
 
std::vector< std::vector< double > > filterTime (const std::vector< std::vector< double > > &data, double freq_filt=10.0, double freq_acq=50.0)
 Apply temporal Butterworth low-pass filter to displacement data.
 
std::tuple< std::vector< std::vector< double > >, std::vector< std::vector< double > >, std::vector< std::vector< double > > > filterTime3D (const std::vector< std::vector< double > > &disp_x, const std::vector< std::vector< double > > &disp_y, const std::vector< std::vector< double > > &disp_z, double freq_filt=10.0, double freq_acq=50.0)
 Apply temporal filtering to 3D displacement vectors.
 
std::string trim (const std::string &s)
 Trim leading/trailing whitespace (spaces, tabs, CR, LF).
 
std::vector< int > parseTrialList (const std::string &spec)
 Parse a comma/space-separated list of integer trial IDs.
 
std::vector< int > readTrialsFile (const std::string &path)
 Read a trials file: one trial ID per line.
 
std::vector< SubjectTrial > readSubjectTrialCsv (const std::string &path)
 Read subject_trial.csv (header "subject,trial") into rows, skipping the header line and any blank/comment lines.
 
int slurmArrayTaskId ()
 Resolve SLURM_ARRAY_TASK_ID from the environment.
 
static nlohmann::json points3dToJson (const Point3DFrame &pts)
 
static Point3DFrame points3dFromJson (const nlohmann::json &j)
 
static nlohmann::json deformGradientToJson (const DeformGradient &F)
 
static nlohmann::json strainTensorToJson (const StrainTensor &E)
 
static nlohmann::json deformDataToJson (const DeformData &deform)
 
template<typename T >
void writePOD (std::ofstream &ofs, const T &value)
 
template<typename T >
void readPOD (std::ifstream &ifs, T &value)
 
template<typename T >
void writeVector (std::ofstream &ofs, const std::vector< T > &vec)
 
template<typename T >
void readVector (std::ifstream &ifs, std::vector< T > &vec)
 
void writeString (std::ofstream &ofs, const std::string &str)
 
void readString (std::ifstream &ifs, std::string &str)
 
template<typename T >
void writeVector2D (std::ofstream &ofs, const std::vector< std::vector< T > > &vec)
 
template<typename T >
void readVector2D (std::ifstream &ifs, std::vector< std::vector< T > > &vec)
 
void writePoints3D (std::ofstream &ofs, const Point3DFrame &pts)
 
void readPoints3D (std::ifstream &ifs, Point3DFrame &pts)
 
void writeDispData (std::ofstream &ofs, const DispData &disp)
 
void readDispData (std::ifstream &ifs, DispData &disp)
 
void writeCalibrationData (std::ofstream &ofs, const CalibrationData &calib)
 
void readCalibrationData (std::ifstream &ifs, CalibrationData &calib)
 
void writeDistortionData (std::ofstream &ofs, const DistortionData &dist)
 
void writeStringMap (std::ofstream &ofs, const std::map< std::string, std::string > &map)
 
void readDistortionData (std::ifstream &ifs, DistortionData &dist)
 
void readStringMap (std::ifstream &ifs, std::map< std::string, std::string > &map)
 
static matvar_t * createEmptyCharVar (const char *name=nullptr)
 
static std::vector< Eigen::Vector3d > computeVertexNormals (const std::vector< int > &faces, const std::vector< Eigen::Vector3d > &vertices)
 
static double rayTriangleHit (const Eigen::Vector3d &O, const Eigen::Vector3d &D, const Eigen::Vector3d &A, const Eigen::Vector3d &B, const Eigen::Vector3d &C, double eps)
 
static std::vector< Eigen::Vector3d > raySetTriangleIntersect (const std::vector< Eigen::Vector3d > &origins, const std::vector< Eigen::Vector3d > &dirs, const std::vector< int > &faces, const std::vector< Eigen::Vector3d > &vertices, double eps=1e-6)
 
static std::vector< double > computeRaySurfaceDistance (const std::vector< Eigen::Vector3d > &V1, const std::vector< Eigen::Vector3d > &N1, const std::vector< int > &F2, const std::vector< Eigen::Vector3d > &V2)
 
static double meanFiniteEdgeLength (const std::vector< int > &faces, const std::vector< Eigen::Vector3d > &vertices)
 
static std::vector< int > applyFaceMask (const std::vector< int > &F, const std::vector< bool > &CT)
 
static bool removeFacesContainingVertex (const std::vector< int > &F, std::vector< bool > &CT, int v_remove)
 
static std::vector< int > filterFaces (const std::vector< int > &faces, const std::vector< bool > &keep)
 
template<typename T >
static std::vector< T > filterByMask (const std::vector< T > &data, const std::vector< bool > &keep)
 
static std::vector< std::vector< int > > buildFaceAdjacency (const std::vector< int > &faces, size_t n_faces)
 Build face adjacency map from triangle connectivity For each face, find all faces that share at least one vertex.
 
static std::vector< std::array< double, 3 > > computeFaceCentroids (const Point3DFrame &points, const std::vector< int > &faces, size_t n_faces)
 Compute face centroids from vertices and faces.
 
static double computeAverageResolution (const std::vector< std::array< double, 3 > > &centroids, const std::vector< std::vector< int > > &adjacency)
 Compute average resolution (spacing) of face centroids.
 
static std::vector< std::vector< std::pair< int, int > > > findKNearestByHops (const std::vector< std::vector< int > > &adjacency, int k)
 Find k-nearest neighbors for each face using BFS on adjacency graph.
 
static void designButterworth4 (double Wn, std::vector< double > &b, std::vector< double > &a)
 Design 4th order Butterworth low-pass filter coefficients Equivalent to MATLAB's [B,A] = butter(4, Wn)
 
static std::vector< double > filtfilt (const std::vector< double > &b, const std::vector< double > &a, const std::vector< double > &x)
 Apply zero-phase filtering (equivalent to MATLAB's filtfilt) Filters forward and backward to eliminate phase distortion.
 
static void fillMissingLinear (std::vector< double > &data)
 Fill missing values (NaN) with linear interpolation Equivalent to MATLAB's fillmissing(d,'linear',1,'EndValues','nearest')
 

Variables

static size_t scalar_dims [2] = {1, 1}
 
static bool g_stitch_ray_bvh = false
 

Detailed Description

DataSerializer - Abstract base class for format-agnostic DIC data I/O.

Implementation of visualization module for DIC results.

Temporal Filtering Implementation Port of MATLAB myfilterTime.m and filtfilt.

Surface Stitching Implementation for Multi-Pair 3D Reconstruction Based on Matlab's DIC3DsurfaceStitch.m.

Strain Computation Implementation Direct port of MATLAB triSurfaceDeformation_rewrited.m.

Implementation of StepC stereovision / DLT calibration.

Implementation of MASK + Seed setup for xDIC stepsABC.

ROI and Seed Point Manager for CPPXDIC Implementation of ROI/seed loading and coordinate transformations Based on MATLAB draw_ref_roi.m, draw_ref_seed.m, and map_*.m functions.

MAT File Writer for CPPXDIC Implementation of MAT file writing in xDIC format Produces MATLAB v7.3 (HDF5) compatible output.

MAT File Reader Implementation.

Image processing utilities for CPPXDIC Implementation of saturation and filtering operations Based on MATLAB satur.m and filter_like_ben.m.

Face Isotropy Index Implementation Port of MATLAB faceIsotropyIndex.m.

Implementation of binary serialization for DIC structures.

Delaunay Triangulation Implementation using CGAL.

DataSerializer implementations for mat, bin, and json formats.

Visualization module for DIC results Exports 3D mesh data with deformation/strain fields for visualization Equivalent to MATLAB's plot_singleTrial_map and anim8_rewrited functions.

Trial / (subject, trial) selection helpers for CPPXDIC drivers.

Temporal Filtering for CPPXDIC Port of MATLAB myfilterTime.m.

Surface Stitching for Multi-Pair 3D Reconstruction.

Strain Computation for CPPXDIC Port of MATLAB triSurfaceDeformation_rewrited.m Based on Triangular Cosserat Point Elements (TCPE)

StepC: stereovision / DLT calibration.

MASK + Seed setup for the xDIC stepsABC tool.

Step D: 2D DIC Analysis Workflow for CPPXDIC Complete implementation of stepD_2DDIC from Matlab xDIC Handles the full 2D DIC analysis pipeline.

ROI and Seed Point Manager for CPPXDIC Handles ROI loading/creation and seed point management Equivalent to draw_ref_roi.m, draw_ref_seed.m, and related functions in Matlab xDIC.

Parameter structures for CPPXDIC Encapsulates parameters to avoid passing many arguments between functions Equivalent to parameter structures in Matlab stepD_2DDIC.m.

MATLAB-equivalent functions for DIC processing.

MAT File Writer for CPPXDIC Handles writing DIC results to MATLAB v7.3 (HDF5) format Produces output structure matching xDIC format.

MAT File Reader for CPPXDIC Helper functions for reading MATLAB .mat files using matio.

Image processing utilities for CPPXDIC Handles image saturation and filtering operations Equivalent to satur.m and filter_like_ben.m in Matlab xDIC.

Face Isotropy Index for CPPXDIC Port of MATLAB faceIsotropyIndex.m.

Data structures for DIC results Matches MATLAB xDIC structure format.

Delaunay Triangulation for CPPXDIC CGAL-based implementation matching MATLAB's delaunayTriangulation.

The MATLAB data structure (mat_trees.txt) is the canonical schema. This abstraction allows transparent switching between output formats (.mat, .bin, .json) via a config parameter, without changing pipeline code.

To add a new format, implement a new subclass and register it in create().

Computes triangle regularity/quality metric

Reference: Cappozzo, A., Cappello, A., Della Croce, U., & Pensalfini, F. (1997). Surface-marker cluster design criteria for 3-D bone movement reconstruction. IEEE Transactions on Biomedical Engineering, 44(12), 1165-1174.

These functions replicate specific MATLAB operations used in the xDIC pipeline, prefixed with matlab_ to clearly indicate their origin and purpose.

  • matlab_replacebadcorr: Equivalent of replacebadcorr() in step2_dic_finish.m
  • matlab_shrink_mask: Equivalent of shrink_mask.m
  • matlab_imgaussfilt3: Equivalent of imgaussfilt3() with 'spatial' FilterDomain

Provides interactive (OpenCV highgui) and non-interactive (file/config based) setup of the reference MASK (polygon ROI) and Seed point(s) used to initialise DIC tracking.

This mirrors the MATLAB MultiDIC interactive helpers draw_ref_roi.m and draw_ref_seed.m (polygon ROI via roipoly + seed point picking) but exposes a headless path so the exact same binary runs on a cluster node with no display.

The mask/seed data structures and any persistence to/from the cppxdic MAT format are delegated to cppxdic::ROIManager so this tool does not duplicate ROI/seed logic.

C++ port of MATLAB MultiDIC main_script/stepC_stereovision_calibration.m and the helpers it calls:

  • generate_cylindrical_calibration_object_coordinate_file.m
  • STEP1_CalcDLTparameters_rewrited.m (per-camera DLT11 parameter fit)
  • the DLT reconstruction-error computation

The 11-parameter DLT fit itself reuses the existing Utils::DLT11Calibration helper (src/utils.cpp) so no new linear-algebra path is introduced. Eigen is used for the stereo triangulation least-squares solve, consistent with the rest of the repo.

Reference: Solav, Dana, et al. "Bone pose estimation in the presence of soft tissue artifact using triangular cosserat point elements." Annals of biomedical engineering 44.4 (2016): 1181-1190.

Implements Butterworth low-pass filtering for smoothing displacement time series

Small, header-only utilities shared by the gen_subject_trial generator and the trial-level experiment runner (single trial, SLURM array over a trial list, SLURM array over a subject_trial.csv). Kept self-contained so new targets can include just this header without pulling in the full pipeline.

See matlab_functions.h for documentation.

GUI drawing code is guarded by XDIC_STEPSABC_GUI so the translation unit compiles and links on a headless cluster node where no highgui window backend is available. When GUI support is disabled, runGui() returns a clean error.

Ported from MATLAB MultiDIC stepC_stereovision_calibration.m. The 11-parameter DLT fit reuses Utils::DLT11Calibration; the stereo triangulation uses Eigen (consistent with the rest of the repo).

Typedef Documentation

◆ Delaunay

typedef CGAL::Delaunay_triangulation_2<K, Tds> cppxdic::Delaunay

Definition at line 20 of file delaunay_triangulation.cpp.

◆ K

typedef CGAL::Exact_predicates_inexact_constructions_kernel cppxdic::K

Definition at line 17 of file delaunay_triangulation.cpp.

◆ Point_2

typedef K::Point_2 cppxdic::Point_2

Definition at line 21 of file delaunay_triangulation.cpp.

◆ Tds

typedef CGAL::Triangulation_data_structure_2<Vb> cppxdic::Tds

Definition at line 19 of file delaunay_triangulation.cpp.

◆ Vb

typedef CGAL::Triangulation_vertex_base_with_info_2<size_t, K> cppxdic::Vb

Definition at line 18 of file delaunay_triangulation.cpp.

Enumeration Type Documentation

◆ ExportFormat

enum class cppxdic::ExportFormat
strong

Visualization export formats.

Enumerator
VTK 
PLY 
CSV 

Definition at line 22 of file visualization.h.

Function Documentation

◆ applyFaceMask()

static std::vector< int > cppxdic::applyFaceMask ( const std::vector< int > &  F,
const std::vector< bool > &  CT 
)
static

Definition at line 593 of file surface_stitching.cpp.

◆ buildFaceAdjacency()

static std::vector< std::vector< int > > cppxdic::buildFaceAdjacency ( const std::vector< int > &  faces,
size_t  n_faces 
)
static

Build face adjacency map from triangle connectivity For each face, find all faces that share at least one vertex.

Parameters
facesFlattened triangle indices (size = n_faces * 3)
n_facesNumber of faces
Returns
Adjacency list: adj[face_idx] = vector of adjacent face indices

Definition at line 110 of file visualization.cpp.

◆ computeAverageResolution()

static double cppxdic::computeAverageResolution ( const std::vector< std::array< double, 3 > > &  centroids,
const std::vector< std::vector< int > > &  adjacency 
)
static

Compute average resolution (spacing) of face centroids.

Parameters
centroidsFace centroid positions
adjacencyFace adjacency list
Returns
Average distance between adjacent face centroids

Definition at line 182 of file visualization.cpp.

◆ computeEdgeLengths()

std::vector< double > cppxdic::computeEdgeLengths ( const std::vector< int > &  faces,
const std::vector< Eigen::Vector3d > &  vertices 
)

Compute edge lengths for all triangles Matches MATLAB: patchEdgeLengths(F, V)

Definition at line 263 of file surface_stitching.cpp.

◆ computeFaceCentroids()

static std::vector< std::array< double, 3 > > cppxdic::computeFaceCentroids ( const Point3DFrame &  points,
const std::vector< int > &  faces,
size_t  n_faces 
)
static

Compute face centroids from vertices and faces.

Parameters
points3D points for the current frame
facesFlattened triangle indices
n_facesNumber of faces
Returns
Vector of centroids (x, y, z) for each face

Definition at line 156 of file visualization.cpp.

◆ computeFaceIsotropyIndex()

std::vector< double > cppxdic::computeFaceIsotropyIndex ( const std::vector< int > &  faces,
const std::vector< Eigen::Vector3d > &  vertices 
)

Compute isotropy index for triangular faces.

The isotropy index measures the "regularity" of a triangle:

  • Value of 1.0: Perfectly equilateral triangle (most regular)
  • Value of 0.0: Degenerate triangle (vertices aligned on a line)
  • NaN: Triangle has NaN vertices

Algorithm:

  1. Compute cluster position model: X = [x1-xa, x2-xa, x3-xa] where xa is centroid
  2. Compute covariance-like matrix: K = X*X'/3
  3. Compute eigenvalues of K
  4. Isotropy index = 2*λ2 / (λ2 + λ3) where λ2 < λ3 are sorted eigenvalues
Parameters
facesTriangle connectivity (3*nFaces flattened: [v0,v1,v2, v0,v1,v2, ...])
vertices3D vertex positions (nVertices x 3)
Returns
Isotropy index for each face (nFaces values)

Definition at line 64 of file face_isotropy.cpp.

◆ computeMeshBoundary()

std::vector< int > cppxdic::computeMeshBoundary ( const std::vector< int > &  faces,
const std::vector< Eigen::Vector3d > &  vertices 
)

Compute boundary edges of a triangular mesh Matches MATLAB: patchBoundary(F, V)

Parameters
facesTriangle faces (flat array: [v0,v1,v2, v0,v1,v2, ...])
verticesVertex positions
Returns
Boundary edges as pairs [v0,v1, v0,v1, ...]

Definition at line 218 of file surface_stitching.cpp.

◆ computeRaySurfaceDistance()

static std::vector< double > cppxdic::computeRaySurfaceDistance ( const std::vector< Eigen::Vector3d > &  V1,
const std::vector< Eigen::Vector3d > &  N1,
const std::vector< int > &  F2,
const std::vector< Eigen::Vector3d > &  V2 
)
static

Definition at line 568 of file surface_stitching.cpp.

◆ computeSingleFaceIsotropyIndex()

double cppxdic::computeSingleFaceIsotropyIndex ( const Eigen::Vector3d &  v0,
const Eigen::Vector3d &  v1,
const Eigen::Vector3d &  v2 
)

Compute isotropy index for a single triangle.

Parameters
v0First vertex position
v1Second vertex position
v2Third vertex position
Returns
Isotropy index (0 to 1, or NaN if degenerate)

Definition at line 12 of file face_isotropy.cpp.

◆ computeSingleFrameDeformation()

DeformationResult cppxdic::computeSingleFrameDeformation ( const std::vector< int > &  faces,
const std::vector< Eigen::Vector3d > &  vertices_ref,
const std::vector< Eigen::Vector3d > &  vertices_cur 
)

Compute deformation for a single frame.

Parameters
facesTriangle connectivity
vertices_refReference vertices
vertices_curCurrent (deformed) vertices
Returns
Deformation result for single frame

Definition at line 14 of file strain_computation.cpp.

◆ computeTriSurfaceDeformation()

FrameDeformationResult cppxdic::computeTriSurfaceDeformation ( const std::vector< int > &  faces,
const std::vector< Eigen::Vector3d > &  vertices_ref,
const std::vector< std::vector< Eigen::Vector3d > > &  vertices_def,
bool  cumulative = true 
)

Compute deformation and strain for triangular surface elements.

Parameters
facesTriangle connectivity (Nx3, each row is [v1, v2, v3])
vertices_refReference vertex positions (Mx3)
vertices_defDeformed vertex positions for each frame (vector of Mx3)
cumulativeIf true, use first frame as reference; if false, use previous frame
Returns
Frame-based deformation results

Definition at line 319 of file strain_computation.cpp.

◆ computeVertexNormals()

static std::vector< Eigen::Vector3d > cppxdic::computeVertexNormals ( const std::vector< int > &  faces,
const std::vector< Eigen::Vector3d > &  vertices 
)
static

Definition at line 298 of file surface_stitching.cpp.

◆ createEmptyCharVar()

static matvar_t * cppxdic::createEmptyCharVar ( const char *  name = nullptr)
static

Definition at line 25 of file mat_writer.cpp.

◆ cuncorr_cuda_available()

bool cppxdic::cuncorr_cuda_available ( )

True if cuNCorr was built with CUDA and a device is present at runtime.

Definition at line 47 of file cuncorr_dic.cpp.

◆ deformDataToJson()

static nlohmann::json cppxdic::deformDataToJson ( const DeformData &  deform)
static

Definition at line 368 of file data_serializer.cpp.

◆ deformGradientToJson()

static nlohmann::json cppxdic::deformGradientToJson ( const DeformGradient &  F)
static

Definition at line 350 of file data_serializer.cpp.

◆ designButterworth4()

static void cppxdic::designButterworth4 ( double  Wn,
std::vector< double > &  b,
std::vector< double > &  a 
)
static

Design 4th order Butterworth low-pass filter coefficients Equivalent to MATLAB's [B,A] = butter(4, Wn)

Parameters
WnNormalized cutoff frequency (0 to 1, where 1 = Nyquist)
bOutput numerator coefficients (size 5 for 4th order)
aOutput denominator coefficients (size 5 for 4th order)

Definition at line 830 of file visualization.cpp.

◆ edgeListToCurve()

std::vector< int > cppxdic::edgeListToCurve ( const std::vector< int > &  edges)

Convert an unordered list of edges into an ordered curve of vertex indices.

Matches MATLAB: edgeListToCurve(E)

Parameters
edgesEdge pairs [v0,v1, v0,v1, ...]
Returns
Ordered list of vertex indices forming the curve

Definition at line 933 of file surface_stitching.cpp.

◆ fillMissingLinear()

static void cppxdic::fillMissingLinear ( std::vector< double > &  data)
static

Fill missing values (NaN) with linear interpolation Equivalent to MATLAB's fillmissing(d,'linear',1,'EndValues','nearest')

Definition at line 952 of file visualization.cpp.

◆ filterByMask()

template<typename T >
static std::vector< T > cppxdic::filterByMask ( const std::vector< T > &  data,
const std::vector< bool > &  keep 
)
static

Definition at line 1065 of file surface_stitching.cpp.

◆ filterFaces()

static std::vector< int > cppxdic::filterFaces ( const std::vector< int > &  faces,
const std::vector< bool > &  keep 
)
static

Definition at line 1049 of file surface_stitching.cpp.

◆ filterTime()

std::vector< std::vector< double > > cppxdic::filterTime ( const std::vector< std::vector< double > > &  data,
double  freq_filt = 10.0,
double  freq_acq = 50.0 
)

Apply temporal Butterworth low-pass filter to displacement data.

Parameters
dataInput data (nPoints x nFrames) - each column is a time series
freq_filtFilter cutoff frequency (Hz)
freq_acqAcquisition/sampling frequency (Hz)
nPointsNumber of spatial points
nFramesNumber of time frames
Returns
Filtered data (same dimensions as input)

Algorithm:

  • 4th order Butterworth low-pass filter
  • Zero-phase filtering using forward-backward pass (filtfilt)
  • Boundary padding to reduce edge effects
  • Preserves NaN values (only filters valid data)

Definition at line 17 of file temporal_filter.cpp.

◆ filterTime3D()

std::tuple< std::vector< std::vector< double > >, std::vector< std::vector< double > >, std::vector< std::vector< double > > > cppxdic::filterTime3D ( const std::vector< std::vector< double > > &  disp_x,
const std::vector< std::vector< double > > &  disp_y,
const std::vector< std::vector< double > > &  disp_z,
double  freq_filt = 10.0,
double  freq_acq = 50.0 
)

Apply temporal filtering to 3D displacement vectors.

Parameters
disp_xX-component displacement (nPoints x nFrames)
disp_yY-component displacement (nPoints x nFrames)
disp_zZ-component displacement (nPoints x nFrames)
freq_filtFilter cutoff frequency (Hz)
freq_acqAcquisition/sampling frequency (Hz)
Returns
Tuple of (filtered_x, filtered_y, filtered_z)

Definition at line 89 of file temporal_filter.cpp.

◆ filtfilt()

static std::vector< double > cppxdic::filtfilt ( const std::vector< double > &  b,
const std::vector< double > &  a,
const std::vector< double > &  x 
)
static

Apply zero-phase filtering (equivalent to MATLAB's filtfilt) Filters forward and backward to eliminate phase distortion.

Parameters
bNumerator coefficients
aDenominator coefficients
xInput signal
Returns
Filtered signal

Definition at line 885 of file visualization.cpp.

◆ findAllBoundaryFaces()

std::vector< bool > cppxdic::findAllBoundaryFaces ( const std::vector< int > &  faces,
const std::vector< int > &  boundary_edges 
)

Remove faces where all 3 edges are on the boundary (degenerate boundary triangles).

Matches MATLAB DIC3DsurfaceStitch lines 127-160.

Parameters
facesTriangle faces (flat: [v0,v1,v2, ...])
boundary_edgesBoundary edge pairs [v0,v1, ...]
Returns
Boolean mask per face: true = keep, false = remove

Definition at line 972 of file surface_stitching.cpp.

◆ findKNearestByHops()

static std::vector< std::vector< std::pair< int, int > > > cppxdic::findKNearestByHops ( const std::vector< std::vector< int > > &  adjacency,
int  k 
)
static

Find k-nearest neighbors for each face using BFS on adjacency graph.

Parameters
adjacencyFace adjacency list
kNumber of neighbors to find
Returns
For each face: vector of (neighbor_idx, distance_in_hops)

Definition at line 208 of file visualization.cpp.

◆ groupBoundaryEdges()

std::vector< std::vector< int > > cppxdic::groupBoundaryEdges ( const std::vector< int > &  boundary_edges)

Group boundary edges into connected components.

Matches MATLAB: tesgroup(E)

Parameters
boundary_edgesBoundary edges as pairs [v0,v1, v0,v1, ...]
Returns
Vector of groups, each group is a list of edge indices

Definition at line 888 of file surface_stitching.cpp.

◆ matlab_imgaussfilt3()

std::vector< cv::Mat > cppxdic::matlab_imgaussfilt3 ( const std::vector< cv::Mat > &  volume,
double  sigma_spatial,
double  sigma_temporal 
)

Applies a 3D Gaussian filter (spatial + temporal) to a volume of 2D fields.

Equivalent to MATLAB imgaussfilt3(volume, sigma, 'FilterDomain', 'spatial', 'padding', 'replicate').

Uses separable filtering: 2D spatial Gaussian per frame, then 1D temporal Gaussian per pixel.

Parameters
volumeInput 3D data as vector of CV_64F Mats (H x W each)
sigma_spatialGaussian sigma for spatial (x,y) dimensions
sigma_temporalGaussian sigma for temporal (frame) dimension
Returns
Filtered volume (same dimensions)

Definition at line 84 of file matlab_functions.cpp.

◆ matlab_replacebadcorr()

int cppxdic::matlab_replacebadcorr ( ncorr::DIC_analysis_output &  data,
double  level_corr_coef = 1.0,
double  sigma_spatial = 1.0,
double  sigma_temporal = 2.0,
double  shrink_factor = 0.9 
)

Replaces badly correlated displacement data with spatiotemporally filtered values.

Equivalent to MATLAB replacebadcorr() in step2_dic_finish.m.

Algorithm:

  1. Stack displacement fields into 3D volumes (H x W x Nframe)
  2. Identify bad correlation mask: corrcoef > level_corr_coef
  3. Apply 3D Gaussian filter (sigma_spatial, sigma_temporal) with replicate padding
  4. Shrink the valid mask by shrink_factor to avoid border artifacts
  5. Replace only bad-corr points within shrunk mask with filtered values
  6. Repeat filtering + replacement (double pass) for smoother results
Parameters
dataDIC analysis output (modified in-place)
level_corr_coefCorrelation coefficient threshold (MATLAB default: 1.0)
sigma_spatialSpatial Gaussian sigma (MATLAB default: 1.0)
sigma_temporalTemporal Gaussian sigma (MATLAB default: 2.0)
shrink_factorMask shrink factor to avoid border effects (MATLAB default: 0.9)
Returns
Number of replaced subsets across all frames

Definition at line 163 of file matlab_functions.cpp.

◆ matlab_shrink_mask()

cv::Mat cppxdic::matlab_shrink_mask ( const cv::Mat &  mask,
double  factor 
)

Shrinks a binary mask by a scale factor around its centroid.

Equivalent to MATLAB shrink_mask.m:

  • Find boundary of mask
  • Compute centroid
  • Scale polygon by factor around centroid
  • Fill scaled polygon
Parameters
maskInput binary mask (CV_8U, nonzero = valid)
factorScale factor (0.9 = shrink to 90%)
Returns
Shrunk binary mask (CV_8U)

Definition at line 21 of file matlab_functions.cpp.

◆ meanFiniteEdgeLength()

static double cppxdic::meanFiniteEdgeLength ( const std::vector< int > &  faces,
const std::vector< Eigen::Vector3d > &  vertices 
)
static

Definition at line 583 of file surface_stitching.cpp.

◆ parseTrialList()

std::vector< int > cppxdic::parseTrialList ( const std::string &  spec)
inline

Parse a comma/space-separated list of integer trial IDs.

Accepts e.g. "7,12,25" or "7 12 25" or "7, 12 , 25".

Definition at line 42 of file trial_selection.h.

◆ points3dFromJson()

static Point3DFrame cppxdic::points3dFromJson ( const nlohmann::json &  j)
static

Definition at line 244 of file data_serializer.cpp.

◆ points3dToJson()

static nlohmann::json cppxdic::points3dToJson ( const Point3DFrame &  pts)
static

Definition at line 235 of file data_serializer.cpp.

◆ raySetTriangleIntersect()

static std::vector< Eigen::Vector3d > cppxdic::raySetTriangleIntersect ( const std::vector< Eigen::Vector3d > &  origins,
const std::vector< Eigen::Vector3d > &  dirs,
const std::vector< int > &  faces,
const std::vector< Eigen::Vector3d > &  vertices,
double  eps = 1e-6 
)
static

Definition at line 512 of file surface_stitching.cpp.

◆ rayTriangleHit()

static double cppxdic::rayTriangleHit ( const Eigen::Vector3d &  O,
const Eigen::Vector3d &  D,
const Eigen::Vector3d &  A,
const Eigen::Vector3d &  B,
const Eigen::Vector3d &  C,
double  eps 
)
static

Definition at line 328 of file surface_stitching.cpp.

◆ readCalibrationData()

void cppxdic::readCalibrationData ( std::ifstream &  ifs,
CalibrationData &  calib 
)

Definition at line 125 of file dic_structures.cpp.

◆ readDispData()

void cppxdic::readDispData ( std::ifstream &  ifs,
DispData &  disp 
)

Definition at line 96 of file dic_structures.cpp.

◆ readDistortionData()

void cppxdic::readDistortionData ( std::ifstream &  ifs,
DistortionData &  dist 
)

Definition at line 186 of file dic_structures.cpp.

◆ readPOD()

template<typename T >
void cppxdic::readPOD ( std::ifstream &  ifs,
T &  value 
)

Definition at line 20 of file dic_structures.cpp.

◆ readPoints3D()

void cppxdic::readPoints3D ( std::ifstream &  ifs,
Point3DFrame &  pts 
)

Definition at line 85 of file dic_structures.cpp.

◆ readString()

void cppxdic::readString ( std::ifstream &  ifs,
std::string &  str 
)

Definition at line 51 of file dic_structures.cpp.

◆ readStringMap()

void cppxdic::readStringMap ( std::ifstream &  ifs,
std::map< std::string, std::string > &  map 
)

Definition at line 214 of file dic_structures.cpp.

◆ readSubjectTrialCsv()

std::vector< SubjectTrial > cppxdic::readSubjectTrialCsv ( const std::string &  path)
inline

Read subject_trial.csv (header "subject,trial") into rows, skipping the header line and any blank/comment lines.

Each data line must contain at least two comma-separated fields: subject, trial.

Definition at line 83 of file trial_selection.h.

◆ readTrialsFile()

std::vector< int > cppxdic::readTrialsFile ( const std::string &  path)
inline

Read a trials file: one trial ID per line.

Blank lines and lines whose first non-whitespace character is '#' are ignored.

Definition at line 63 of file trial_selection.h.

◆ readVector()

template<typename T >
void cppxdic::readVector ( std::ifstream &  ifs,
std::vector< T > &  vec 
)

Definition at line 34 of file dic_structures.cpp.

◆ readVector2D()

template<typename T >
void cppxdic::readVector2D ( std::ifstream &  ifs,
std::vector< std::vector< T > > &  vec 
)

Definition at line 70 of file dic_structures.cpp.

◆ removeFacesContainingVertex()

static bool cppxdic::removeFacesContainingVertex ( const std::vector< int > &  F,
std::vector< bool > &  CT,
int  v_remove 
)
static

Definition at line 610 of file surface_stitching.cpp.

◆ removeOverlapSurfaces()

std::pair< std::vector< bool >, std::vector< bool > > cppxdic::removeOverlapSurfaces ( const std::vector< int > &  faces1,
const std::vector< int > &  faces2,
const std::vector< Eigen::Vector3d > &  vertices1,
const std::vector< Eigen::Vector3d > &  vertices2,
double  min_gap,
bool  pair_forced = false 
)

Remove overlapping regions from two surfaces Matches MATLAB: removeOverlapSurface_temp_2018_10_30(F1, F2, V1, V2, [], [], minGap, pairforced)

Parameters
faces1First surface faces
faces2Second surface faces
vertices1First surface vertices
vertices2Second surface vertices
min_gapMinimum gap threshold for overlap detection
Returns
Pair of boolean masks (keep face 1, keep face 2)

Definition at line 642 of file surface_stitching.cpp.

◆ run_cuncorr_dic()

ncorr::DIC_analysis_output cppxdic::run_cuncorr_dic ( const std::vector< ncorr::Image2D > &  imgs,
const ncorr::ROI2D &  roi,
const CuncorrDicConfig &  cfg,
CuncorrDicInfo *  info = nullptr 
)

Run cuNCorr in sequence mode (fixed reference = imgs[0], warm-start each frame) over the stack against the full-resolution roi.

Returns a raw Lagrangian, pixel-unit DIC_analysis_output on the reduced grid (one Disp2D per current frame).

Exceptions
std::invalid_argumentif fewer than 2 images.

Definition at line 53 of file cuncorr_dic.cpp.

◆ setStitchRayAccel()

void cppxdic::setStitchRayAccel ( bool  enabled)

Enable/disable the AABB-hierarchy prefilter used by the overlap-removal ray casts.

Off by default. The prefilter is exact (a ray that hits a triangle also hits its padded bounding box, so nothing is pruned that could have been hit) and only changes how many triangles are tested per ray: O(log F) box tests instead of O(F) triangle tests. On rigs with many pairs the brute-force path is the dominant cost of Step E.

Process-wide, set once from Config::step_e_ray_bvh before stitching.

Definition at line 372 of file surface_stitching.cpp.

◆ slurmArrayTaskId()

int cppxdic::slurmArrayTaskId ( )
inline

Resolve SLURM_ARRAY_TASK_ID from the environment.

Returns
the task id, or -1 if the variable is unset/empty.

Definition at line 120 of file trial_selection.h.

◆ stitchPairsGeometric()

DIC3Dcombined cppxdic::stitchPairsGeometric ( const std::vector< DIC3DpairResults > &  all_pairs,
const std::vector< int > &  pair_order,
bool  pair_forced = false 
)

Geometric stitching with overlap removal and boundary zipping Matches MATLAB's DIC3DsurfaceStitch.m with geometric stitching enabled.

Parameters
all_pairsVector of DIC3DpairResults structures, one per stereo pair
pair_orderOrder in which to stitch pairs (1-indexed, matching MATLAB pairIndList)
Returns
Stitched DIC3Dcombined structure with overlaps removed

Definition at line 1077 of file surface_stitching.cpp.

◆ stitchPairsSimple()

DIC3Dcombined cppxdic::stitchPairsSimple ( const std::vector< DIC3DpairResults > &  all_pairs)

Simple append-based stitching for multiple stereo pairs.

Simple append-based stitching (no geometric overlap removal) Equivalent to Matlab lines 450-479 (when pairIndList is empty)

Concatenates all pairs together with proper index offsetting. Does not perform geometric overlap removal.

Parameters
all_pairsVector of DIC3DpairResults structures, one per stereo pair
Returns
Stitched DIC3Dcombined structure with all pairs combined

Definition at line 25 of file surface_stitching.cpp.

◆ stitchRayAccel()

bool cppxdic::stitchRayAccel ( )

Current state of the ray-cast prefilter (see setStitchRayAccel).

Definition at line 373 of file surface_stitching.cpp.

◆ strainTensorToJson()

static nlohmann::json cppxdic::strainTensorToJson ( const StrainTensor &  E)
static

Definition at line 359 of file data_serializer.cpp.

◆ trim()

std::string cppxdic::trim ( const std::string &  s)
inline

Trim leading/trailing whitespace (spaces, tabs, CR, LF).

Definition at line 30 of file trial_selection.h.

◆ writeCalibrationData()

void cppxdic::writeCalibrationData ( std::ofstream &  ofs,
const CalibrationData &  calib 
)

Definition at line 101 of file dic_structures.cpp.

◆ writeDispData()

void cppxdic::writeDispData ( std::ofstream &  ofs,
const DispData &  disp 
)

Definition at line 91 of file dic_structures.cpp.

◆ writeDistortionData()

void cppxdic::writeDistortionData ( std::ofstream &  ofs,
const DistortionData &  dist 
)

Definition at line 153 of file dic_structures.cpp.

◆ writePOD()

template<typename T >
void cppxdic::writePOD ( std::ofstream &  ofs,
const T &  value 
)

Definition at line 15 of file dic_structures.cpp.

◆ writePoints3D()

void cppxdic::writePoints3D ( std::ofstream &  ofs,
const Point3DFrame &  pts 
)

Definition at line 79 of file dic_structures.cpp.

◆ writeString()

void cppxdic::writeString ( std::ofstream &  ofs,
const std::string &  str 
)

Definition at line 43 of file dic_structures.cpp.

◆ writeStringMap()

void cppxdic::writeStringMap ( std::ofstream &  ofs,
const std::map< std::string, std::string > &  map 
)

Definition at line 177 of file dic_structures.cpp.

◆ writeVector()

template<typename T >
void cppxdic::writeVector ( std::ofstream &  ofs,
const std::vector< T > &  vec 
)

Definition at line 25 of file dic_structures.cpp.

◆ writeVector2D()

template<typename T >
void cppxdic::writeVector2D ( std::ofstream &  ofs,
const std::vector< std::vector< T > > &  vec 
)

Definition at line 61 of file dic_structures.cpp.

◆ zipBoundaryCurves()

std::vector< int > cppxdic::zipBoundaryCurves ( const std::vector< int > &  curve1,
const std::vector< int > &  curve2,
const std::vector< Eigen::Vector3d > &  V_combined 
)

Zip two boundary curves together by creating a triangle strip.

Simplified equivalent of MATLAB's delaunayZip. Uses greedy advancing-front: picks the shorter diagonal at each step.

Parameters
curve1Ordered vertex indices of boundary curve 1
curve2Ordered vertex indices of boundary curve 2 (already offset for combined mesh)
V_combinedCombined vertex positions [V1; V2]
Returns
New faces (flat array) connecting the two curves

Definition at line 999 of file surface_stitching.cpp.

Variable Documentation

◆ g_stitch_ray_bvh

bool cppxdic::g_stitch_ray_bvh = false
static

Definition at line 370 of file surface_stitching.cpp.

◆ scalar_dims

size_t cppxdic::scalar_dims[2] = {1, 1}
static

Definition at line 20 of file mat_writer.cpp.