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 | SaigeInitTextFormatting (SaigeTextFormatting * formatting) SaigeInitTextFormatting. |
| unsigned int | SaigeConvertImageType (const int channel, const int type) SaigeConvertImageType. |
| int | SaigeOverlaySegmentedObjects (const void * baseImage, const SaigeSegmentedObject * objects, SaigeModelInfo * modelInfo, const int numOfSegmentedObjects, const int width, const int height, const int channels, const int type, const bool isRGB, const double overlayAlpha, void * resultImage) SaigeOverlaySegmentedObjects. |
| int | SaigeOverlayDetectedObjects (const void * baseImage, const SaigeDetectedObject * objects, SaigeModelInfo * modelInfo, const int numOfDetectedObjects, const int width, const int height, const int channels, const int type, const bool withClassName, const bool isRGB, const double overlayAlpha, void * resultImage) SaigeOverlayDetectedObjects. |
| int | SaigeOverlayTextObjects (const void * baseImage, const SaigeTextObject * objects, const int numOfTextObjects, const int width, const int height, const int channels, const int type, const bool isRGB, const double overlayAlpha, const double textScale, void * resultImage) SaigeOverlayTextObjects. |
| int | SaigeOverlayHeatmap (const void * baseImage, const float * heatmap, const int width, const int height, const int channels, const int type, const bool isRGB, const double overlayAlpha, void * resultImage) SaigeOverlayHeatmaps. |
| int | SaigeShowImage (const void * image, const int width, const int height, const int channels, const int type, const bool isRGB, const bool invert, const double alpha, const int waitMS) SaigeShowImage. |
| 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¶
SaigeInitTextFormatting¶
SaigeInitTextFormatting.
void SaigeInitTextFormatting (
SaigeTextFormatting * formatting
)
Initializes the boolean array indicating the inclusion of character sets in the given SaigeTextFormatting to false for all values. This prepares the formatting settings for use in text recognition tasks.
Parameters:
formattingPointer to the variable to be set.
SaigeConvertImageType¶
SaigeConvertImageType.
unsigned int SaigeConvertImageType (
const int channel,
const int type
)
Converts the number of channels and SaigeImageType into the image flag macro used in SaigeInferFromByteArray. This function is useful for preparing image data for inference.
Parameters:
channelThe number of channels in the image.typeThe data type of the image. Refer to SaigeDrawImage for setting options.
Returns:
imageFlag Returns the converted image flag macro.
SaigeOverlaySegmentedObjects¶
SaigeOverlaySegmentedObjects.
int SaigeOverlaySegmentedObjects (
const void * baseImage,
const SaigeSegmentedObject * objects,
SaigeModelInfo * modelInfo,
const int numOfSegmentedObjects,
const int width,
const int height,
const int channels,
const int type,
const bool isRGB,
const double overlayAlpha,
void * resultImage
)
Draws segmented objects on a base image and stores the result in an output image. This function allows for the visualization of segmentation results overlaid on an original image.
Parameters:
baseImageThe base image data on which segmented objects will be drawn.objectsThe array of segmented objects detected from inference.modelInfoThe model information, used for class colors; if null, the color red will be used.numOfSegmentedObjectsThe number of segmented objects.widthThe width of the base and result images.heightThe height of the base and result images.channelsThe number of channels in the base and result images.typeThe type of the image. Refer to SaigeImageType for details.overlayAlphaThe transparency value for visualizing segmented objects; the range is 0 to 1, where values closer to 1 make the segmented objects more transparent.resultImage[out] The image data that stores the result with segmented objects drawn on it.
Returns:
errorCode Returns 0 on success, or an error code if there is a failure.
See also: SaigeGetInferenceResultNumOfSegmentedObjects, SaigeGetInferenceResultSegmentedObjects
SaigeOverlayDetectedObjects¶
SaigeOverlayDetectedObjects.
int SaigeOverlayDetectedObjects (
const void * baseImage,
const SaigeDetectedObject * objects,
SaigeModelInfo * modelInfo,
const int numOfDetectedObjects,
const int width,
const int height,
const int channels,
const int type,
const bool withClassName,
const bool isRGB,
const double overlayAlpha,
void * resultImage
)
Draws the bounding boxes of detected objects on a base image and stores the result in an output image. This function allows for the visualization of detection results overlaid on an original image.
Parameters:
baseImageThe base image data on which detected objects will be drawn.objectsThe array of detected objects from inference.modelInfoThe model information, used for class names and colors; if null, the color red will be used.numOfDetectedObjectsThe number of detected objects.widthThe width of the base and result images.heightThe height of the base and result images.channelsThe number of channels in the base and result images.typeThe type of the image. Refer to SaigeImageType for details.withClassNameIf set totrue, the class name of each detected object will also be displayed.isRGBIf set totrue, indicates that the image data is in RGB order.overlayAlphaThe transparency value for visualizing detected objects; the range is 0 to 1, where values closer to 1 make the detected objects more transparent.resultImage[out] The image data that stores the result with detected objects drawn on it.
Returns:
errorCode Returns 0 on success, or an error code if there is a failure.
See also: SaigeGetInferenceResultNumOfDetectedObjects, SaigeGetInferenceResultDetectedObjects
SaigeOverlayTextObjects¶
SaigeOverlayTextObjects.
int SaigeOverlayTextObjects (
const void * baseImage,
const SaigeTextObject * objects,
const int numOfTextObjects,
const int width,
const int height,
const int channels,
const int type,
const bool isRGB,
const double overlayAlpha,
const double textScale,
void * resultImage
)
Draws the OCR results, represented by SaigeTextObject, on a base image and stores the result in an output image. Currently, Korean text appears as '?', support for it is planned for future updates.
Parameters:
baseImageThe base image data on which SaigeTextObject will be drawn.objectsThe array of SaigeTextObject detected from inference.numOfSaigeTextObjectThe number of SaigeTextObject.widthThe width of the base and result images.heightThe height of the base and result images.channelsThe number of channels in the base and result images.typeThe type of the image. Refer to SaigeImageType for details.isRGBIf set totrue, indicates that the image data is in RGB order.overlayAlphaThe transparency value for visualizing SaigeTextObject; the range is 0 to 1, where values closer to 1 make the SaigeTextObject more transparent.resultImage[out] The image data that stores the result with SaigeTextObject drawn on it.
Returns:
errorCode Returns 0 on success, or an error code if there is a failure.
See also: SaigeGetInferenceResultNumOfSaigeTextObject, SaigeGetInferenceResultSaigeTextObject
SaigeOverlayHeatmap¶
SaigeOverlayHeatmaps.
int SaigeOverlayHeatmap (
const void * baseImage,
const float * heatmap,
const int width,
const int height,
const int channels,
const int type,
const bool isRGB,
const double overlayAlpha,
void * resultImage
)
Draws a colorized heatmap on a base image and stores the result in an output image. This function helps visualize the heatmap data in relation to the original image.
Parameters:
baseImageThe base image data on which the heatmap will be drawn.heatmapThe array of heatmap data obtained from the inspection results.widthThe width of the base and result images.heightThe height of the base and result images.channelsThe number of channels in the base and result images.typeThe type of the image. Refer to SaigeImageType for details.isRGBIf set totrue, indicates that the image data is in RGB order.overlayAlphaThe transparency value for visualizing the heatmap; the range is 0 to 1, where values closer to 1 make the heatmap more transparent.resultImage[out] The image data that stores the result with the heatmap drawn on it.
Returns:
errorCode Returns 0 on success, or an error code if there is a failure.
See also: SaigeGetInferenceResultHeatmap
SaigeShowImage¶
SaigeShowImage.
int SaigeShowImage (
const void * image,
const int width,
const int height,
const int channels,
const int type,
const bool isRGB,
const bool invert,
const double alpha,
const int waitMS
)
Displays an image in a separate window. This function is useful for visualizing images during development or debugging processes.
Parameters:
imageThe image data to be displayed.widthThe width of the image.heightThe height of the image.channelsThe number of channels in the image.typeThe data type of the image. Refer to SaigeImageType for setting options.isRGBIf set totrue, indicates that the image data is in RGB order.invertIf set totrue, the colors will be inverted during display.alphaThe value multiplied with the pixel values of the image data; this helps adjust the brightness of the displayed 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.
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.