百度行驶证C++离线SDK V1.1 C#接入

百度行驶证C++离线SDK V1.1 C#接入

目录

说明

效果

项目

代码

下载


说明

自己根据SDK封装了动态库,然后C#调用。

SDK包结构

效果

项目

代码

using Newtonsoft.Json;
using System;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;

namespace CSharpWinformTest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        const string DllName = "DLSharp.dll";

        //行驶证正页

        [DllImport(DllName, EntryPoint = "dl_front_init_license", CallingConvention = CallingConvention.Cdecl)]
        internal extern static int dl_front_init_license(string key, string licenseFile, bool is_remote);

        [DllImport(DllName, EntryPoint = "dl_front_create", CallingConvention = CallingConvention.Cdecl)]
        internal extern static IntPtr dl_front_create();

        [DllImport(DllName, EntryPoint = "dl_front_init", CallingConvention = CallingConvention.Cdecl)]
        internal extern static int dl_front_init(IntPtr engine, string ini_path);

        [DllImport(DllName, EntryPoint = "dl_front_ocr", CallingConvention = CallingConvention.Cdecl)]
        internal extern static int dl_front_ocr(IntPtr engine, string image_path, StringBuilder ocr_result1, StringBuilder ocr_result2);

        [DllImport(DllName, EntryPoint = "dl_front_destroy", CallingConvention = CallingConvention.Cdecl)]
        internal extern static void dl_front_destroy(IntPtr engine);


        //行驶证副页

        [DllImport(DllName, EntryPoint = "dl_back_init_license", CallingConvention = CallingConvention.Cdecl)]
        internal extern static int dl_back_init_license(string key, string licenseFile, bool is_remote);

        [DllImport(DllName, EntryPoint = "dl_back_create", CallingConvention = CallingConvention.Cdecl)]
        internal extern static IntPtr dl_back_create();

        [DllImport(DllName, EntryPoint = "dl_back_init", CallingConvention = CallingConvention.Cdecl)]
        internal extern static int dl_back_init(IntPtr engine, string ini_path);

        [DllImport(DllName, EntryPoint = "dl_back_ocr", CallingConvention = CallingConvention.Cdecl)]
        internal extern static int dl_back_ocr(IntPtr engine, string image_path, StringBuilder ocr_result1, StringBuilder ocr_result2);

        [DllImport(DllName, EntryPoint = "dl_back_destroy", CallingConvention = CallingConvention.Cdecl)]
        internal extern static void dl_back_destroy(IntPtr engine);


        IntPtr front_engine;
        IntPtr back_engine;

        private void button1_Click(object sender, EventArgs e)
        {

            if (image_path == "")
            {
                return;
            }

            StringBuilder ocr_result1 = new StringBuilder(1024);
            StringBuilder ocr_result2 = new StringBuilder(1024);
            int res = dl_front_ocr(front_engine, image_path, ocr_result1, ocr_result2);
            if (res == 0)
            {

                Object jsonObject = JsonConvert.DeserializeObject(ocr_result1.ToString());
                textBox1.Text = JsonConvert.SerializeObject(jsonObject, Newtonsoft.Json.Formatting.Indented);
            }
            else
            {
                textBox1.Text = "识别失败";
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            string key = "AISEE_xingshizheng_win_0530_3_3";
            string licenseFile = Application.StartupPath + "\\license\\license.ini";
            int res = -1;
            string ini_path = "";

            res = dl_front_init_license(key, licenseFile, false);
            Console.WriteLine(res.ToString());

            front_engine = dl_front_create();

            ini_path = Application.StartupPath + "\\resource\\vehiclecard_front_resource";
            res = dl_front_init(front_engine, ini_path);
            Console.WriteLine(res.ToString());

            res = dl_back_init_license(key, licenseFile, false);
            Console.WriteLine(res.ToString());

            back_engine = dl_back_create();

            ini_path = Application.StartupPath + "\\resource\\vehiclecard_back_resource";
            res = dl_back_init(back_engine, ini_path);
            Console.WriteLine(res.ToString());

            image_path = Application.StartupPath + "\\front_images\\2.jpg";
            //image_path = Application.StartupPath + "\\back_images\\1.png";

            pictureBox1.Image = new Bitmap(image_path);
        }

        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            dl_front_destroy(front_engine);
            dl_back_destroy(back_engine);
        }

        string fileFilter = "*.*|*.bmp;*.jpg;*.jpeg;*.tiff;*.tiff;*.png";
        string image_path = "";

        private void button2_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = fileFilter;
            if (ofd.ShowDialog() != DialogResult.OK) return;
            pictureBox1.Image = null;
            image_path = ofd.FileName;
            pictureBox1.Image = new Bitmap(image_path);
            textBox1.Text = "";
        }

        private void button3_Click(object sender, EventArgs e)
        {
            if (image_path == "")
            {
                return;
            }

            StringBuilder ocr_result1 = new StringBuilder(1024);
            StringBuilder ocr_result2 = new StringBuilder(1024);
            int res = dl_back_ocr(back_engine, image_path, ocr_result1, ocr_result2);
            if (res == 0)
            {
                Object jsonObject = JsonConvert.DeserializeObject(ocr_result1.ToString());
                textBox1.Text = JsonConvert.SerializeObject(jsonObject, Newtonsoft.Json.Formatting.Indented);
            }
            else
            {
                textBox1.Text = "识别失败";
            }
        }

        private void button4_Click(object sender, EventArgs e)
        {
            image_path = Application.StartupPath + "\\front_images\\2.jpg";
            pictureBox1.Image = new Bitmap(image_path);
        }

        private void button5_Click(object sender, EventArgs e)
        {
            image_path = Application.StartupPath + "\\back_images\\1.png";
            pictureBox1.Image = new Bitmap(image_path);
        }
    }
}

using Newtonsoft.Json;
using System;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;namespace CSharpWinformTest
{public partial class Form1 : Form{public Form1(){InitializeComponent();}const string DllName = "DLSharp.dll";//行驶证正页[DllImport(DllName, EntryPoint = "dl_front_init_license", CallingConvention = CallingConvention.Cdecl)]internal extern static int dl_front_init_license(string key, string licenseFile, bool is_remote);[DllImport(DllName, EntryPoint = "dl_front_create", CallingConvention = CallingConvention.Cdecl)]internal extern static IntPtr dl_front_create();[DllImport(DllName, EntryPoint = "dl_front_init", CallingConvention = CallingConvention.Cdecl)]internal extern static int dl_front_init(IntPtr engine, string ini_path);[DllImport(DllName, EntryPoint = "dl_front_ocr", CallingConvention = CallingConvention.Cdecl)]internal extern static int dl_front_ocr(IntPtr engine, string image_path, StringBuilder ocr_result1, StringBuilder ocr_result2);[DllImport(DllName, EntryPoint = "dl_front_destroy", CallingConvention = CallingConvention.Cdecl)]internal extern static void dl_front_destroy(IntPtr engine);//行驶证副页[DllImport(DllName, EntryPoint = "dl_back_init_license", CallingConvention = CallingConvention.Cdecl)]internal extern static int dl_back_init_license(string key, string licenseFile, bool is_remote);[DllImport(DllName, EntryPoint = "dl_back_create", CallingConvention = CallingConvention.Cdecl)]internal extern static IntPtr dl_back_create();[DllImport(DllName, EntryPoint = "dl_back_init", CallingConvention = CallingConvention.Cdecl)]internal extern static int dl_back_init(IntPtr engine, string ini_path);[DllImport(DllName, EntryPoint = "dl_back_ocr", CallingConvention = CallingConvention.Cdecl)]internal extern static int dl_back_ocr(IntPtr engine, string image_path, StringBuilder ocr_result1, StringBuilder ocr_result2);[DllImport(DllName, EntryPoint = "dl_back_destroy", CallingConvention = CallingConvention.Cdecl)]internal extern static void dl_back_destroy(IntPtr engine);IntPtr front_engine;IntPtr back_engine;private void button1_Click(object sender, EventArgs e){if (image_path == ""){return;}StringBuilder ocr_result1 = new StringBuilder(1024);StringBuilder ocr_result2 = new StringBuilder(1024);int res = dl_front_ocr(front_engine, image_path, ocr_result1, ocr_result2);if (res == 0){Object jsonObject = JsonConvert.DeserializeObject(ocr_result1.ToString());textBox1.Text = JsonConvert.SerializeObject(jsonObject, Newtonsoft.Json.Formatting.Indented);}else{textBox1.Text = "识别失败";}}private void Form1_Load(object sender, EventArgs e){string key = "AISEE_xingshizheng_win_0530_3_3";string licenseFile = Application.StartupPath + "\\license\\license.ini";int res = -1;string ini_path = "";res = dl_front_init_license(key, licenseFile, false);Console.WriteLine(res.ToString());front_engine = dl_front_create();ini_path = Application.StartupPath + "\\resource\\vehiclecard_front_resource";res = dl_front_init(front_engine, ini_path);Console.WriteLine(res.ToString());res = dl_back_init_license(key, licenseFile, false);Console.WriteLine(res.ToString());back_engine = dl_back_create();ini_path = Application.StartupPath + "\\resource\\vehiclecard_back_resource";res = dl_back_init(back_engine, ini_path);Console.WriteLine(res.ToString());image_path = Application.StartupPath + "\\front_images\\2.jpg";//image_path = Application.StartupPath + "\\back_images\\1.png";pictureBox1.Image = new Bitmap(image_path);}private void Form1_FormClosing(object sender, FormClosingEventArgs e){dl_front_destroy(front_engine);dl_back_destroy(back_engine);}string fileFilter = "*.*|*.bmp;*.jpg;*.jpeg;*.tiff;*.tiff;*.png";string image_path = "";private void button2_Click(object sender, EventArgs e){OpenFileDialog ofd = new OpenFileDialog();ofd.Filter = fileFilter;if (ofd.ShowDialog() != DialogResult.OK) return;pictureBox1.Image = null;image_path = ofd.FileName;pictureBox1.Image = new Bitmap(image_path);textBox1.Text = "";}private void button3_Click(object sender, EventArgs e){if (image_path == ""){return;}StringBuilder ocr_result1 = new StringBuilder(1024);StringBuilder ocr_result2 = new StringBuilder(1024);int res = dl_back_ocr(back_engine, image_path, ocr_result1, ocr_result2);if (res == 0){Object jsonObject = JsonConvert.DeserializeObject(ocr_result1.ToString());textBox1.Text = JsonConvert.SerializeObject(jsonObject, Newtonsoft.Json.Formatting.Indented);}else{textBox1.Text = "识别失败";}}private void button4_Click(object sender, EventArgs e){image_path = Application.StartupPath + "\\front_images\\2.jpg";pictureBox1.Image = new Bitmap(image_path);}private void button5_Click(object sender, EventArgs e){image_path = Application.StartupPath + "\\back_images\\1.png";pictureBox1.Image = new Bitmap(image_path);}}
}

下载

C++封装源码下载

C#调用源码下载

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/791509.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

LeetCode-94. 二叉树的中序遍历【栈 树 深度优先搜索 二叉树】

LeetCode-94. 二叉树的中序遍历【栈 树 深度优先搜索 二叉树】 题目描述:解题思路一:递归解题思路二:迭代解题思路三:0 题目描述: 给定一个二叉树的根节点 root ,返回 它的 中序 遍历 。 示例 1&#xff1…

基于Python深度学习的中文情感分析系统(V2.0)

博主介绍:✌程序员徐师兄、7年大厂程序员经历。全网粉丝12w、csdn博客专家、掘金/华为云/阿里云/InfoQ等平台优质作者、专注于Java技术领域和毕业项目实战✌ 🍅文末获取源码联系🍅 👇🏻 精彩专栏推荐订阅👇…

信息安全就是国家安全,带大家了解一下安全算法

信息安全就是国家安全! 今天这编文章就带大家了解一下安全算法吧,个人理解仅供参考! 对安全算法 - 摘要算法的理解 摘要算法是一种将任意长度的数据转换为固定长度字节串的算法。它具有以下特点和应用。 首先,摘要算法能够生成…

详解Qt网络编程

Qt的网络编程能力非常强大,它提供了从底层socket API到高层HTTP、FTP等协议处理的完整解决方案。下面将简要介绍Qt中网络编程的核心类及其功能,并给出一些基本的使用示例。 核心网络类: QTcpSocket 和 QTcpServer QTcpSocket 是用于TCP通信的…

文件操作详解(三)--fsee -- ftell -- rewind -- feof函数 -- ferror函数

目录 一.文件的随机读写1.fseek2.ftell3.rewind 二.文件读写结束的判定1.feof函数(不是用来判定文件结束的)2.ferror函数 三.文件缓冲区 一.文件的随机读写 1.fseek int fseek(FILE* stream,long int offset,int origin); //第一个参数文件流 //第二个…

react组件:fragment

如果你要传递 key 给一个 &#xff0c;你不能使用 <>…</>&#xff0c;你必须从 ‘react’ 中导入 Fragment 且表示为…。 当你要从 <></> 转换为 [] 或 <></> 转换为 &#xff0c;React 并不会重置 state。这个规则只在一层深度的情况下…

excel统计分析——协方差分析的作用

参考资料&#xff1a;生物统计学 1、协变量与试验因素的区别 如果把协方差分析资料中的协变量看作多因素方差分析资料中的一个因素&#xff0c;则两类资料有相似之处&#xff0c;但两类资料有本质的不同。在方差分析中&#xff0c;各因素的水平时人为控制的&#xff0c;即使是…

学透Spring Boot — 004. Spring Boot Starter机制和自动配置机制

如果你项目中一直用的是 Spring Boot&#xff0c;那么恭喜你没有经历过用 Spring 手动集成其它框架的痛苦。 都说 Spring Boot 大大简化了 Spring 框架开发 Web 应用的难度&#xff0c;这里我们通过配置 Hibernate 的两种方式来深刻体会这一点&#xff1a; 使用 Spring 框架集…

【算法刷题day16】Leetcode:104. 二叉树的最大深度、111. 二叉树的最小深度、222.完全二叉树的节点个数

文章目录 Leetcode 104. 二叉树的最大深度解题思路代码总结 Leetcode 111. 二叉树的最小深度解题思路代码总结 Leetcode 222.完全二叉树的节点个数解题思路代码总结 草稿图网站 java的Deque Leetcode 104. 二叉树的最大深度 题目&#xff1a;104. 二叉树的最大深度 解析&#…

MT3017 上色

思路&#xff1a;使用分治&#xff0c;在每个连续区域递归调用heng()和shu() #include <bits/stdc.h> using namespace std; int n, m; int h[5005];int shu(int l, int r) {return r - l 1; } int heng(int l, int r) {int hmin 0x3f3f3f3f;for (int i l; i < r;…

IoT数采平台2:文档

IoT数采平台1&#xff1a;开篇IoT数采平台2&#xff1a;文档IoT数采平台3&#xff1a;功能IoT数采平台4&#xff1a;测试 【平台功能】 基础配置、 实时监控、 规则引擎、 告警列表、 系统配置 消息通知&#xff1a;Websocket 设备上线、设备下线、 数据变化、 告警信息、 实时…

蓝桥杯:全球变暖(python,BFS,DFS)(栈溢出的处理办法)

图论的经典题型&#xff0c;深度优先搜索和广度优先搜索都可以&#xff0c;但是本题推荐使用广度优先搜索&#xff08;类似的题最好都用广度优先搜索&#xff09;&#xff0c;因为使用深度优先搜索会爆栈&#xff08;栈溢出&#xff09;。本篇博客两种方法都进行讲解&#xff0…

【协议】RPC

文章目录 概述与web service/web api/wcf区别简介区别和联系 grpc.Net Core示例 参考 概述 与web service/web api/wcf区别 简介 RPC&#xff08;Remote Procedure Call Protocol&#xff09;即远程过程调用协议&#xff0c;是分布式系统间通信的一种协议。通过网络从远程计…

【Apache Doris】周FAQ集锦:第 2 期

【Apache Doris】周FAQ集锦&#xff1a;第 2 期 SQL问题数据操作问题运维常见问题其它问题关于社区 欢迎查阅本周的 Apache Doris 社区 FAQ 栏目&#xff01; 在这个栏目中&#xff0c;每周将筛选社区反馈的热门问题和话题&#xff0c;重点回答并进行深入探讨。旨在为广大用户和…

【WEEK6】学习目标及总结【MySQL】【中文版】

学习目标&#xff1a; 两周完成MySQL的学习——第二周 学习内容&#xff1a; 参考视频教程【狂神说Java】MySQL最新教程通俗易懂DQL查询数据 学习时间及产出&#xff1a; 第六周MON~WED, SUN 2024.4.1【WEEK6】 【DAY1】DQL查询数据-第一部分【中文版】【WEEK6】 【DAY1】DQ…

关键字:static

回顾类中的实例变量&#xff08;即非static的成员变量&#xff09; class Circle{ private double radius; public Circle(double radius){ this.radiusradius; } public double findArea(){ return Math.PI*radius*radius; } } 创建两个C…

计算机网络—TCP协议详解:特性、应用(2)

&#x1f3ac;慕斯主页&#xff1a;修仙—别有洞天 ♈️今日夜电波&#xff1a;マリンブルーの庭園—ずっと真夜中でいいのに。 0:34━━━━━━️&#x1f49f;──────── 3:34 &#x1f504; ◀️…

FPGA的就业前景

FPGA&#xff08;Field-Programmable Gate Array&#xff09;技术在数字电路设计和嵌入式系统开发方面具有广泛的应用&#xff0c;因此在FPGA领域有着较好的就业前景。 目前&#xff0c;FPGA在通信、计算机、消费电子、汽车、航空航天等行业中得到了广泛应用。随着新一代通信网…

抽象类与抽象方法(或abstract关键字)

由来 举例1&#xff1a; 随着继承层次中一个个新子类的定义&#xff0c;类变得越来越具体&#xff0c;而父类则更一般&#xff0c;更通用。类的设计应该保证父类和子类能够共享特征。有时将一个父类设计得非常抽象&#xff0c;以至于它没有具体的实例&#xff0c;这样的类叫做…

STM32G系 编程连接不上目标板,也有可能是软件不兼容。

由于一直用的老版本STM32 ST-LINK Utility 4.20 &#xff0c;找遍了所有问题&#xff0c;SWD就是连不上目标板。 电源脚 VDDA 地线&#xff0c;SWD的四条线&#xff0c;还是不行&#xff0c;浪费了一天&#xff0c;第二天才想起&#xff0c;是不是G系升级了 SWD协议。结果下载…