SaigeVision C/C++  1.4.7
SaigeVision API document for C/C++
ExampleDetRuntime.cpp

This is an example of how to inspect sample images by using all the functions of Detection module. More details about this example.

#include "SRUtils.h"
/* define this variable when user want to use new score threshold other than preset values. */
//#define SR_USE_NEW_SCORE_THRESHOLD
/* define this variable when user want to use new pixel size threshold other than preset values. */
//#define SR_USE_NEW_PIXEL_SIZE_THRESHOLD
/* define this variable when user want to limit the forward time of classfication algorithm. */
//#define SR_USE_FORWARD_TIME_LIMIT
/* define this variable when user want to filter the detection outputs(boxes) by max number for each class. */
//#define SR_FILTER_OUTPUT_BY_MAX_NUMBER
int main()
{
std::wstring data_dir = L"../../../examples/data";
// trained model path
std::wstring trainedModelPath = data_dir + L"/models/lego_sample_model.srDet";
// image paths to classify
std::vector<std::wstring> imagePaths(5);
imagePaths[0] = data_dir + L"/images/Lego/sample1.png";
imagePaths[1] = data_dir + L"/images/Lego/sample2.png";
imagePaths[2] = data_dir + L"/images/Lego/sample3.png";
imagePaths[3] = data_dir + L"/images/Lego/sample4.png";
imagePaths[4] = data_dir + L"/images/Lego/sample5.png";
/***********************************************************
* 0. 이미지 인풋 타입 설정
* inputImageType -
* ImageFilePathMultiByteChar: from file path (multi byte char)
* ImageFilePathWideChar: from file path (wide char)
* UCGrayImage: from memory(8bit unsigned char gray image)
* UCColorImage: from memory(8bit unsigned char color image)
* UIColorImage: from memory(32bit unsigned int color image)
***********************************************************/
//eSRInputImageType inputImageType = eSRInputImageType::ImageFilePathMultiByteChar;
eSRInputImageType inputImageType = eSRInputImageType::ImageFilePathWideChar;
//eSRInputImageType inputImageType = eSRInputImageType::UCGrayImage;
//eSRInputImageType inputImageType = eSRInputImageType::UCColorImage;
//eSRInputImageType inputImageType = eSRInputImageType::UIColorImage;
unsigned char* ucImageData = nullptr; // unsigned char image data
unsigned int* uiImageData = nullptr; // unsigned int image data
/***********************************************************
* 0-1. 정보 띄우기 단계 설정 (Verbosity)
* verbosity -
* 0: only warning
* 1: warning + model info
* 2: warning + model info + result info
* 3: warning + model info + result info + image display
* displayTime - 결과 이미지 display 하는 시간 (milliseconds)
* resizeFactor - 결과 이미지 display 하는 스케일 (display 크기 = 원본 크기 * resizeFactor)
***********************************************************/
int verbosity = 3;
int displayTime = 100;
double resizeFactor = 1.0;
/***********************************************************
* 0-2. GPU 번호 설정
* gpuIndex - 사용하고자 하는 gpu의 번호
* Multi GPU 가 가능한 License의 경우에 한하여 gpuIndex를
* 0~3까지 설정해 줄 수 있다. 아닌 경우 gpuIndex는 0을 사용하여야 한다.
***********************************************************/
int gpuIndex = 0;
/***********************************************************
* 1. 모델 파일 및 검사 결과 handle 생성,
* Create handles for model files and inspection results
***********************************************************/
DetTestHandle handle = SR_CreateDetTestHandleByWideCharPath(trainedModelPath.c_str());
if (handle == nullptr)
{
std::cout << "Saige Vision failed: Please check the file path of trained model." << std::endl;
}
/***********************************************************
* 2. 클래스 정보 확인 (Optional)
* Check class information
***********************************************************/
// Print all detection test parameters
srStatus = SR_PrintDetTestParameters(handle);
if (srStatus != NO_ERROR_OUT)
{
PrintErrorType(srStatus, verbosity);
// if you get this error, it's possible that the handle is not created.
return -1;
}
// Get Detection test parameters one by one
int numberOfClassesOutput = 0;
int maxStrLenOfClassName = 0;
// Get the number of classes
srStatus = SR_GetDetTestNumberOfClasses(handle, &numberOfClassesOutput);
if (srStatus != NO_ERROR_OUT)
{
PrintErrorType(srStatus, verbosity);
// if you get this error, it's possible that input pointer is not allocated (nullptr).
return -1;
}
// Get the maximum length of class names
srStatus = SR_GetDetTestMaxStrLenOfClassName(handle, &maxStrLenOfClassName);
if (srStatus != NO_ERROR_OUT)
{
PrintErrorType(srStatus, verbosity);
// if you get this error, it's possible that input pointer is not allocated (nullptr).
return -1;
}
std::vector<std::string> classNames(numberOfClassesOutput);
std::vector<std::wstring> wClassNames(numberOfClassesOutput);
std::vector<int> classColorsOutput(numberOfClassesOutput);
std::vector<int> scoreThresholdOutput(numberOfClassesOutput);
std::vector<int> pixelSizeThresholdOutput(numberOfClassesOutput);
char* classNameOutput = new char[maxStrLenOfClassName];
wchar_t* wClassNameOutput = new wchar_t[maxStrLenOfClassName];
for (int i = 0; i < numberOfClassesOutput; i++)
{
// Get a color of single class
srStatus = SR_GetDetTestOneClassColor(handle, i, &(classColorsOutput[i]));
if (srStatus != NO_ERROR_OUT)
{
PrintErrorType(srStatus, verbosity);
// if you get this error, it's possible that the input index is out of bound(# of classes) or input pointer is not allocated (nullptr).
return -1;
}
// Get a name of single class by multi byte char (char*)
srStatus = SR_GetDetTestOneClassNameWithMultiByteChar(handle, i, classNameOutput);
if (srStatus != NO_ERROR_OUT)
{
PrintErrorType(srStatus, verbosity);
// if you get this error, it's possible that the input index is out of bound(# of classes) or input pointer is not allocated (nullptr).
return -1;
}
// Get a name of single class by wide char (wchar_t*)
srStatus = SR_GetDetTestOneClassNameWithWideChar(handle, i, wClassNameOutput);
if (srStatus != NO_ERROR_OUT)
{
PrintErrorType(srStatus, verbosity);
// if you get this error, it's possible that the input index is out of bound(# of classes) or input pointer is not allocated (nullptr).
return -1;
}
classNames[i] = classNameOutput;
wClassNames[i] = wClassNameOutput;
}
delete[] classNameOutput;
delete[] wClassNameOutput;
/***********************************************************
* 3. 검사 옵션 확인 및 수정 (Optional)
* Check inspection options and set new values
***********************************************************/
// Get the score threshold for each class
srStatus = SR_GetDetTestMinScoreThreshold(handle, scoreThresholdOutput.data());
if (srStatus != NO_ERROR_OUT)
{
PrintErrorType(srStatus, verbosity);
// if you get this error, it's possible that input pointer is not allocated (nullptr).
return -1;
}
// Get the area threshold for each class
srStatus = SR_GetDetTestPixelSizeThreshold(handle, pixelSizeThresholdOutput.data());
if (srStatus != NO_ERROR_OUT)
{
PrintErrorType(srStatus, verbosity);
// if you get this error, it's possible that input pointer is not allocated (nullptr).
return -1;
}
#ifdef SR_USE_NEW_SCORE_THRESHOLD
std::vector<int> scoreThresholdInput(numberOfClassesOutput);
for (int i = 0; i < numberOfClassesOutput; i++)
{
scoreThresholdInput[i] = 50; // set new score threshold for each class
}
srStatus = SR_SetDetTestMinScoreThreshold(handle, numberOfClassesOutput, scoreThresholdInput.data(), true);
if (srStatus != NO_ERROR_OUT)
{
PrintErrorType(srStatus, verbosity);
// if you get this error, it's possible that the input's [# of classes] does not match the model's or input pointer is not allocated (nullptr).
return -1;
}
#endif
#ifdef SR_USE_NEW_PIXEL_SIZE_THRESHOLD
std::vector<int> pixelSizeThresholdInput(numberOfClassesOutput);
for (int i = 0; i < numberOfClassesOutput; i++)
{
pixelSizeThresholdInput[i] = 0; // set new pixel-size threshold for each class
}
srStatus = SR_SetDetTestPixelSizeThreshold(handle, pixelSizeThresholdInput.data(), true);
if (srStatus != NO_ERROR_OUT)
{
PrintErrorType(srStatus, verbosity);
// if you get this error, it's possible that input pointer is not allocated (nullptr).
return -1;
}
#endif
#ifdef SR_USE_FORWARD_TIME_LIMIT
float timeLimit = 1100; // milliseconds
srStatus = SR_SetDetTestForwardTimeLimitVariables(handle, timeLimit, true, true);
if (srStatus != NO_ERROR_OUT)
{
PrintErrorType(srStatus, verbosity);
// if you get this error, it's possible that handle is not created.
return -1;
}
#endif
#ifndef SR_USE_FORWARD_TIME_LIMIT
srStatus = SR_SetDetTestIsToUseForwardTimeLimit(handle, false, true);
if (srStatus != NO_ERROR_OUT)
{
PrintErrorType(srStatus, verbosity);
// if you get this error, it's possible that handle is not created.
return -1;
}
#endif
#ifdef SR_FILTER_OUTPUT_BY_MAX_NUMBER
std::vector<int> maxNumberOfDetectionBoxes(numberOfClassesOutput);
for (size_t i = 0; i < numberOfClassesOutput; i++)
{
maxNumberOfDetectionBoxes[i] = 5; // set the maximum number of boxes which can be detected for each class
}
srStatus = SR_SetDetTestMaxNumberOfDetectionBoxesForEachClass(handle, numberOfClassesOutput, maxNumberOfDetectionBoxes.data(), true);
if (srStatus != NO_ERROR_OUT)
{
PrintErrorType(srStatus, verbosity);
// if you get this error, it's possible that the input's [# of classes] does not match the model's or input pointer is not allocated (nullptr).
return -1;
}
#endif
#ifndef SR_FILTER_OUTPUT_BY_MAX_NUMBER
std::vector<int> maxNumberOfDetectionBoxes(numberOfClassesOutput);
for (size_t i = 0; i < numberOfClassesOutput; i++)
{
maxNumberOfDetectionBoxes[i] = -1; // -1 indicates that filter is not applied
}
srStatus = SR_SetDetTestMaxNumberOfDetectionBoxesForEachClass(handle, numberOfClassesOutput, maxNumberOfDetectionBoxes.data(), true);
if (srStatus != NO_ERROR_OUT)
{
PrintErrorType(srStatus, verbosity);
// if you get this error, it's possible that handle is not created.
return -1;
}
#endif
/***********************************************************
* 4. 메모리를 GPU 및 CPU에 할당합니다.
* Allocate GPU and CPU memory
***********************************************************/
srStatus = SR_LoadDetTestNetworkInGPU(handle, gpuIndex);
if (srStatus != NO_ERROR_OUT)
{
PrintErrorType(srStatus, verbosity);
// if you get this error, it's possible that the inserted index is not applicable.
return -1;
}
for (size_t i_img = 0; i_img < imagePaths.size(); i_img++)
{
int h = 0, w = 0;
if (inputImageType == eSRInputImageType::UIColorImage)
{
uiImageData = (unsigned int*)GetImageDataByInputImageType(imagePaths[i_img], inputImageType, h, w);
}
else
{
ucImageData = (unsigned char*)GetImageDataByInputImageType(imagePaths[i_img], inputImageType, h, w);
}
/***********************************************************
* 5. 이미지 검사하기, Inspect images
***********************************************************/
if (inputImageType == eSRInputImageType::ImageFilePathMultiByteChar)
{
// Check if given image path(UNICODE) can be converted to ASCII CODE without any loss.
size_t sizeOfChar = 0;
size_t sizeOfWChar = wcslen(imagePaths[i_img].c_str());
size_t bufferSize = sizeOfWChar * 2;
std::vector<char> imagePathMB(bufferSize);
sizeOfChar = wcstombs(
imagePathMB.data(),
imagePaths[i_img].c_str(),
bufferSize
);
if (sizeOfChar != sizeOfWChar)
{
std::wcout << "Saige Vision FAILED: Wrong Image path" << imagePaths[i_img] << std::endl;
continue;
}
srStatus = SR_ApplyDetTestFromImageFile(handle, imagePathMB.data(), detTestResult);
}
else if (inputImageType == eSRInputImageType::ImageFilePathWideChar)
{
srStatus = SR_ApplyDetTestFromImageFileByWideCharPath(handle, imagePaths[i_img].c_str(), detTestResult);
}
else if (inputImageType == eSRInputImageType::UCGrayImage)
{
srStatus = SR_ApplyDetTestFrom8bitCharGrayArray(handle, ucImageData, h, w, detTestResult);
}
else if (inputImageType == eSRInputImageType::UCColorImage)
{
srStatus = SR_ApplyDetTestFrom8bitCharColorArray(handle, ucImageData, h, w, detTestResult);
}
else if (inputImageType == eSRInputImageType::UIColorImage)
{
srStatus = SR_ApplyDetTestFromUnsignedIntColorArray(handle, uiImageData, h, w, detTestResult);
}
if (srStatus != NO_ERROR_OUT)
{
PrintErrorType(srStatus, verbosity);
// if you get this error, it's possible that the input data is not loaded successfully.
if (verbosity >= 3)
{
DisplayFailedImageOnCVWindow(imagePaths[i_img], "FAIL TO DETECT", "Detection Result", displayTime, resizeFactor);
}
continue; // jump to next image
}
/***********************************************************
* 6. 검사 결과 받아오기, Retrieve inspection results
***********************************************************/
int numberOfBoxesOutput = 0;
long inspectionTimeOutput = 0, loadImageTimeOutput = 0;
// Get the number of detected boxes
srStatus = SR_GetDetTestResultNumberOfBoxes(detTestResult, &numberOfBoxesOutput);
if (srStatus != NO_ERROR_OUT)
{
PrintErrorType(srStatus, verbosity);
// if you get this error, it's possible that the input pointer is not allocated (nullptr).
continue; // jump to next image
}
// Get the inspection time
srStatus = SR_GetDetTestInspectionTime(detTestResult, &inspectionTimeOutput);
if (srStatus != NO_ERROR_OUT)
{
PrintErrorType(srStatus, verbosity);
// if you get this error, it's possible that the input pointer is not allocated (nullptr).
continue; // jump to next image
}
// Get the image-loading time
srStatus = SR_GetDetTestLoadImageTime(detTestResult, &loadImageTimeOutput);
if (srStatus != NO_ERROR_OUT)
{
PrintErrorType(srStatus, verbosity);
// if you get this error, it's possible that the input pointer is not allocated (nullptr).
continue; // jump to next image
}
std::vector<SR_DetectedBox> detectedBoxes(numberOfBoxesOutput);
// Get the information of all the detected boxes.
srStatus = SR_GetDetTestResultDetectedBoxes(detTestResult, numberOfBoxesOutput, detectedBoxes.data());
if (srStatus != NO_ERROR_OUT)
{
PrintErrorType(srStatus, verbosity);
// if you get this error, it's possible that the input's [# of boxes] does not match the result's or the input pointer is not allocated (nullptr).
continue; // jump to next image
}
// Display and draw
cv::Mat image = cv::Mat();
if (verbosity >= 3)
{
if (inputImageType == eSRInputImageType::UCGrayImage)
{
image = cv::Mat(h, w, CV_8UC1, ucImageData);
image = image.clone(); /* to prevent modifying raw data */
}
else if (inputImageType == eSRInputImageType::UCColorImage)
{
image = cv::Mat(h, w, CV_8UC3, ucImageData);
image = image.clone(); /* to prevent modifying raw data */
}
else if (inputImageType == eSRInputImageType::UIColorImage)
{
image = cv::Mat(h, w, CV_8UC4, uiImageData);
image = image.clone(); /* to prevent modifying raw data */
}
else
{
int isSuccess = OpenImageFile(imagePaths[i_img].c_str(), image);
if (isSuccess == 0)
{
std::cout << "Saige Vision FAILED: Fail to open image file to display" << std::endl;
continue;
}
}
if (image.channels() == 4)
{
cv::cvtColor(image, image, cv::COLOR_BGRA2BGR);
}
if (image.channels() == 1)
{
cv::cvtColor(image, image, cv::COLOR_GRAY2BGR);
}
}
if (verbosity >= 2)
{
std::cout << "====== Detection Test Result ======" << std::endl;
std::wcout << imagePaths[i_img] << std::endl;
std::cout << " - Number of final detected boxes: " << numberOfBoxesOutput << std::endl;
#ifdef SR_FILTER_OUTPUT_BY_MAX_NUMBER
int* numberOfBoxesBeforeFiltered = new int[numberOfClassesOutput];
SR_GetDetTestResultNumberOfBoxesBeforeFiltered(detTestResult, numberOfClassesOutput, numberOfBoxesBeforeFiltered);
std::cout << " - Number of raw detected boxes before filtering: " << std::endl;
for (size_t i_c = 0; i_c < numberOfClassesOutput; i_c++)
{
std::cout << " - " << classNames[i_c] << ": " << numberOfBoxesBeforeFiltered[i_c] << std::endl;
}
delete[] numberOfBoxesBeforeFiltered;
#endif
std::cout << " - Image Loading time: " << loadImageTimeOutput << std::endl << std::endl;
std::cout << " - Inspection time: " << inspectionTimeOutput << std::endl;
std::cout << " - Detected boxes information" << std::endl;
}
for (int i = 0; i < numberOfBoxesOutput; i++)
{
int xmin = static_cast<int>(detectedBoxes[i].box.x_tl);
int ymin = static_cast<int>(detectedBoxes[i].box.y_tl);
int xmax = static_cast<int>(detectedBoxes[i].box.x_br);
int ymax = static_cast<int>(detectedBoxes[i].box.y_br);
if (verbosity >= 2)
{
printf(" - %d-th box info(label, score, x_topLeft, y_topLeft, x_bottomRight, y_bottomRight): %d, %0.2f, %d, %d, %d, %d\n",
i, detectedBoxes[i].box.classIdx, detectedBoxes[i].box.score, xmin, ymin, xmax, ymax);
}
// plot
if (verbosity >= 3)
{
// get class color
int colorTmp = classColorsOutput[detectedBoxes[i].box.classIdx];
unsigned char r = (colorTmp >> 16) & 0xFF;
unsigned char g = (colorTmp >> 8) & 0xFF;
unsigned char b = (colorTmp) & 0xFF;
cv::Scalar classColor = cv::Scalar(b, g, r);
// draw rectangle
cv::Rect rect(xmin, ymin, xmax - xmin, ymax - ymin);
cv::rectangle(image, rect, classColor, 2, 8, 0);
cv::putText(image, classNames[detectedBoxes[i].box.classIdx], cv::Point(xmin, ymin), 2, 1.2, classColor, 3);
}
}
if (verbosity >= 3)
{
cv::namedWindow("Detection Result", cv::WINDOW_NORMAL);
cv::resizeWindow("Detection Result", image.size().width * resizeFactor, image.size().height * resizeFactor);
cv::imshow("Detection Result", image);
cv::waitKey(displayTime);
}
if (ucImageData != nullptr)
{
delete[] ucImageData;
}
if (uiImageData != nullptr)
{
delete[] uiImageData;
}
}
/***********************************************************
* 7. Handle 파괴, Destruct handles
***********************************************************/
srStatus = SR_DeleteDetTestResult(detTestResult);
if (srStatus != NO_ERROR_OUT)
{
PrintErrorType(srStatus, verbosity);
// if you get this error, it's possible that the input pointer is not allocated (nullptr).
return -1;
}
srStatus = SR_DestroyDetTestHandle(handle);
if (srStatus != NO_ERROR_OUT)
{
PrintErrorType(srStatus, verbosity);
// if you get this error, it's possible that the input pointer is not allocated (nullptr).
return -1;
}
std::cout << "SaigeVision successfully completed, please press enter key to terminate" << std::endl;
std::cin.get();
return 0;
}
SR_GetDetTestMinScoreThreshold
eErrorType SR_GetDetTestMinScoreThreshold(DetTestHandle handle, int *scoreThreshold)
Get Detection's score threshold for each class.
SR_GetDetTestOneClassNameWithWideChar
eErrorType SR_GetDetTestOneClassNameWithWideChar(DetTestHandle handle, const int classIdx, wchar_t *className)
Get a wide char name of certain class by given index.
SR_CreateDetTestHandleByWideCharPath
DetTestHandle SR_CreateDetTestHandleByWideCharPath(const wchar_t *filePath)
Create a DetTestHandle via wide char path.
SR_ApplyDetTestFromImageFileByWideCharPath
eErrorType SR_ApplyDetTestFromImageFileByWideCharPath(DetTestHandle handle, const wchar_t *imagePath, DetTestResult detTestResult)
Apply detection algorithm to image by file path.
SR_GetDetTestOneClassNameWithMultiByteChar
eErrorType SR_GetDetTestOneClassNameWithMultiByteChar(DetTestHandle handle, const int classIdx, char *className)
Get a multi byte char name of certain class by given index.
SR_GetDetTestMaxStrLenOfClassName
eErrorType SR_GetDetTestMaxStrLenOfClassName(DetTestHandle handle, int *len)
Get a maximum length of class name.
SR_ApplyDetTestFromImageFile
eErrorType SR_ApplyDetTestFromImageFile(DetTestHandle handle, const char *imagePath, DetTestResult detTestResult)
Apply detection algorithm to image by file path.
SR_GetDetTestPixelSizeThreshold
eErrorType SR_GetDetTestPixelSizeThreshold(DetTestHandle handle, int *areaThreshold)
Get Detection's area threshold for each class.
SR_SetDetTestMinScoreThreshold
eErrorType SR_SetDetTestMinScoreThreshold(DetTestHandle handle, int numOfClasses, int *scoreThreshold, bool writeOnModelFile=true)
Set Detection's score threshold for each class.
SR_GetDetTestNumberOfClasses
eErrorType SR_GetDetTestNumberOfClasses(DetTestHandle handle, int *numberOfClasses)
Get the number of classes.
GetImageDataByInputImageType
void * GetImageDataByInputImageType(const std::wstring imagePath, const eSRInputImageType inputType, int &height, int &width, int *channel=nullptr)
Get image data from a file path and image size by an allocated pointer for example projects.
Definition: SRUtils.h:138
SR_SetDetTestIsToUseForwardTimeLimit
eErrorType SR_SetDetTestIsToUseForwardTimeLimit(DetTestHandle handle, bool bIsToUseForwardTimeLimit, bool writeOnModelFile=true)
Set the boolean whether the current model is using time limit or not.
SR_SetDetTestMaxNumberOfDetectionBoxesForEachClass
eErrorType SR_SetDetTestMaxNumberOfDetectionBoxesForEachClass(DetTestHandle handle, int numOfClasses, int *maxNumBoxes, bool writeOnModelFile=true)
Set Max number of boxes.
DetectorTestDLL.h
Header file for Detection Module.
SR_GetDetTestResultNumberOfBoxes
eErrorType SR_GetDetTestResultNumberOfBoxes(DetTestResult detTestResult, int *numDetectedBoxes)
Get the number of detected boxes.
SR_GetDetTestResultDetectedBoxes
eErrorType SR_GetDetTestResultDetectedBoxes(DetTestResult detTestResult, const int numDetectedBoxes, SR_DetectedBox *detectedBoxes)
Get SR_DetectedBox.
SR_LoadDetTestNetworkInGPU
eErrorType SR_LoadDetTestNetworkInGPU(DetTestHandle handle, int GPUNumber)
Allocate required cpu & gpu memory.
SR_DestroyDetTestHandle
eErrorType SR_DestroyDetTestHandle(DetTestHandle handle)
Destruct a DetTestHandle.
eSRInputImageType
eSRInputImageType
Data Type of input Image for example projects.
Definition: SRUtils.h:23
SR_DeleteDetTestResult
eErrorType SR_DeleteDetTestResult(DetTestResult detTestResult)
Destruct a DetTestResult.
SR_ApplyDetTestFrom8bitCharGrayArray
eErrorType SR_ApplyDetTestFrom8bitCharGrayArray(DetTestHandle handle, const unsigned char *imageData, const int height, const int width, DetTestResult detTestResult)
Apply detection algorithm to 1-channel image by 8-bit data.
SR_GetDetTestInspectionTime
eErrorType SR_GetDetTestInspectionTime(DetTestResult detTestResult, long *inspectionTimeInLong)
Get the inspection time.
SR_GetDetTestOneClassColor
eErrorType SR_GetDetTestOneClassColor(DetTestHandle handle, const int classIdx, int *classColor)
Get a color of certain class by given index.
SR_GetDetTestResultNumberOfBoxesBeforeFiltered
eErrorType SR_GetDetTestResultNumberOfBoxesBeforeFiltered(DetTestResult detTestResult, int numClasses, int *numRawBoxes)
Get the number of raw detected boxes before filtered by Max number of boxes for each class.
SR_ApplyDetTestFrom8bitCharColorArray
eErrorType SR_ApplyDetTestFrom8bitCharColorArray(DetTestHandle handle, const unsigned char *imageData, const int height, const int width, DetTestResult detTestResult)
Apply detection algorithm to 3-channels(BGR) image by 8-bit data.
SR_SetDetTestForwardTimeLimitVariables
eErrorType SR_SetDetTestForwardTimeLimitVariables(DetTestHandle handle, float forwardTimeLimit, bool bIsToUseForwardTimeLimit, bool writeOnModelFile=true)
Set the Forward time limit variables.
SR_SetDetTestPixelSizeThreshold
eErrorType SR_SetDetTestPixelSizeThreshold(DetTestHandle handle, int *areaThreshold, bool writeOnModelFile=true)
Set Detection's area threshold for each class.
DetTestHandle
void * DetTestHandle
Detection file handler.
Definition: DetectorTestDLL.h:52
eErrorType
eErrorType
Enumerator indicating error codes.
Definition: CommonHeaderDLL.h:25
DisplayFailedImageOnCVWindow
void DisplayFailedImageOnCVWindow(std::wstring &imagePath, std::string failPhrase, std::string windowName, int displayTime, const float resizeFactor)
Display failed image on opencv window for example projects.
Definition: SRUtils.h:273
SR_PrintDetTestParameters
eErrorType SR_PrintDetTestParameters(DetTestHandle handle)
Print a model parameters (Detection's class information, inspection options...)
SRUtils.h
Header file of util functions for example projects.
SR_ApplyDetTestFromUnsignedIntColorArray
eErrorType SR_ApplyDetTestFromUnsignedIntColorArray(DetTestHandle handle, const unsigned int *imageData, const int height, const int width, DetTestResult detTestResult)
Apply detection algorithm to 4-channels(BGRA) image by 8-bit data.
SR_GetDetTestLoadImageTime
eErrorType SR_GetDetTestLoadImageTime(DetTestResult detTestResult, long *imageLoadingTimeInLong)
Get the image loading time.
NO_ERROR_OUT
@ NO_ERROR_OUT
Definition: CommonHeaderDLL.h:26
SR_MakeDetTestResult
DetTestResult SR_MakeDetTestResult()
Construct a DetTestResult.
DetTestResult
void * DetTestResult
Detection inspection results handler.
Definition: DetectorTestDLL.h:67
OpenImageFile
bool OpenImageFile(const std::wstring imagePath, cv::Mat &image, bool asCV8U=false)
Open image file for example projects.
Definition: SRUtils.h:74