REF:
1)https://www.emgu.com/wiki/index.php/License_Plate_Recognition_in_CSharp
2)https://github.com/fasetto/license-plate-recognition/blob/master/src/LPlateRecognition.UI/ViewModels/MainViewModel.cs
Windows 10 x64 @ ASUS X450
Visual Studio 2019
建置程序
1) New FormApp
2) Nuget
emgu.cv 3.4.3.3016
Tesseract.Net SDK 1.18.342
3) Add class (Ref:1)
using Emgu.CV;
using Emgu.CV.CvEnum;
using Emgu.CV.OCR;
using Emgu.CV.Structure;
using Emgu.CV.Util;
using Emgu.Util;
using Patagames.Ocr;
using Patagames.Ocr.Enums;
//---###
using (UMat tmp = filteredPlate.Clone())
{
string plainText;
using (var api = OcrApi.Create())
{
api.Init(Languages.English);
api.SetVariable("tessedit_char_whitelist", "ABCDEFGHIJKLMNOPQRSTUVWXYZ-1234567890");
plainText = api.GetTextFromImage(tmp.Bitmap);
}
//_ocr.Recognize(tmp);
//words = _ocr.GetCharacters();
//if (words.Length == 0) continue;
if (plainText.Length == 0) continue;
//for (int i = 0; i < words.Length; i++)
for (int i = 0; i < plainText.Length; i++)
{
strBuilder.Append(plainText[i]);
}
}
//---###
4) Form1.cs
public Form1()
{
InitializeComponent();
imageBox1.Image = new Image<Bgr, byte>(@"C:\Users\csjou\Downloads\license-plate2.jpg");
}
private void button1_Click(object sender, EventArgs e)
{
LicensePlateDetector LPD = new LicensePlateDetector("test");
Mat m = new Image<Bgr, byte>(imageBox1.Image.Bitmap).Mat;
List<IInputOutputArray> licensePlateImagesList = new List<IInputOutputArray>();
List<IInputOutputArray> filteredLicensePlateImagesList = new List<IInputOutputArray>();
List<RotatedRect> licenseBoxList = new List<RotatedRect>();
List<string> words = LPD.DetectLicensePlate(
m,
licensePlateImagesList,
filteredLicensePlateImagesList,
licenseBoxList
);
this.Text = "";
for (int i = 0; i < words.Count; i++)
this.Text += words[i];
}