打包NCNN模型为OCR加密包 - OcrEncryptModel
函数简介
将 PP-OCR NCNN 四文件(det/rec 的 .param / .bin)及可选识别字典打成欧拉 OCR 加密包并写入磁盘。
接口名称
OcrEncryptModel
DLL 调用
int OcrEncryptModel(long ola, string detParamPath, string detBinPath, string recParamPath, string recBinPath, string dictPath, string password, string savePath);
参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| ola | 长整数型 | OLAPlug 对象指针 |
| detParamPath | 字符串 | 检测模型 .param,如 PP_OCRv5_mobile_det.ncnn.param |
| detBinPath | 字符串 | 检测模型 .bin |
| recParamPath | 字符串 | 识别模型 .param |
| recBinPath | 字符串 | 识别模型 .bin |
| dictPath | 字符串 | 识别字典 UTF-8 文本(一行一字);空 则不写入包内字典 |
| password | 字符串 | 加密密码(UTF-8,不可为空) |
| savePath | 字符串 | 输出加密包路径 |
示例
OcrEncryptModel(ola,
"PP_OCRv5_mobile_det.ncnn.param", "PP_OCRv5_mobile_det.ncnn.bin",
"PP_OCRv5_mobile_rec.ncnn.param", "PP_OCRv5_mobile_rec.ncnn.bin",
"", "your_password", "D:\\models\\custom.omd");
返回值
整数型:1 成功,0 失败。
注意事项
- 产出魔数 OLAOENC1,与 YOLO 包 OLAYENC1 可区分。
dictPath为空为 v1 包(四段模型);非空为 v2 包(四段模型 + 字典)。- 自定义 rec 须与训练时
character_dict/ keys 一致;未打包字典时加载后使用内置ppocrv5_keys。 - Paddle 导出常见字典:
ppocr_keys_v1.txt、dict.txt、key_list.txt(每行一字,index 0 为 CTC blank)。
