C\#신분증 식별 관련 기술 기능 상세 설명
환경 구축
다운로드 주소:EmguCV 홈 페이지
File 클래스 에서 이 EXE 를 다운로드 하여 설치 하고 설치 한 후 디 렉 터 리 에서 해당 구성 요 소 를 찾 을 수 있 으 며 응용 사례 도 있 습 니 다.
dll 폴 더 의 dll 은 C\#항목 에 인용 되 었 습 니 다.x64,x86,tessdata 는 OCR 인식 에 대응 하 는 라 이브 러 리 와 언어 라 이브 러 리 입 니 다.제 tessdata 에는 중국어 패 키 지 를 추가 하여 이 세 개의 폴 더 를 프로그램 실행 폴 더 에 넣 었 습 니 다.
Demo
자신 이 만 든 작은 데모 그림:신분증 사진 은 바 이 두 에서 다운로드 한 것 이다.
이 라 이브 러 리 의 유일한 단점 은 문자 식 별 률 이 너무 낮 고 이미지 식별 효과 도 좋 지 않다 는 것 이다
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Emgu.CV;
using Emgu.CV.OCR;
using Emgu.CV.Structure;
using System.IO;
namespace EmguCV
{
public partial class Form1 : Form
{
Image<Gray, Byte> imageThreshold;
public Form1()
{
InitializeComponent();
pictureBox1.Enabled = false;
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
// ,
Tesseract _ocr = new Tesseract(@"", "chi_sim", OcrEngineMode.TesseractOnly);
_ocr.SetImage(imageThreshold);
_ocr.Recognize();
String text = _ocr.GetUTF8Text();
this.textBox1.Text = text;
}
private void pictureBox2_Click(object sender, EventArgs e)
{
OpenFileDialog of = new OpenFileDialog();
of.Title = " ";
if (of.ShowDialog() == DialogResult.OK)
{
string file = of.FileName;
Image img = Image.FromFile(file);
pictureBox1.Image = img;
}
Bitmap bitmap = (Bitmap)this.pictureBox1.Image;
Image<Bgr, Byte> imageSource = new Image<Bgr, byte>(bitmap);
Image<Gray, Byte> imageGrayscale = imageSource.Convert<Gray, Byte>();
imageGrayscale = randon(imageGrayscale);
imageThreshold = imageGrayscale.ThresholdBinary(new Gray(100), new Gray(255));
this.pictureBox2.Image = imageThreshold.ToBitmap();
}
/// <summary>
///
/// </summary>
/// <param name="imageInput"></param>
/// <returns></returns>
private Image<Gray, Byte> randon(Image<Gray, Byte> imageInput)//
{
int nwidth = imageInput.Width;
int nheight = imageInput.Height;
int sum;
int SumOfCha;
int SumOfChatemp = 0;
int[] sumhang = new int[nheight];
Image<Gray, Byte> resultImage = imageInput;
Image<Gray, Byte> ImrotaImage;
//20
for (int ang = -20; ang < 20; ang = ang + 1)
{
ImrotaImage = imageInput.Rotate(ang, new Gray(1));
for (int i = 0; i < nheight; i++)
{
sum = 0;
for (int j = 0; j < nwidth; j++)
{
sum += ImrotaImage.Data[i, j, 0];
}
sumhang[i] = sum;
}
SumOfCha = 0;
for (int k = 0; k < nheight - 1; k++)
{
SumOfCha = SumOfCha + (Math.Abs(sumhang[k] - sumhang[k + 1]));
}
if (SumOfCha > SumOfChatemp)
{
resultImage = ImrotaImage;
SumOfChatemp = SumOfCha;
}
}
return resultImage;
}
private void pictureBox1_Click(object sender, EventArgs e)
{
}
}
}
이상 이 바로 본 고의 모든 내용 입 니 다.여러분 의 학습 에 도움 이 되 고 저 희 를 많이 응원 해 주 셨 으 면 좋 겠 습 니 다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
WebView2를 Visual Studio 2017 Express에서 사용할 수 있을 때까지Evergreen .Net Framework SDK 4.8 VisualStudio2017에서 NuGet을 사용하기 때문에 패키지 관리 방법을 packages.config 대신 PackageReference를 사용해야...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.