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

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

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