本教程将指导您如何使用OpenVINO在C# WinForm项目中部署PP-OCRv5模型。
项目使用以下NuGet包:
weights
文件夹,将上述文件放入其中。
项目根目录/
├── weights/
│ ├── PP-OCRv5_mobile_det_onnx.onnx
│ ├── PP-OCRv5_mobile_cls_onnx.onnx
│ ├── PP-OCRv5_mobile_rec_onnx.onnx
│ └── ppocrv5_dict.txt
├── Form1.cs
├── Form1.Designer.cs
└── Program.cs
在Form1.cs中,我们定义了模型路径和初始化OCR预测器:
private string det_model = Application.StartupPath + "\\weights\\PP-OCRv5_mobile_det_onnx.onnx";
private string cls_model = Application.StartupPath + "\\weights\\PP-OCRv5_mobile_cls_onnx.onnx";
private string rec_model = Application.StartupPath + "\\weights\\PP-OCRv5_mobile_rec_onnx.onnx";
private string key_path = Application.StartupPath + "\\weights\\ppocrv5_dict.txt";
private OCRPredictor ocr = null;
在Form1_Load事件中初始化模型:
RuntimeOption.RecOption.label_path = key_path;
ocr = new OCRPredictor(det_model, cls_model, rec_model);