在好例子网,分享、交流、成长!
您当前所在位置:首页C# 开发实例Windows系统编程 → 图像文字识别(Interop.MODI)

图像文字识别(Interop.MODI)

Windows系统编程

下载此实例
  • 开发语言:C#
  • 实例大小:0.20M
  • 下载次数:154
  • 浏览次数:1934
  • 发布时间:2016-07-01
  • 实例类别:Windows系统编程
  • 发 布 人:ahmatjan5000
  • 文件格式:.rar
  • 所需积分:2
 相关标签: 文字 图像 识别

实例介绍

【实例简介】

【实例截图】

【核心代码】

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Windows;
using System.Drawing.Imaging;
using System.Threading;

namespace DevOCR
{
    public partial class Form1 : Form
    {

		// Declare the two dialog objects
		//   we'll be using.
        //声明的两个对话框对象
        //我们将使用。
		MyWin m_WindowDlg;
		ShowBitmap m_ShowBitmapDlg;

        public Form1()
        {
            InitializeComponent();
		}
		private void btnCapture_Click(object sender, EventArgs e)
		{
            // Get the screen width and height.获取屏幕的宽度和高度。
			int w = Screen.PrimaryScreen.Bounds.Width;
			int h = Screen.PrimaryScreen.Bounds.Height;
            // Create the dialog object on which we'll创建对话框对象上,我们将
            //   display the screen bitmap.在屏幕显示位图。
			m_WindowDlg = new MyWin();
            // Set to wait cursor so user knows something设置为等待光标,使用户知道的东西
            //   is going on.是怎么回事。
			Cursor = Cursors.WaitCursor;
            // Hide the main app window so that it isn't in the隐藏在主应用程序窗口,以便它不是在
            //   capture image (and wait since Vista takes its time).捕获图像(等待由于Vista需要的时间)。
			Hide();
			Thread.Sleep(200);
            // Create the bitmap into which the screen will be copied.创建到该屏幕将被复制位图。
			m_WindowDlg.m_objBitmap = new Bitmap(w, h,
				PixelFormat.Format32bppArgb);
            // Get the graphics context for the bitmap.获取为位图图形上下文。
			Graphics g = Graphics.FromImage(m_WindowDlg.m_objBitmap);
            // Copy the screen into the bitmap object.位图复制到对象的屏幕。
			g.CopyFromScreen(0, 0, 0, 0, new Size(w, h));
            // Show the main application window. We need显示主应用程序窗口。我们需要
            //   to do this because the child window won't这样做,因为子窗口不会
            //   behave properly if it's hidden or minimized.循规蹈矩,如果是隐藏或最小化。
			Show();
            // Create a delegate so that the EndCapture创建一个代表,让EndCapture
            //   method can be called.方法可以调用。
			m_WindowDlg.m_EndCaptureMethod = 
				new MyWin.EndCaptureMethod(EndCapture);
            // Show the captured screen.查看捕获的屏幕。
			m_WindowDlg.Show();
            // Hide the main application window.隐藏主应用程序窗口。
			Hide();
            // Set the location, size, and cursor of the设置的位置,大小,以及游标
            //   dialog in which the user will select对话框中,用户将选择
            //   a portion.的一部分。
			m_WindowDlg.Location = new Point(0, 0);
			m_WindowDlg.Size = new Size(w, h);
			m_WindowDlg.Cursor = Cursors.Cross;
		}
        // This method is called once the user is这种方法被称为一旦用户
        //   finished selecting the screen region完成选择屏幕区域
        //   that will be OCRed.将文本识别过。
		public void EndCapture(int x, int y, int w, int h)
		{
            // Restore cursor恢复光标
			Cursor = Cursors.Default;
            // Created the dialog in which we'll创建对话框中,我们将
            //   show the capture bitmap.显示位图的捕获。
			m_ShowBitmapDlg = new ShowBitmap();
            // Copy the bitmap from the selection bitmap复制从选择位图位图
            //   that was displayed to the display bitmap.这是显示在显示位图。
			m_ShowBitmapDlg.m_objBitmap =
				new Bitmap(w, h, PixelFormat.Format32bppArgb);
            // Get the graphics context for the bitmap.获取为位图图形上下文
			Graphics g = 
				Graphics.FromImage(m_ShowBitmapDlg.m_objBitmap);
            // Copy the selected portion into the newly-created选定部分复制到新创建的
			//   bitmap.位图
			g.DrawImage(m_WindowDlg.m_objBitmap,
				new Rectangle(0, 0, w, h), x, y,
				w, h, GraphicsUnit.Pixel);
            // Hide the dialog that was used to display the 隐藏了用来显示对话框 
            //   entire screen.整个屏幕。
			m_WindowDlg.Hide();
            // Add to the width and height the frame margins.增加宽度和高度的框架边缘
			w  = (m_ShowBitmapDlg.Bounds.Width -
				m_ShowBitmapDlg.ClientRectangle.Width);
			h  = (m_ShowBitmapDlg.Bounds.Height -
				m_ShowBitmapDlg.ClientRectangle.Height);
            // Set the maximum size for the window in which设置的窗口,其中最大尺寸
            //   we'll display the bitmap.我们将会显示位图。
			m_ShowBitmapDlg.MaximumSize = 
				m_ShowBitmapDlg.Size = new Size(w, h);
            // Show the bitmap in the dialog.查看对话框中的位图。
			m_ShowBitmapDlg.ShowDialog();
            // Now re-show the main application window.现在重新出现在主应用程序窗口。
			Show();
		}
    }
}

标签: 文字 图像 识别

实例下载地址

图像文字识别(Interop.MODI)

不能下载?内容有错? 点击这里报错 + 投诉 + 提问

好例子网口号:伸出你的我的手 — 分享

网友评论

第 1 楼 silver_12138 发表于: 2017-09-19 10:45 45
未能加载文件或程序集“Interop.MODI, Version=11.0.0.0, Culture=neutral, PublicKeyToken=null”或它的某一个依赖项。生成此程序集的运行时比当前加载的运行时新,无法加载此程序集。一直提示这个错误,为什么

支持(0) 盖楼(回复)

发表评论

(您的评论需要经过审核才能显示)

查看所有1条评论>>

小贴士

感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。

  • 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
  • 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
  • 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
  • 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。

关于好例子网

本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明

;
报警