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

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

#include "OCRTestDLL.h"
#include <iostream>
#include <string>
// User's error code
int SRErrorReturnCode = -1;
#define CheckSROCRErrors(status, handle, testResult)\
{ \
eErrorType e = status; \
if (e != NO_ERROR_OUT) \
{ \
PrintErrorType(e); \
SR_DestroyOCRTestHandle(handle); \
SR_DeleteOCRTestResult(testResult); \
return SRErrorReturnCode; \
} \
}
int main()
{
std::wstring data_dir = L"../../../examples/data";
std::wstring boxModelPath = data_dir + L"/models/ocr.srOcrBox";
std::wstring textModelPath = data_dir + L"/models/ocr.srOcrText";
OCRTestHandle handle = SR_CreateOCRTestHandleByWideCharPath(boxModelPath.c_str(), textModelPath.c_str());
if (handle == nullptr)
{
std::cerr << "SaigeVision Segmentation Error: invalid file path" << std::endl;
std::cin.get();
return -1;
}
int gpu_index = -1;
CheckSROCRErrors(SR_LoadOCRTestNetworkInGPU(handle, gpu_index), handle, nullptr);
std::cout << "SaigeVision successfully completed, please press enter key to terminate" << std::endl;
std::cin.get();
return 0;
}
SR_DestroyOCRTestHandle
eErrorType SR_DestroyOCRTestHandle(OCRTestHandle handle)
Destruct a OCRTestHandle.
SR_LoadOCRTestNetworkInGPU
eErrorType SR_LoadOCRTestNetworkInGPU(OCRTestHandle handle, int GPUNumber)
Allocate required cpu & gpu memory.
SR_CreateOCRTestHandleByWideCharPath
OCRTestHandle SR_CreateOCRTestHandleByWideCharPath(const wchar_t *ocrBoxFilePath, const wchar_t *ocrTextFilePath)
Create a OCRTestHandle via wide char path.
OCRTestDLL.h
Header file for OCR Module.
OCRTestHandle
void * OCRTestHandle
OCR file handler.
Definition: OCRTestDLL.h:52