C#识别图片数字

csharp 复制代码
    ///选取图片按钮的代码
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    private void 选择图片_Click(object sender, EventArgs e)
    {      
            OpenFileDialog openFileDialog = new OpenFileDialog();
        openFileDialog.Filter = "JPG Files (*.jpg)|*.jpg|PNG Files (*.png)|*.png";
        openFileDialog.FilterIndex = 1;
            openFileDialog.Multiselect = false;
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                selectedPicture = openFileDialog.FileName;
                MessageBox.Show($"您选中的图片路径为:{selectedPicture}");
                // 使用Image类加载图片           
                Image image = Image.FromFile(selectedPicture);
            // 将图片显示在PictureBox中        
            pictureBox1.Image = image;   
            }
            else
            {
                MessageBox.Show("您本次没有选择任何图片!!!");
            }
        
    }

    /// <summary>
    /// 开始识别按钮的代码
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    private void 识别_Click(object sender, EventArgs e)
    {

        //创建扫描器
            OcrScanner scanner = new OcrScanner();
        //开始扫描
            if (selectedPicture!=null)
            scanner.Scan(selectedPicture);
            //输出结果
            string result = scanner.Text.ToString();
            richTextBox1.Text = result;
        
    }

要将项目名\packages\Spire.OCR.1.8.0\runtimes\win-x64\native内的ddl,放到\项目名\bin\x64\Debug内

相关推荐
麦兜*4 分钟前
MongoDB Atlas 云数据库实战:从零搭建全球多节点集群
java·数据库·spring boot·mongodb·spring·spring cloud
東雪蓮☆5 分钟前
深入理解 LVS-DR 模式与 Keepalived 高可用集群
linux·运维·服务器·lvs
Slaughter信仰8 分钟前
深入理解Java虚拟机:JVM高级特性与最佳实践(第3版)第十章知识点问答(10题)
java·jvm·数据库
麦兜*10 分钟前
MongoDB 在物联网(IoT)中的应用:海量时序数据处理方案
java·数据库·spring boot·物联网·mongodb·spring
乌萨奇也要立志学C++32 分钟前
【Linux】进程概念(二):进程查看与 fork 初探
linux·运维·服务器
大飞pkz34 分钟前
【设计模式】C#反射实现抽象工厂模式
设计模式·c#·抽象工厂模式·c#反射·c#反射实现抽象工厂模式
-Xie-44 分钟前
Mysql杂志(十六)——缓存池
数据库·mysql·缓存
七夜zippoe1 小时前
缓存与数据库一致性实战手册:从故障修复到架构演进
数据库·缓存·架构
一个天蝎座 白勺 程序猿2 小时前
Apache IoTDB(5):深度解析时序数据库 IoTDB 在 AINode 模式单机和集群的部署与实践
数据库·apache·时序数据库·iotdb·ainode