ImFusion C++ SDK 4.5.0
ImFusion::OpticalTrackingMarkerIO Namespace Reference

Reading and writing OpticalTrackingMarker instances to/from various file formats. More...

Detailed Description

Reading and writing OpticalTrackingMarker instances to/from various file formats.

This namespace provides functions to serialize and deserialize optical tracking markers using different file formats. Supported formats include JSON, INI, and ROM (binary). The file format is automatically determined by the file extension.

Example usage:

// ... configure marker ...
// Save to file (format determined by extension)
// Load from file
auto loadedMarker = OpticalTrackingMarkerIO::loadFromFile("marker.ini");
if (loadedMarker) {
// Use marker
}
Represents a marker for optical tracking cameras.
Definition OpticalTrackingMarker.h:30
std::unique_ptr< OpticalTrackingMarker > loadFromFile(const Filesystem::Path &filename)
Loads a marker from a file.
bool saveToFile(const OpticalTrackingMarker &marker, const Filesystem::Path &filename)
Saves a marker to a file.

Typedefs

using SaveHandler = std::function<bool(const OpticalTrackingMarker&, const Filesystem::Path&)>
 Function type for saving a marker to a file.
using LoadHandler = std::function<std::unique_ptr<OpticalTrackingMarker>(const Filesystem::Path&)>
 Function type for loading a marker from a file.

Functions

bool saveToFile (const OpticalTrackingMarker &marker, const Filesystem::Path &filename)
 Saves a marker to a file.
std::unique_ptr< OpticalTrackingMarkerloadFromFile (const Filesystem::Path &filename)
 Loads a marker from a file.
void registerFileFormat (const std::string &extension, SaveHandler saveHandler, LoadHandler loadHandler)
 Registers a file format handler for a specific extension.
bool isFileFormatSupported (const std::string &extension)
 Checks if a file format handler is registered for the given extension.
std::vector< std::stringsupportedFileExtensions ()
 Returns a list of all supported file extensions.

Function Documentation

◆ saveToFile()

bool ImFusion::OpticalTrackingMarkerIO::saveToFile ( const OpticalTrackingMarker & marker,
const Filesystem::Path & filename )

Saves a marker to a file.

Format is determined by file extension.

Parameters
markerThe marker to save
filenamePath to the output file
Returns
True if successful, false otherwise

◆ loadFromFile()

std::unique_ptr< OpticalTrackingMarker > ImFusion::OpticalTrackingMarkerIO::loadFromFile ( const Filesystem::Path & filename)

Loads a marker from a file.

Format is determined by file extension.

Parameters
filenamePath to the input file
Returns
Unique pointer to loaded marker, or nullptr on failure

◆ registerFileFormat()

void ImFusion::OpticalTrackingMarkerIO::registerFileFormat ( const std::string & extension,
SaveHandler saveHandler,
LoadHandler loadHandler )

Registers a file format handler for a specific extension.

Parameters
extensionFile extension (e.g., "ini", "rom", "json") without the dot
saveHandlerFunction to save marker to file
loadHandlerFunction to load marker from file

◆ isFileFormatSupported()

bool ImFusion::OpticalTrackingMarkerIO::isFileFormatSupported ( const std::string & extension)

Checks if a file format handler is registered for the given extension.

Parameters
extensionFile extension without the dot
Returns
True if handler is registered
Search Tab / S to search, Esc to close