add dll version and its usage
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
// DLLUsageDemo.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
|
||||
//
|
||||
|
||||
#include <iostream>
|
||||
#include "LibEasyOCR-CPP.h"
|
||||
#include <opencv2/highgui/highgui.hpp>
|
||||
#include <opencv2/imgproc/imgproc.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::wstring detect_model = L"..\\EasyOCR-CPP\\DetectionModel.onnx";
|
||||
std::wstring recognize_model = L"..\\EasyOCR-CPP\\RecognitionModel-EN.onnx";
|
||||
std::string image = "..\\..\\vin.jpg";
|
||||
|
||||
uns::EasyOCR_CPP::GlobalOCRConfig().SetDetectModelPath(detect_model);
|
||||
uns::EasyOCR_CPP::GlobalOCRConfig().SetGPUUsage(uns::easyocr::GPUUsage::CPUOnly);
|
||||
uns::EasyOCR_CPP::SetRecognitionModel(recognize_model, uns::easyocr::CharsetType::EN);
|
||||
|
||||
if (!uns::EasyOCR_CPP::InitDetectionModel())
|
||||
{
|
||||
std::cout << "Detector Init Failure!" << std::endl;
|
||||
return -1;
|
||||
}
|
||||
if (!uns::EasyOCR_CPP::InitRecognitionModel())
|
||||
{
|
||||
std::cout << "Recognizer Init Failure!" << std::endl;
|
||||
return -2;
|
||||
}
|
||||
|
||||
cv::Mat img = uns::EOCR_SupportTools::ReadImage(image, true);
|
||||
if (img.empty())
|
||||
{
|
||||
std::cerr << "Failed to load image: " << image << std::endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
auto results = uns::EasyOCR_CPP::FullAuto(img);
|
||||
for (const auto& [index, info] : results)
|
||||
{
|
||||
const auto& [text, conf] = info;
|
||||
std::cout << "Box " << index << ": \"" << uns::EOCR_SupportTools::WtoA(text) << "\" Confidence=" << conf << "\n";
|
||||
}
|
||||
|
||||
uns::EasyOCR_CPP::CleanupOCR();
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user