Image Alignment¶
Image Alignment.
Public Functions¶
| Type | Name |
|---|---|
| int | SaigeInitializeAlignModule (const int gpuIndex, const int sourceWidth, const int sourceHeight, const int targetWidth, const int targetHeight) Function to activate the Saige Alignment function with the default preset ( prototype_a). |
| int | SaigeInitializeAlignModuleWithPreset (const int gpuIndex, const int sourceWidth, const int sourceHeight, const int targetWidth, const int targetHeight, const char * preset) Function to activate the Saige Alignment function with a specified alignment preset. |
| int | SaigeFinalizeAlignModule () Function to terminate the Saige Alignment function. Releases the GPU memory used by the function. |
| int | SaigeAlignImageFromByteArray (const unsigned char * sourceImage, const int sourceWidth, const int sourceHeight, const int sourceChannel, const unsigned char * targetImage, const int targetWidht, const int targetHeight, const int targetChannel, unsigned int flag, unsigned char * croppedSourceImage) Function to adjust the position of the Source image to match the Target image. |
| int | SaigeAlignImageFromByteArrayWithCoord (const unsigned char * sourceImage, const int sourceWidth, const int sourceHeight, const int sourceChannel, const unsigned char * targetImage, const int targetWidht, const int targetHeight, const int targetChannel, unsigned int flag, unsigned char * croppedSourceImage, int * cropCoords) Extended variant of SaigeAlignImageFromByteArray that also returns the pixel coordinates of the crop box applied to the Source image. |
| int | SaigeAlignImageFromFile (const char * sourceImagePath, const char * targetImagePath, int * cropWidth, int * cropHeight, int * cropChannel, unsigned char * croppedSourceImage) Not Implemented. |
Public Functions Documentation¶
SaigeInitializeAlignModule¶
Function to activate the Saige Alignment function with the default preset (prototype_a).
int SaigeInitializeAlignModule (
const int gpuIndex,
const int sourceWidth,
const int sourceHeight,
const int targetWidth,
const int targetHeight
)
Equivalent to SaigeInitializeAlignModuleWithPreset(gpuIndex, ..., nullptr). prototype_a adjusts the position of the Source image to match the Target image and crops it, so the Source image must be larger than the Target image. Use SaigeInitializeAlignModuleWithPreset for other alignment methods.
Parameters:
gpuIndexIndex of the GPU to use. Pass -1 to use the CPU.sourceWidthWidth of the Source image.sourceHeightHeight of the Source image.targetWidthWidth of the Target image.targetHeightHeight of the Target image.
Returns:
errorCode Returns 0 on success, or an error code if there is a failure.
SaigeInitializeAlignModuleWithPreset¶
Function to activate the Saige Alignment function with a specified alignment preset.
int SaigeInitializeAlignModuleWithPreset (
const int gpuIndex,
const int sourceWidth,
const int sourceHeight,
const int targetWidth,
const int targetHeight,
const char * preset
)
Behavior per preset:
* prototype_a (default): scan↔ODB, Source > Target. Crops a Target-sized region from the Source (GPU capable)
* scan_odb_mutual_information: img↔odb, Source = Target. Mutual-information based translation
* scan_scan_correlation: img↔img (different lighting), Source = Target. Correlation based translation
The translation presets (scan_odb_mutual_information, scan_scan_correlation) do not use a model and run on the CPU regardless of gpuIndex. If the Source and Target sizes differ, error code -419302 is returned. See SaigeAlignImageFromByteArrayWithCoord for the meaning of the aligned image and coordinates. The alignment module keeps a single preset per process; calling this function again releases the previous configuration and initializes the new preset.
Parameters:
gpuIndexIndex of the GPU to use. Pass -1 to use the CPU.sourceWidthWidth of the Source image.sourceHeightHeight of the Source image.targetWidthWidth of the Target image.targetHeightHeight of the Target image.presetPreset name or path to a.saigealignfile. A name resolves toSAIGE_HOME/SaigeVision/module/SaigeAlignment/checkpoint/<preset>.saigealign.nullptror an empty string selectsprototype_a.
Returns:
errorCode Returns 0 on success, or an error code if there is a failure. Returns FILE_NOT_FOUND if the preset file does not exist.
SaigeFinalizeAlignModule¶
Function to terminate the Saige Alignment function. Releases the GPU memory used by the function.
int SaigeFinalizeAlignModule ()
Returns:
errorCode Returns 0 on success, or an error code if there is a failure.
SaigeAlignImageFromByteArray¶
Function to adjust the position of the Source image to match the Target image.
int SaigeAlignImageFromByteArray (
const unsigned char * sourceImage,
const int sourceWidth,
const int sourceHeight,
const int sourceChannel,
const unsigned char * targetImage,
const int targetWidht,
const int targetHeight,
const int targetChannel,
unsigned int flag,
unsigned char * croppedSourceImage
)
The result has the Target size, so croppedSourceImage must hold targetWidth * targetHeight * sourceChannel bytes. The result is returned in RGB order regardless of the input channel order. See SaigeInitializeAlignModuleWithPreset for the behavior of each preset.
Parameters:
sourceImageThe byte array of the Source image.sourceWidthThe width of the Source image.sourceHeightThe height of the Source image.sourceChannelThe channel of the Source image.targetImageThe byte array of the Target image.targetWidhtThe width of the Target image.targetHeightThe height of the Target image.targetChannelThe channel of the Target image.flagInput image flag. SpecifySAIGE_IMAGE_BGRwhen the inputs are in BGR order (e.g. OpenCVcv::imread); otherwise RGB order is assumed.croppedSourceImageThe byte array that receives the Source image aligned to the Target.
Returns:
errorCode Returns 0 on success, or an error code if there is a failure.
SaigeAlignImageFromByteArrayWithCoord¶
Extended variant of SaigeAlignImageFromByteArray that also returns the pixel coordinates of the crop box applied to the Source image.
int SaigeAlignImageFromByteArrayWithCoord (
const unsigned char * sourceImage,
const int sourceWidth,
const int sourceHeight,
const int sourceChannel,
const unsigned char * targetImage,
const int targetWidht,
const int targetHeight,
const int targetChannel,
unsigned int flag,
unsigned char * croppedSourceImage,
int * cropCoords
)
Alignment behaves identically to SaigeAlignImageFromByteArray; additionally, the Source region placed in the result image is written to cropCoords as (x1, y1, x2, y2) in Source-image coordinates. The legacy symbol is kept for backward compatibility — use this variant only when coordinates are required.
* prototype_a: the region cropped from the Source; always inside the Source bounds.
* scan_odb_mutual_information / scan_scan_correlation: the Source is translated by (dx, dy), and the coordinates are (-dx, -dy, W - dx, H - dy), which may be negative or exceed W, H. Parts shifted out of the result are clipped and empty areas are filled with 0. If alignment fails, the original Source and (0, 0, W, H) are returned, which cannot be distinguished from an actual zero shift.
Parameters:
cropCoordsAn int[4] output array that receives the pixel coordinates (x1, y1, x2, y2) of the Source region placed in the result image. Passnullptrif the coordinates are not needed.
Returns:
errorCode Returns 0 on success, or an error code if there is a failure.
SaigeAlignImageFromFile¶
Not Implemented.
int SaigeAlignImageFromFile (
const char * sourceImagePath,
const char * targetImagePath,
int * cropWidth,
int * cropHeight,
int * cropChannel,
unsigned char * croppedSourceImage
)