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

MaskSeedSetup. More...

#include <mask_seed_setup.h>

Static Public Member Functions

static MaskSeedResult runGui (const cv::Mat &reference_image, int num_seeds, std::string &error_message)
 Interactive GUI setup using OpenCV highgui.
 
static MaskSeedResult loadFromFiles (const std::string &polygon_or_mask_path, const std::string &seed_path, const cv::Size &image_size, std::string &error_message)
 Non-interactive setup: load mask polygon (or mask image) and seed points from files.
 
static bool save (const MaskSeedResult &result, const std::string &out_prefix, std::string &error_message)
 Persist a result to disk.
 
static cv::Mat polygonToMask (const std::vector< cv::Point > &polygon, const cv::Size &image_size)
 Rasterise a polygon into an 8-bit (0/255) mask of the given size.
 
static std::vector< cv::Point > readPolygonFile (const std::string &path, std::string &error_message)
 Read a ".poly" polygon file.
 
static std::vector< SeedPoint > readSeedFile (const std::string &path, std::string &error_message)
 Read a ".seed" file.
 
static bool guiAvailable ()
 Returns true if this binary was compiled with GUI support.
 

Detailed Description

MaskSeedSetup.

Static helpers to create (GUI), load (non-GUI) and persist mask + seed data.

File formats (documented in README_xdic_stepsABC.md):

  • Mask polygon : plain-text ".poly" file, one "x y" pair per line (pixel coords), header line "# xdic mask polygon vN".
  • Mask image : 8-bit single channel PNG (0 / 255). Optional; regenerated from the polygon when only the polygon file is present.
  • Seed : plain-text ".seed" file, one "x y" pair per line, header line "# xdic seed points vN".

Definition at line 51 of file mask_seed_setup.h.

Member Function Documentation

◆ guiAvailable()

bool cppxdic::stepsABC::MaskSeedSetup::guiAvailable ( )
static

Returns true if this binary was compiled with GUI support.

Definition at line 41 of file mask_seed_setup.cpp.

◆ loadFromFiles()

MaskSeedResult cppxdic::stepsABC::MaskSeedSetup::loadFromFiles ( const std::string &  polygon_or_mask_path,
const std::string &  seed_path,
const cv::Size &  image_size,
std::string &  error_message 
)
static

Non-interactive setup: load mask polygon (or mask image) and seed points from files.

No window is created. This is the cluster path.

Parameters
polygon_or_mask_pathPath to a ".poly" polygon file OR an 8-bit mask image.
seed_pathPath to a ".seed" file.
image_sizeReference image size (used to rasterise the polygon).
error_messageFilled with a human readable message on failure.
Returns
MaskSeedResult (valid==false on error).

Definition at line 99 of file mask_seed_setup.cpp.

◆ polygonToMask()

cv::Mat cppxdic::stepsABC::MaskSeedSetup::polygonToMask ( const std::vector< cv::Point > &  polygon,
const cv::Size &  image_size 
)
static

Rasterise a polygon into an 8-bit (0/255) mask of the given size.

Definition at line 49 of file mask_seed_setup.cpp.

◆ readPolygonFile()

std::vector< cv::Point > cppxdic::stepsABC::MaskSeedSetup::readPolygonFile ( const std::string &  path,
std::string &  error_message 
)
static

Read a ".poly" polygon file.

Returns empty vector on error.

Definition at line 59 of file mask_seed_setup.cpp.

◆ readSeedFile()

std::vector< SeedPoint > cppxdic::stepsABC::MaskSeedSetup::readSeedFile ( const std::string &  path,
std::string &  error_message 
)
static

Read a ".seed" file.

Returns empty vector on error.

Definition at line 79 of file mask_seed_setup.cpp.

◆ runGui()

MaskSeedResult cppxdic::stepsABC::MaskSeedSetup::runGui ( const cv::Mat &  reference_image,
int  num_seeds,
std::string &  error_message 
)
static

Interactive GUI setup using OpenCV highgui.

Opens a window on the reference image, lets the user draw a polygon MASK (left-click to add vertices, right-click / ENTER to close the polygon) and then pick one or more seed points. Only compiled when XDIC_STEPSABC_GUI is defined; otherwise returns an invalid result with an error message.

Parameters
reference_imageReference image to draw on (grayscale or BGR).
num_seedsNumber of seed points to collect (>=1).
error_messageFilled with a human readable message on failure.
Returns
MaskSeedResult (valid==false on cancel / unavailable GUI).

Definition at line 290 of file mask_seed_setup.cpp.

◆ save()

bool cppxdic::stepsABC::MaskSeedSetup::save ( const MaskSeedResult &  result,
const std::string &  out_prefix,
std::string &  error_message 
)
static

Persist a result to disk.

Writes <out_prefix>.poly, <out_prefix>_mask.png and <out_prefix>.seed. Returns false (and sets error_message) on I/O error.

Definition at line 141 of file mask_seed_setup.cpp.


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