(二)PaddleOCR 编译 ocr_system.dll

摘要:
包括/ocr_ rec.h>__declspec(dllexport)简历;字符串路径(argv[2]);imread(img_path;imread_COLOR):DBDetectordet(config.det_model_dir;config.gpu_id:config.max_sid_len;config.use_mkldnn;

(二)PaddleOCR 编译 ocr_system.dll第1张

(二)PaddleOCR 编译 ocr_system.dll第2张

 选中ocr_system项目 右键-->仅用于项目-->仅生成ocr_system, 生成ocr_system.dll,打开cmd cd到Release目录下,就可以看到ocr_system.dll了。

下图中的Debug在编译的时候记得换成Release,不然就会报下图错误列表中的错误。

(二)PaddleOCR 编译 ocr_system.dll第3张

这样ocr_system.dll 和 ocr_system.exe都生成了就可以为下一步做winform ocr识别做基础了。

ocr_system c++中 main.cpp代码如下:

(二)PaddleOCR 编译 ocr_system.dll第4张(二)PaddleOCR 编译 ocr_system.dll第5张
#include "glog/logging.h"
#include "omp.h"
#include "opencv2/core.hpp"
#include "opencv2/imgcodecs.hpp"
#include "opencv2/imgproc.hpp"
#include <chrono>
#include <iomanip>
#include <iostream>
#include <ostream>
#include <vector>

#include <cstring>
#include <fstream>
#include <numeric>

#include <include/config.h>
#include <include/ocr_det.h>
#include <include/ocr_rec.h>
//#include"ocr.h"
using namespace std;
using namespace cv;
using namespace PaddleOCR;

/*
1.返回框选字体;
2.返回解析字符串
*/

extern "C" __declspec(dllexport) cv::Mat * LoadModel(char* input, int width, int height);
__declspec(dllexport) cv::Mat* LoadModel(char* input, int width, int height)
{

    OCRConfig config("D:\Paddle\PaddleOCR\deploy\cpp_infer\tools\config.txt");

    config.PrintConfigInfo();

    //std::string img_path(argv[2]);
    //cv::Mat srcimg = cv::imread(img_path, cv::IMREAD_COLOR);
    cv::Mat srcimg(height, width, CV_8UC3, input);

    DBDetector det(config.det_model_dir, config.use_gpu, config.gpu_id,
        config.gpu_mem, config.cpu_math_library_num_threads,
        config.use_mkldnn, config.max_side_len, config.det_db_thresh,
        config.det_db_box_thresh, config.det_db_unclip_ratio,
        config.use_polygon_score,config.visualize,
        config.use_tensorrt, config.use_fp16);

    Classifier* cls = nullptr;
    if (config.use_angle_cls == true) {
        cls = new Classifier(config.cls_model_dir, config.use_gpu, config.gpu_id,
            config.gpu_mem, config.cpu_math_library_num_threads,
            config.use_mkldnn, config.cls_thresh,
            config.use_tensorrt, config.use_fp16);
    }

    CRNNRecognizer rec(config.rec_model_dir, config.use_gpu, config.gpu_id,
        config.gpu_mem, config.cpu_math_library_num_threads,
        config.use_mkldnn, config.char_list_file,
        config.use_tensorrt, config.use_fp16);

    auto start = std::chrono::system_clock::now();
    std::vector<std::vector<std::vector<int>>> boxes;
    // 检测
    cv::Mat ocrImage;
    ocrImage = det.Run(srcimg, boxes);
    // 识别
    rec.Run(boxes, srcimg, cls);
    auto end = std::chrono::system_clock::now();
    auto duration =
        std::chrono::duration_cast<std::chrono::microseconds>(end - start);
    std::cout << "Cost  "
        << double(duration.count()) *
        std::chrono::microseconds::period::num /
        std::chrono::microseconds::period::den
        << "s" << std::endl;
    cv::Mat gray;
    cv::cvtColor(srcimg, gray, COLOR_BGR2GRAY);
    return new cv::Mat(ocrImage);
}
View Code

先到这里,后面继续更新。

(二)PaddleOCR 编译 ocr_system.dll第6张

免责声明:文章转载自《(二)PaddleOCR 编译 ocr_system.dll》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇B样条基函数的定义及系数的意义用navicate 连接本地数据库提示用户名/口令无效下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

js前端使用jOrgChart插件实现组织架构图的展示

项目要做组织架构图,要把它做成自上而下的树形结构。  需要购买阿里云产品和服务的,点击此链接领取优惠券红包,优惠购买哦,领取后一个月内有效: https://promotion.aliyun.com/ntms/yunparter/invite.html?userCode=fp9ccf07 一、说明 (1)通过后台查询数据库,生成树形数组结构,返回到前台。...

Eclipse护眼技巧

作为一名IT工作者,无时无刻不需要浏览网页编写代码。眼睛长时间接受高强度冲击容易造成损伤。介绍几种方法缓解你的眼疲劳! 一、Eclipse主题设置        夜间模式下选择夜间主题当然是最合适的。         步骤:WIndows-->Preference-->General-->Appearance 注意:此时切换之后,若控制...

以前整理的网络上免费API接口

以前整理的一些免费的API接口,具体是否好用还需要时间测试,但是先分享给大家。 天气接口 聚合数据: http://op.juhe.cn/onebox/weather/query 用例 官方文档 来源:weather.com 百度接口: http://api.map.baidu.com/telematics/v3/weather?location=嘉兴...

稍为改写了下DropBrute用于IPV6检测nginx的access_log

#!/bin/sh # # DropBrute.sh @20130516 # # minimalist OpenWRT/dropbear ssh brute force attack banning script # # Installation steps: # # 1) Optionally edit the variables in the head...

如何禁止 iPhone Safari video标签视频自动全屏?

最近做一个移动端微信页面项目,在微信页面中有视频播放,但是需要禁止IOS的自动全屏播放(前提必须使用video标签)。如: <video id="post" autoplay loop preload="auto"> <source src="foo.mp4" type="video/mp4"> </video> 在...

29网络偷包

偷包,就是在网络传输过程中,截取某一数据包,进行解析获取其发送的数据。 原理与TCP通信类似。只需在创建套接字时,参数不同。 fd = socket(PF_INET, SOCK_RAW, IPPROTO_TCP); PF_INET                      IPV4协议 SOCK_RAW            对原始网络协议访问 IPPRO...