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内

相关推荐
ZLRRLZ7 分钟前
【Linux操作系统】进程控制
linux·运维·服务器
程序新视界18 分钟前
在连表查询场景下,MySQL隐式转换存在的坑
数据库·mysql·dba
c#上位机24 分钟前
wpf之ToggleButton控件
c#·wpf
九河云44 分钟前
在云计算环境中实施有效的数据安全策略
大数据·网络·数据库·云计算
qq762118221 小时前
Linux c 在内存中创建zip,最后写入测试
linux·运维·服务器
jayxuyj1 小时前
MySQL8.0新特性探秘深入解析窗口函数的性能优化策略
服务器
华纳云IDC服务商1 小时前
网站服务器频繁掉线的主要原因是什么
运维·服务器
小黄人软件1 小时前
【部署python网站】宝塔面板 小目标2:实时搜索网上资源文件网站放在服务器上 用AI做一个作品,不断迭代。
运维·服务器
未来之窗软件服务2 小时前
服务器运维(四)服务器漏洞扫描工具与审查——东方仙化神期
运维·服务器·仙盟创梦ide·东方仙盟·东方仙盟运维