콘텐츠로 이동

이미지 정렬 기능

이미지 정렬 기능

Public Functions

Type Name
int SaigeInitializeAlignModule (const int gpuIndex, const int sourceWidth, const int sourceHeight, const int targetWidth, const int targetHeight)
Saige Alignment 기능을 기본 preset(prototype_a)으로 활성화하는 함수입니다.
int SaigeInitializeAlignModuleWithPreset (const int gpuIndex, const int sourceWidth, const int sourceHeight, const int targetWidth, const int targetHeight, const char * preset)
정렬 방식(preset)을 지정하여 Saige Alignment 기능을 활성화하는 함수입니다.
int SaigeFinalizeAlignModule ()
Saige Alignment 기능을 종료하는 함수입니다. 기능에 사용된 GPU 메모리를 해제합니다.
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)
Source 이미지를 Target 이미지에 맞게 위치를 조정하는 함수입니다.
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)
SaigeAlignImageFromByteArray의 확장 버전으로, Source 이미지에 적용된 Crop 박스의 픽셀 좌표를 함께 반환합니다.
int SaigeAlignImageFromFile (const char * sourceImagePath, const char * targetImagePath, int * cropWidth, int * cropHeight, int * cropChannel, unsigned char * croppedSourceImage)
Not Implemented.

Public Functions Documentation

SaigeInitializeAlignModule

Saige Alignment 기능을 기본 preset(prototype_a)으로 활성화하는 함수입니다.

int SaigeInitializeAlignModule (
    const int gpuIndex,
    const int sourceWidth,
    const int sourceHeight,
    const int targetWidth,
    const int targetHeight
) 

SaigeInitializeAlignModuleWithPreset(gpuIndex, ..., nullptr)과 동일합니다. prototype_a는 Source 이미지를 Target 이미지에 맞게 위치를 조정하여 Crop하는 방식이므로, Source 이미지가 Target 이미지보다 커야 합니다. 다른 정렬 방식이 필요하면 SaigeInitializeAlignModuleWithPreset을 사용합니다.

Parameters:

  • gpuIndex 사용할 GPU의 인덱스입니다. CPU를 사용할 경우 -1을 입력합니다.
  • sourceWidth Source 이미지의 너비입니다.
  • sourceHeight Source 이미지의 높이입니다.
  • targetWidth Target 이미지의 너비입니다.
  • targetHeight Target 이미지의 높이입니다.

Returns:

errorCode 정상 작동 시 0을 리턴하고, 에러 발생 시 에러코드를 리턴합니다.

SaigeInitializeAlignModuleWithPreset

정렬 방식(preset)을 지정하여 Saige Alignment 기능을 활성화하는 함수입니다.

int SaigeInitializeAlignModuleWithPreset (
    const int gpuIndex,
    const int sourceWidth,
    const int sourceHeight,
    const int targetWidth,
    const int targetHeight,
    const char * preset
) 

preset별 동작은 다음과 같습니다. * prototype_a (기본값): scan↔ODB, Source > Target. Source에서 Target 크기 영역을 Crop (GPU 사용 가능) * scan_odb_mutual_information: img↔odb, Source = Target. 상호정보 기반 평행이동 정렬 * scan_scan_correlation: img↔img(조명이 다른 페어), Source = Target. 상관 기반 평행이동 정렬

평행이동 방식(scan_odb_mutual_information, scan_scan_correlation)은 모델을 사용하지 않아 gpuIndex와 무관하게 CPU로 동작하며, Source와 Target 크기가 다르면 에러 코드 -419302를 리턴합니다. 정렬 결과와 좌표의 의미는 SaigeAlignImageFromByteArrayWithCoord를 참고합니다. Alignment 모듈은 프로세스당 하나의 preset만 유지하며, 다시 호출하면 기존 설정을 해제하고 새 preset으로 초기화합니다.

Parameters:

  • gpuIndex 사용할 GPU의 인덱스입니다. CPU를 사용할 경우 -1을 입력합니다.
  • sourceWidth Source 이미지의 너비입니다.
  • sourceHeight Source 이미지의 높이입니다.
  • targetWidth Target 이미지의 너비입니다.
  • targetHeight Target 이미지의 높이입니다.
  • preset preset 이름 또는 .saigealign 파일 경로입니다. 이름을 주면 SAIGE_HOME/SaigeVision/module/SaigeAlignment/checkpoint/<preset>.saigealign을 사용합니다. nullptr 또는 빈 문자열이면 prototype_a를 사용합니다.

Returns:

errorCode 정상 작동 시 0을 리턴하고, 에러 발생 시 에러코드를 리턴합니다. preset 파일이 없으면 FILE_NOT_FOUND를 리턴합니다.

SaigeFinalizeAlignModule

Saige Alignment 기능을 종료하는 함수입니다. 기능에 사용된 GPU 메모리를 해제합니다.

int SaigeFinalizeAlignModule () 

Returns:

errorCode 정상 작동 시 0을 리턴하고, 에러 발생 시 에러코드를 리턴합니다.

SaigeAlignImageFromByteArray

Source 이미지를 Target 이미지에 맞게 위치를 조정하는 함수입니다.

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
) 

결과 이미지는 Target 크기이므로 croppedSourceImage의 크기는 targetWidth * targetHeight * sourceChannel이어야 합니다. 결과 이미지는 입력 채널 순서와 무관하게 RGB 순서로 반환됩니다. preset별 동작은 SaigeInitializeAlignModuleWithPreset을 참고합니다.

Parameters:

  • sourceImage Source 이미지의 바이트 배열입니다.
  • sourceWidth Source 이미지의 너비입니다.
  • sourceHeight Source 이미지의 높이입니다.
  • sourceChannel Source 이미지의 채널입니다.
  • targetImage Target 이미지의 바이트 배열입니다.
  • targetWidht Target 이미지의 너비입니다.
  • targetHeight Target 이미지의 높이입니다.
  • targetChannel Target 이미지의 채널입니다.
  • flag 입력 이미지 플래그입니다. 입력이 BGR 순서(예: OpenCV cv::imread)이면 SAIGE_IMAGE_BGR을 지정해야 하며, 지정하지 않으면 RGB 순서로 간주합니다.
  • croppedSourceImage Target에 맞게 정렬된 Source 이미지를 받을 바이트 배열입니다.

Returns:

errorCode 정상 작동 시 0을 리턴하고, 에러 발생 시 에러코드를 리턴합니다.

SaigeAlignImageFromByteArrayWithCoord

SaigeAlignImageFromByteArray의 확장 버전으로, Source 이미지에 적용된 Crop 박스의 픽셀 좌표를 함께 반환합니다.

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
) 

정렬 동작은 SaigeAlignImageFromByteArray와 동일하며, 추가로 결과 이미지에 들어간 Source 영역을 Source 이미지 좌표계 기준 (x1, y1, x2, y2)로 cropCoords에 기록합니다. 기존 시그니처는 하위 호환을 위해 유지되며, 좌표가 필요할 때만 본 함수를 사용하면 됩니다. * prototype_a: Source에서 잘라낸 영역이며 항상 Source 범위 안에 있습니다. * scan_odb_mutual_information / scan_scan_correlation: Source를 (dx, dy)만큼 이동한 결과로 좌표는 (-dx, -dy, W - dx, H - dy)이며 음수이거나 W, H를 넘을 수 있습니다. 결과 이미지에서 범위를 벗어난 영역은 잘리고 빈 영역은 0으로 채워집니다. 정렬에 실패하면 원본 Source와 (0, 0, W, H)를 반환하므로 실제 이동량이 0인 경우와 구분되지 않습니다.

Parameters:

  • cropCoords 결과 이미지에 들어간 Source 영역의 픽셀 좌표(x1, y1, x2, y2)를 담을 int[4] 배열입니다. 좌표가 필요 없다면 nullptr을 전달할 수 있습니다.

Returns:

errorCode 정상 작동 시 0을 리턴하고, 에러 발생 시 에러코드를 리턴합니다.

SaigeAlignImageFromFile

Not Implemented.

int SaigeAlignImageFromFile (
    const char * sourceImagePath,
    const char * targetImagePath,
    int * cropWidth,
    int * cropHeight,
    int * cropChannel,
    unsigned char * croppedSourceImage
)