SaigeVisionUtil.h¶
Go to the source code of this file.
#include "SaigeVisionAPI.h"
SaigeVision 예제를 실행하기 위해 필요한 함수가 정의되어 있습니다. 이미지 데이터 사용, 추론 결과 시각화 등에 사용됩니다.
Public Types¶
| Type | Name |
|---|---|
| enum | _SaigeImageType |
| typedef enum _SaigeImageType | SaigeImageType |
Public Functions¶
| Type | Name |
|---|---|
| void * | SaigeGetImageData (const char * imagePath, int * width, int * height, int * channels, int * type) SaigeGetImageData. |
| int | SaigeFreeImageData (void * image) SaigeFreeImageData. |
| int | SaigeColorCodeToRGB (const char * color, unsigned char * r, unsigned char * g, unsigned char * b) SaigeColorCodeToRGB. |
| int | SaigeDrawDetectedObjects (const void * image, const SaigeDetectedObject * objects, SaigeModelInfo * modelInfo, const int numOfDetectedObjects, const int width, const int height, const int channels, const int type, const int waitMS) SaigeDrawDetectedObjects. |
| int | SaigeDrawSegmentedObjects (const void * image, const SaigeSegmentedObject * objects, SaigeModelInfo * modelInfo, const int numOfSegmentedObjects, const int width, const int height, const int channels, const int type, const double overlayAlpha, const int waitMS) SaigeDrawSegmentedObjects. |
| int | SaigeDrawTextObjects (const void * image, const SaigeTextObject * objects, const int numBoxes, const int width, const int height, const int channels, const int type, const int waitMS) SaigeDrawTextObjects. |
| int | SaigeDrawHeatmap (const float * image, const int width, const int height, const int waitMS) SaigeDrawHeatmap. |
| int | SaigeDrawImage (const void * image, const int width, const int height, const int channels, const double alpha, const int type, const bool invert, const int waitMS) SaigeDrawImage. |
| int | SaigeDrawImageOverBase (const void * base_img, const void * img, const int width, const int height, const int channels_base, const int channels_img, const int type_base, const int type_img, const double alpha, const bool invert, const int waitMS) SaigeDrawImageOverBase. |
Public Types Documentation¶
_SaigeImageType¶
enum _SaigeImageType {
SV_U8 = 0,
SV_U16 = 1,
SV_F32 = 2,
SV_F64 = 3,
SV_FILEPATH = 4
};
SaigeImageType¶
enum _SaigeImageType SaigeImageType;
Public Functions Documentation¶
SaigeGetImageData¶
SaigeGetImageData.
void * SaigeGetImageData (
const char * imagePath,
int * width,
int * height,
int * channels,
int * type
)
Retrieves image data from the specified image path. For color images, the data is always returned in RGB order.
Parameters:
imagePathThe path to the image.width[out] The width of the image.height[out] The height of the image.channels[out] The number of channels in the image.type[out] The type of the image.
Returns:
image Returns the image data as a void* type.
See also: SaigeFreeImageData
SaigeFreeImageData¶
SaigeFreeImageData.
int SaigeFreeImageData (
void * image
)
Frees the memory of the image obtained from SaigeGetImageData.
Parameters:
imageThe image data for which to free the memory.
Returns:
errorCode Returns 0 on success, or an error code if there is a failure.
See also: SaigeGetImageData
SaigeColorCodeToRGB¶
SaigeColorCodeToRGB.
int SaigeColorCodeToRGB (
const char * color,
unsigned char * r,
unsigned char * g,
unsigned char * b
)
Converts a color code to RGB values. This function is useful for interpreting the color representation of classes in a model.
Parameters:
colorThe color code to convert.r[out] The R value of the RGB color.g[out] The G value of the RGB color.b[out] The B value of the RGB color.
Returns:
errorCode Returns 0 on success, or an error code if there is a failure.
See also: SaigeModelInfo::classColors
SaigeDrawDetectedObjects¶
SaigeDrawDetectedObjects.
int SaigeDrawDetectedObjects (
const void * image,
const SaigeDetectedObject * objects,
SaigeModelInfo * modelInfo,
const int numOfDetectedObjects,
const int width,
const int height,
const int channels,
const int type,
const int waitMS
)
Draws detected objects on the specified image and displays them. Useful for visualizing object detection results.
Parameters:
imageThe image data on which the detected objects will be drawn.objectsThe array of detected objects from inference.modelInfoThe model information, used for class names and color display.numOfDetectedObjectsThe number of detected objects.widthThe width of the image.heightThe height of the image.channelsThe number of channels in the image.typeThe type of the image. See SaigeImageType for reference.waitMSThe display duration in milliseconds; if set to 0, the display window must be closed manually.
Returns:
errorCode Returns 0 on success, or an error code if there is a failure.
See also: SaigeGetInferenceResultNumOfDetectedObjects, SaigeGetInferenceResultDetectedObjects
SaigeDrawSegmentedObjects¶
SaigeDrawSegmentedObjects.
int SaigeDrawSegmentedObjects (
const void * image,
const SaigeSegmentedObject * objects,
SaigeModelInfo * modelInfo,
const int numOfSegmentedObjects,
const int width,
const int height,
const int channels,
const int type,
const double overlayAlpha,
const int waitMS
)
Draws segmented objects on the specified image and displays them. Useful for visualizing segmentation results.
Parameters:
imageThe image data on which the segmented objects will be drawn.objectsThe array of segmented objects from inference.modelInfoThe model information, used for class names and color display.numOfSegmentedObjectsThe number of segmented objects.widthThe width of the image.heightThe height of the image.channelsThe number of channels in the image.typeThe type of the image. See SaigeImageType for reference.overlayAlphaThe transparency value for visualizing the segmented objects; the range is 0 to 1, where values closer to 1 indicate more transparency.waitMSThe display duration in milliseconds; if set to 0, the display window must be closed manually.
Returns:
errorCode Returns 0 on success, or an error code if there is a failure.
See also: SaigeGetInferenceResultNumOfSegmentedObjects, SaigeGetInferenceResultSegmentedObjects
SaigeDrawTextObjects¶
SaigeDrawTextObjects.
int SaigeDrawTextObjects (
const void * image,
const SaigeTextObject * objects,
const int numBoxes,
const int width,
const int height,
const int channels,
const int type,
const int waitMS
)
Displays the detected text areas as SaigeTextObject on the image. Currently, Korean characters will appear as '?', with support planned for the future.
Parameters:
imageThe image data where the detected text objects will be displayed.objectsThe array of detected SaigeTextObject structures.numBoxesThe number of detected text objects.widthThe width of the image.heightThe height of the image.channelsThe number of channels in the image.typeThe type of the image. See SaigeImageType for reference.waitMSThe display duration in milliseconds; if set to 0, the display window must be closed manually.
See also: SaigeTextObject
SaigeDrawHeatmap¶
SaigeDrawHeatmap.
int SaigeDrawHeatmap (
const float * image,
const int width,
const int height,
const int waitMS
)
Displays a heatmap image. This is useful for visualizing areas of interest or anomalies in the processed image.
Parameters:
imageThe heatmap image data.widthThe width of the heatmap.heightThe height of the heatmap.waitMSThe display duration in milliseconds; if set to 0, the display window must be closed manually.
Returns:
errorCode Returns 0 on success, or an error code if there is a failure.
See also: SaigeGetInferenceResultHeatmap
SaigeDrawImage¶
SaigeDrawImage.
int SaigeDrawImage (
const void * image,
const int width,
const int height,
const int channels,
const double alpha,
const int type,
const bool invert,
const int waitMS
)
Displays an image. This function is useful for visualizing images processed or analyzed by the system.
Parameters:
imageThe image data to be displayed.widthThe width of the image.heightThe height of the image.channelsThe number of channels in the image.alphaThe value multiplied by the pixel values of the image data.typeThe image data type.invertIf set totrue, the colors will be inverted.waitMSThe display duration in milliseconds; if set to 0, the display window must be closed manually.
Setting alpha value
When the image is of type unsigned char, it is recommended to set the pixel value range to 0-255.
When the image is of type float, it is recommended to set the pixel value range to 0-1.
Setting type
When the image is of type unsigned char, input 'SV_U8'.
When the image is of type unsigned short, input 'SV_U16'.
When the image is of type float, input 'SV_F32'.
Returns:
errorCode Returns 0 on success, or an error code if there is a failure.
See also: SaigeGetInferenceResultScoremapSEG, SaigeGetInferenceResultScoremapIAD, SaigeGetInferenceResultMask
SaigeDrawImageOverBase¶
SaigeDrawImageOverBase.
int SaigeDrawImageOverBase (
const void * base_img,
const void * img,
const int width,
const int height,
const int channels_base,
const int channels_img,
const int type_base,
const int type_img,
const double alpha,
const bool invert,
const int waitMS
)
Displays an image over a base image. This is useful for layering images, such as displaying annotations or overlays on top of a background image.
Parameters:
base_imgThe image data that will serve as the background.imgThe image data to be displayed on top of the background.widthThe width of both images; they must be the same width.heightThe height of both images; they must be the same height.channels_baseThe number of channels in the background image.channels_imgThe number of channels in the overlay image.type_baseThe data type of the background image. Refer to SaigeDrawImage for setting options.type_imgThe data type of the overlay image. Refer to SaigeDrawImage for setting options.alphaThe value multiplied with the pixel values of the overlay image; it does not affect the background image.invertIf set totrue, the colors of the overlay image will be inverted. This does not affect the background image.waitMSThe display duration in milliseconds; if set to 0, the display window must be closed manually.
Returns:
errorCode Returns 0 on success, or an error code if there is a failure.