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

This is an example of how to handle Segmentation'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";
if (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;
}
SegmentationTestDLL.h
Header file for segmentation module.
SR_LoadSegTestNetworkInGPU
eErrorType SR_LoadSegTestNetworkInGPU(SegTestHandle handle, int GPUNumber, int batchSize=1)
Allocate required cpu & gpu memory.
SR_CreateSegTestHandleByWideCharPath
SegTestHandle SR_CreateSegTestHandleByWideCharPath(const wchar_t *filePath)
Create a SegTestHandle via wide char path.
SR_DestroySegTestHandle
eErrorType SR_DestroySegTestHandle(SegTestHandle handle)
Destruct a SegTestHandle.
SegTestHandle
void * SegTestHandle
Segmentation file handler.
Definition: SegmentationTestDLL.h:90