当前位置: 首页 > wzjs >正文

公司内部网站如何备案搜搜

公司内部网站如何备案,搜搜,广州做网络服装的网站建设,泉州网站设计公司目录 PP-OCRv5官方效果如下 C封装、C#调用效果 项目 代码 下载 PP-OCRv5官方效果如下 C封装、C#调用效果 项目 代码 using Newtonsoft.Json; using OpenCvSharp; using System; using System.Collections.Generic; using System.Diagnostics; using System.Drawing; usi…

目录

PP-OCRv5官方效果如下

C++封装、C#调用效果

项目

代码

下载 


PP-OCRv5官方效果如下

C++封装、C#调用效果

项目

代码

using Newtonsoft.Json;
using OpenCvSharp;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;

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

        const string DllName = "lw.PPOCRSharp.dll";

        //初始化
        [DllImport(DllName, EntryPoint = "init", CallingConvention = CallingConvention.StdCall)]
        public extern static int init(ref IntPtr engine
            , int cpu_threads
            , bool enable_mkldnn

            , string det_model_dir
            , int limit_side_len
            , double det_db_thresh
            , double det_db_box_thresh
            , double det_db_unclip_ratio
            , bool use_dilation

            , bool cls
            , bool use_angle_cls
            , string cls_model_dir
            , double cls_thresh
            , double cls_batch_num

            , string rec_model_dir
            , string rec_char_dict_path
            , int rec_batch_num
            , int rec_img_h
            , int rec_img_w

            , StringBuilder msg);

        //识别
        [DllImport(DllName, EntryPoint = "ocr", CallingConvention = CallingConvention.StdCall)]
        public extern static int ocr(IntPtr engine, IntPtr image, StringBuilder msg, out IntPtr ocr_result, out int ocr_result_len);

        //释放
        [DllImport(DllName, EntryPoint = "destroy", CallingConvention = CallingConvention.StdCall)]
        public extern static int destroy(IntPtr engine, StringBuilder msg);

        static IntPtr OCREngine;

        private Bitmap bmp;

        private String imgPath = null;

        private List<OCRResult> ltOCRResult;

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

        private StringBuilder OCRResultInfo = new StringBuilder();
        private StringBuilder OCRResultAllInfo = new StringBuilder();

        Pen pen = new Pen(Brushes.Red, 2f);

        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = fileFilter;
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                imgPath = ofd.FileName;
                bmp = new Bitmap(imgPath);
                pictureBox1.Image = bmp;
                richTextBox1.Clear();

                button2_Click(null, null);
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {

            if (imgPath == null)
            {
                return;
            }
            button1.Enabled = false;
            button2.Enabled = false;
            richTextBox1.Clear();
            OCRResultInfo.Clear();
            OCRResultAllInfo.Clear();

            Application.DoEvents();

            Mat img = new Mat(imgPath);
            StringBuilder msgTemp = new StringBuilder(128);
            StringBuilder ocrResultStr = new StringBuilder(1024 * 100);

            Stopwatch stopwatch = new Stopwatch();
            stopwatch.Start();

            IntPtr strPtr;
            int ocr_result_len = 0;

            int res = ocr(OCREngine, img.CvPtr, msgTemp, out strPtr, out ocr_result_len);
            byte[] buffer = new byte[ocr_result_len];
            Marshal.Copy(strPtr, buffer, 0, ocr_result_len);
            string ocr_result = Encoding.UTF8.GetString(buffer);
            Marshal.FreeCoTaskMem(strPtr);
            //Console.WriteLine(ocr_result);
            stopwatch.Stop();
            double totalTime = stopwatch.Elapsed.TotalSeconds;

            OCRResultAllInfo.AppendLine($"耗时: {totalTime:F2}s");
            OCRResultAllInfo.AppendLine("---------------------------");

            OCRResultInfo.AppendLine($"耗时: {totalTime:F2}s");
            OCRResultInfo.AppendLine("---------------------------");

            if (res == 0)
            {

                ltOCRResult = Newtonsoft.Json.JsonConvert.DeserializeObject<List<OCRResult>>(ocr_result);
                OCRResultAllInfo.Append(JsonConvert.SerializeObject(ltOCRResult, Newtonsoft.Json.Formatting.Indented));
                Graphics graphics = Graphics.FromImage(bmp);

                foreach (OCRResult item in ltOCRResult)
                {
                    OCRResultInfo.AppendLine(item.text);
                    System.Drawing.Point[] pt = new System.Drawing.Point[] {
                              new System.Drawing.Point(item.x1, item.y1)
                            , new System.Drawing.Point(item.x2, item.y2)
                            , new System.Drawing.Point(item.x3, item.y3)
                            , new System.Drawing.Point(item.x4, item.y4)
                        };
                    graphics.DrawPolygon(pen, pt);
                }
                graphics.Dispose();

                if (checkBox1.Checked)
                {
                    richTextBox1.Text = OCRResultAllInfo.ToString();
                }
                else
                {
                    richTextBox1.Text = OCRResultInfo.ToString();
                }

                pictureBox1.Image = null;
                pictureBox1.Image = bmp;
            }
            else
            {
                MessageBox.Show("识别失败," + msgTemp.ToString());
            }

            img.Release();
            button1.Enabled = true;
            button2.Enabled = true;
        }

        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Form1_Load(object sender, EventArgs e)
        {
            radioButton1.Checked = true;
        }

        void LoadModel()
        {

            StringBuilder msgTemp = new StringBuilder(128);
            string root_dir = Application.StartupPath + @"\inference";

            int cpu_threads = Environment.ProcessorCount + 2;
            bool enable_mkldnn = true;

            string det_model_dir = "";
            int limit_side_len = 960;
            double det_db_thresh = 0.3;
            double det_db_box_thresh = 0.6;
            double det_db_unclip_ratio = 1.2;
            bool use_dilation = false;

            bool cls = false;
            bool use_angle_cls = true;
            string cls_model_dir = root_dir + @"\ch_ppocr_mobile_v2.0_cls_infer\";
            double cls_thresh = 0.9;
            int cls_batch_num = 1;

            string rec_model_dir = "";
            string rec_char_dict_path = root_dir + @"\ppocrv5_dict.txt";
            int rec_batch_num = Environment.ProcessorCount;
            int rec_img_h = 48;
            int rec_img_w = 320;

            if (radioButton1.Checked)
            {
                det_model_dir = root_dir + @"\PP-OCRv5_mobile_det_infer\";
                rec_model_dir = root_dir + @"\PP-OCRv5_mobile_rec_infer\";
            }
            else
            {
                det_model_dir = root_dir + @"\PP-OCRv5_server_det_infer\";
                rec_model_dir = root_dir + @"\PP-OCRv5_server_rec_infer\";
            }
            int res = init(ref OCREngine
                        , cpu_threads
                        , enable_mkldnn

                        , det_model_dir
                        , limit_side_len
                        , det_db_thresh
                        , det_db_box_thresh
                        , det_db_unclip_ratio
                        , use_dilation

                        , cls
                        , use_angle_cls
                        , cls_model_dir
                        , cls_thresh
                        , cls_batch_num

                        , rec_model_dir
                        , rec_char_dict_path
                        , rec_batch_num
                        , rec_img_h
                        , rec_img_w

                        , msgTemp);

            if (res == 0)
            {
                MessageBox.Show("模型加载成功!");
            }
            else
            {
                string msg = msgTemp.ToString();
                MessageBox.Show("模型加载失败," + msg);
            }
        }

        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            richTextBox1.Clear();
            if (checkBox1.Checked)
            {
                richTextBox1.Text = OCRResultAllInfo.ToString();
            }
            else
            {
                richTextBox1.Text = OCRResultInfo.ToString();
            }
        }

        private void radioButton1_CheckedChanged(object sender, EventArgs e)
        {
            RadioButton rb = sender as RadioButton;
            if (rb != null && rb.Checked)
            {
                //MessageBox.Show("选中的是:" + rb.Text);
                LoadModel();
            }
        }
    }


}
 

using Newtonsoft.Json;
using OpenCvSharp;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;namespace OCRV5Test
{public partial class Form1 : Form{public Form1(){InitializeComponent();}const string DllName = "lw.PPOCRSharp.dll";//初始化[DllImport(DllName, EntryPoint = "init", CallingConvention = CallingConvention.StdCall)]public extern static int init(ref IntPtr engine, int cpu_threads, bool enable_mkldnn, string det_model_dir, int limit_side_len, double det_db_thresh, double det_db_box_thresh, double det_db_unclip_ratio, bool use_dilation, bool cls, bool use_angle_cls, string cls_model_dir, double cls_thresh, double cls_batch_num, string rec_model_dir, string rec_char_dict_path, int rec_batch_num, int rec_img_h, int rec_img_w, StringBuilder msg);//识别[DllImport(DllName, EntryPoint = "ocr", CallingConvention = CallingConvention.StdCall)]public extern static int ocr(IntPtr engine, IntPtr image, StringBuilder msg, out IntPtr ocr_result, out int ocr_result_len);//释放[DllImport(DllName, EntryPoint = "destroy", CallingConvention = CallingConvention.StdCall)]public extern static int destroy(IntPtr engine, StringBuilder msg);static IntPtr OCREngine;private Bitmap bmp;private String imgPath = null;private List<OCRResult> ltOCRResult;private string fileFilter = "*.*|*.bmp;*.jpg;*.jpeg;*.tiff;*.tif;*.png";private StringBuilder OCRResultInfo = new StringBuilder();private StringBuilder OCRResultAllInfo = new StringBuilder();Pen pen = new Pen(Brushes.Red, 2f);private void button1_Click(object sender, EventArgs e){OpenFileDialog ofd = new OpenFileDialog();ofd.Filter = fileFilter;if (ofd.ShowDialog() == DialogResult.OK){imgPath = ofd.FileName;bmp = new Bitmap(imgPath);pictureBox1.Image = bmp;richTextBox1.Clear();button2_Click(null, null);}}private void button2_Click(object sender, EventArgs e){if (imgPath == null){return;}button1.Enabled = false;button2.Enabled = false;richTextBox1.Clear();OCRResultInfo.Clear();OCRResultAllInfo.Clear();Application.DoEvents();Mat img = new Mat(imgPath);StringBuilder msgTemp = new StringBuilder(128);StringBuilder ocrResultStr = new StringBuilder(1024 * 100);Stopwatch stopwatch = new Stopwatch();stopwatch.Start();IntPtr strPtr;int ocr_result_len = 0;int res = ocr(OCREngine, img.CvPtr, msgTemp, out strPtr, out ocr_result_len);byte[] buffer = new byte[ocr_result_len];Marshal.Copy(strPtr, buffer, 0, ocr_result_len);string ocr_result = Encoding.UTF8.GetString(buffer);Marshal.FreeCoTaskMem(strPtr);//Console.WriteLine(ocr_result);stopwatch.Stop();double totalTime = stopwatch.Elapsed.TotalSeconds;OCRResultAllInfo.AppendLine($"耗时: {totalTime:F2}s");OCRResultAllInfo.AppendLine("---------------------------");OCRResultInfo.AppendLine($"耗时: {totalTime:F2}s");OCRResultInfo.AppendLine("---------------------------");if (res == 0){ltOCRResult = Newtonsoft.Json.JsonConvert.DeserializeObject<List<OCRResult>>(ocr_result);OCRResultAllInfo.Append(JsonConvert.SerializeObject(ltOCRResult, Newtonsoft.Json.Formatting.Indented));Graphics graphics = Graphics.FromImage(bmp);foreach (OCRResult item in ltOCRResult){OCRResultInfo.AppendLine(item.text);System.Drawing.Point[] pt = new System.Drawing.Point[] {new System.Drawing.Point(item.x1, item.y1), new System.Drawing.Point(item.x2, item.y2), new System.Drawing.Point(item.x3, item.y3), new System.Drawing.Point(item.x4, item.y4)};graphics.DrawPolygon(pen, pt);}graphics.Dispose();if (checkBox1.Checked){richTextBox1.Text = OCRResultAllInfo.ToString();}else{richTextBox1.Text = OCRResultInfo.ToString();}pictureBox1.Image = null;pictureBox1.Image = bmp;}else{MessageBox.Show("识别失败," + msgTemp.ToString());}img.Release();button1.Enabled = true;button2.Enabled = true;}/// <summary>/// 初始化/// </summary>/// <param name="sender"></param>/// <param name="e"></param>private void Form1_Load(object sender, EventArgs e){radioButton1.Checked = true;}void LoadModel(){StringBuilder msgTemp = new StringBuilder(128);string root_dir = Application.StartupPath + @"\inference";int cpu_threads = Environment.ProcessorCount + 2;bool enable_mkldnn = true;string det_model_dir = "";int limit_side_len = 960;double det_db_thresh = 0.3;double det_db_box_thresh = 0.6;double det_db_unclip_ratio = 1.2;bool use_dilation = false;bool cls = false;bool use_angle_cls = true;string cls_model_dir = root_dir + @"\ch_ppocr_mobile_v2.0_cls_infer\";double cls_thresh = 0.9;int cls_batch_num = 1;string rec_model_dir = "";string rec_char_dict_path = root_dir + @"\ppocrv5_dict.txt";int rec_batch_num = Environment.ProcessorCount;int rec_img_h = 48;int rec_img_w = 320;if (radioButton1.Checked){det_model_dir = root_dir + @"\PP-OCRv5_mobile_det_infer\";rec_model_dir = root_dir + @"\PP-OCRv5_mobile_rec_infer\";}else{det_model_dir = root_dir + @"\PP-OCRv5_server_det_infer\";rec_model_dir = root_dir + @"\PP-OCRv5_server_rec_infer\";}int res = init(ref OCREngine, cpu_threads, enable_mkldnn, det_model_dir, limit_side_len, det_db_thresh, det_db_box_thresh, det_db_unclip_ratio, use_dilation, cls, use_angle_cls, cls_model_dir, cls_thresh, cls_batch_num, rec_model_dir, rec_char_dict_path, rec_batch_num, rec_img_h, rec_img_w, msgTemp);if (res == 0){MessageBox.Show("模型加载成功!");}else{string msg = msgTemp.ToString();MessageBox.Show("模型加载失败," + msg);}}private void checkBox1_CheckedChanged(object sender, EventArgs e){richTextBox1.Clear();if (checkBox1.Checked){richTextBox1.Text = OCRResultAllInfo.ToString();}else{richTextBox1.Text = OCRResultInfo.ToString();}}private void radioButton1_CheckedChanged(object sender, EventArgs e){RadioButton rb = sender as RadioButton;if (rb != null && rb.Checked){//MessageBox.Show("选中的是:" + rb.Text);LoadModel();}}}}

下载 

源码下载

http://www.dtcms.com/wzjs/568518.html

相关文章:

  • 做试卷的网站德阳市网站建设
  • 电商网站流程小学网站建设情况说明
  • 优秀网站作品河北雄安建设投资集团网站
  • 江门模板建站系统开封网站建设流程与步骤
  • 南宁网站设计建设连云港做网站建设
  • 要做一个网站需要准备什么仙居做网站
  • 17网站一起做网店普网站案例
  • 凡科建站是放在哪个服务器上邢台市行政区划图
  • 备案 几个网站诸城做网站公司
  • 免费免费网站模板下载数据可视化
  • 海报设计图片大全沈阳seo网站管理
  • 天猫网站建设目的网站建设的人员配置
  • 安徽省工程建设信息网站wordpress修改首页模板
  • 莆田网站建设外贸网站平台搭建包括哪些
  • 信用网站建设是国家统一部署虚拟主机免费云服务器
  • 建设网站费用要进固定资产吗建设银行网站怎么查自己账号
  • 吉林网站建设方案html 公司网站 代码下载
  • 磁力网站怎么做做网站找哪家好要钱吗
  • 哈尔滨网站建设服务定制wordpress
  • 福建省建设银行招聘网站广东住房和城乡建设厅网站
  • 电子商务网站建设结论深圳手机网站建设多少钱
  • 广州化妆品网站建设湖北省建设交易协会网站
  • 网站设计简单网页宁波seo网络推广产品服务
  • 腾讯企业邮箱入口网址做抖音seo排名软件是否合法
  • 做一个网站需要花费多少钱重庆网站关键词优化推广
  • 网站建设 资产做爰全过程免费网站可以看
  • 做ppt好用的网站有哪些idea网站开发
  • 开公司如何做网站推广长沙手机网站设计
  • 手机公众平台网站开发 163com免费邮箱登
  • 局域网网站建设步骤大淘客网站是怎么做的