C # Identification Related technologies

Source: Internet
Author: User

Recent study of C # related OCR technology, image recognition generally C and C + + This low-level language to do more, C # mainly relies on some packaged components to make calls, here is a method of identity card recognition.

Environment construction

: EMGUCV official website

Download this exe under the file category, install it, find the corresponding component in the directory after installation, and some application cases.


DLL is referenced in a C # project, X64,x86,tessdata corresponds to a class library and a language library for OCR recognition, and I have added the Chinese language pack in Tessdata to put these three folders into the Program execution folder.

Demo

I do the small demo ID image is Baidu downloaded

Have to say that the only drawback of this class library is that the text recognition rate is too low, the image recognition effect is not very good

usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;usingSystem.Windows.Forms;usingEMGU.CV;usingEmgu.CV.OCR;usingEmgu.CV.Structure;usingSystem.IO;namespaceemgucv{ Public Partial classForm1:form {Image<gray, byte>Imagethreshold;  PublicForm1 () {InitializeComponent (); Picturebox1.enabled=false; }        Private voidForm1_Load (Objectsender, EventArgs e) {        }        Private voidButton1_Click (Objectsender, EventArgs e) {            //The first parameter is the address of the language pack folder, which is not written by default under the execution folderTesseract _OCR =NewTesseract (@"","Chi_sim", ocrenginemode.tesseractonly); _OCR.            SetImage (Imagethreshold); _OCR.            recognize (); String text=_OCR.            Getutf8text ();  This. TextBox1.Text =text; }        Private voidPicturebox2_click (Objectsender, EventArgs e) {OpenFileDialog of=NewOpenFileDialog (); Of. Title="Please select a picture"; if(Of. ShowDialog () = =DialogResult.OK) {stringFile =of .                FileName; Image img=image.fromfile (file); pictureBox1.Image=img; } Bitmap Bitmap= (Bitmap) This. pictureBox1.Image; Image&LT;BGR, byte> ImageSource =NewIMAGE&LT;BGR,byte>(bitmap); Image<gray, byte> Imagegrayscale = Imagesource.convert<gray, byte>(); Imagegrayscale=Randon (Imagegrayscale); Imagethreshold= Imagegrayscale.thresholdbinary (NewGray ( -),NewGray (255));  This. Picturebox2.image =Imagethreshold.tobitmap (); }        /// <summary>        ///Rotation Correction/// </summary>        /// <param name= "Imageinput" ></param>        /// <returns></returns>        PrivateImage<gray, byte> Randon (Image<gray, byte> imageinput)//definition of Tilt correction sub-function of image projection rotation method        {            intNwidth =Imageinput.width; intNheight =Imageinput.height; intsum; intSumofcha; intSumofchatemp =0; int[] Sumhang =New int[nheight]; Image<gray, byte> resultimage =Imageinput; Image<gray, byte>Imrotaimage; //Adjustment in 20 degree range             for(intAng =- -; Ang < -; Ang = Ang +1) {Imrotaimage= Imageinput.rotate (Ang,NewGray (1));  for(inti =0; i < nheight; i++) {sum=0;  for(intj =0; J < nwidth; J + +) {sum+ = Imrotaimage.data[i, J,0]; } Sumhang[i]=sum; } Sumofcha=0;  for(intK =0; K < nheight-1; k++) {Sumofcha= Sumofcha + (Math.Abs (sumhang[k)-sumhang[k +1])); }                if(Sumofcha >sumofchatemp) {Resultimage=Imrotaimage; Sumofchatemp=Sumofcha; }            }            returnResultimage; }        Private voidPictureBox1_Click (Objectsender, EventArgs e) {        }    }}

C # Identification Related technologies

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.