SaigeVision C/C++ 1.5.0
SaigeVision API document for C/C++
 
Loading...
Searching...
No Matches
ExampleDetErrorHandling.cpp

This is an example of how to handle det's error code. More details about this example.

#include <iostream>
#include <string>
// User's error code
int SRErrorReturnCode = -1;
#define CheckSRDetErrors(status, handle, testResult)\
{ \
eErrorType e = status; \
if (e != NO_ERROR_OUT) \
{ \
PrintErrorType(e); \
SR_DestroyDetTestHandle(handle); \
SR_DeleteDetTestResult(testResult); \
return SRErrorReturnCode; \
} \
}
int main()
{
std::wstring data_dir = L"../../../examples/data";
std::wstring model_path = data_dir + L"/models/lego_sample_model.srDet";
DetTestHandle handle = nullptr;
eErrorType srStatus = SR_CreateDetTestHandleByWideCharPath_ErrorType(&handle, model_path.c_str());
if (srStatus != NO_ERROR_OUT || handle == nullptr)
{
std::cerr << "SaigeVision Detection Error: invalid file path" << std::endl;
std::cin.get();
return -1;
}
int gpu_index = -1;
CheckSRDetErrors(SR_LoadDetTestNetworkInGPU(handle, gpu_index), handle, nullptr);
std::cout << "SaigeVision successfully completed, please press enter key to terminate" << std::endl;
std::cin.get();
return 0;
}
eErrorType
Enumerator indicating error codes.
Definition: CommonHeaderDLL.h:30
@ NO_ERROR_OUT
Definition: CommonHeaderDLL.h:31
Header file for Detection Module.
eErrorType SR_CreateDetTestHandleByWideCharPath_ErrorType(DetTestHandle *detTestHandle, const wchar_t *filePath)
Create a DetTestHandle via wide char path.
void * DetTestHandle
Detection file handler.
Definition: DetectorTestDLL.h:52
eErrorType SR_DestroyDetTestHandle(DetTestHandle handle)
Destruct a DetTestHandle.
eErrorType SR_LoadDetTestNetworkInGPU(DetTestHandle handle, int GPUNumber)
Allocate required cpu & gpu memory.