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

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

#include <iostream>
#include <string>
// User's error code
int SRErrorReturnCode = -1;
#define CheckSRSegErrors(status, handle, testResult)\
{ \
eErrorType e = status; \
if (e != NO_ERROR_OUT) \
{ \
PrintErrorType(e); \
SR_DestroySegTestHandle(handle); \
SR_DeleteSegTestResult(testResult); \
return SRErrorReturnCode; \
} \
}
int main()
{
std::wstring data_dir = L"../../../examples/data";
std::wstring model_path = data_dir + L"/models/pcb_sample_model.srSeg";
SegTestHandle handle = nullptr;
eErrorType srStatus = SR_CreateSegTestHandleByWideCharPath_ErrorType(&handle, model_path.c_str());
if (srStatus != NO_ERROR_OUT || handle == nullptr)
{
std::cerr << "SaigeVision Segmentation Error: invalid file path" << std::endl;
std::cin.get();
return -1;
}
int gpu_index = -1;
CheckSRSegErrors(SR_LoadSegTestNetworkInGPU(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 segmentation module.
eErrorType SR_LoadSegTestNetworkInGPU(SegTestHandle handle, int GPUNumber, int batchSize=1)
Allocate required cpu & gpu memory.
void * SegTestHandle
Segmentation file handler.
Definition: SegmentationTestDLL.h:90
eErrorType SR_CreateSegTestHandleByWideCharPath_ErrorType(SegTestHandle *segTestHandle, const wchar_t *filePath)
Create a SegTestHandle via wide char path.
eErrorType SR_DestroySegTestHandle(SegTestHandle handle)
Destruct a SegTestHandle.