车牌识别emgucv

上传人:鲁** 文档编号:478140641 上传时间:2023-03-08 格式:DOC 页数:5 大小:26.50KB
返回 下载 相关 举报
车牌识别emgucv_第1页
第1页 / 共5页
车牌识别emgucv_第2页
第2页 / 共5页
车牌识别emgucv_第3页
第3页 / 共5页
车牌识别emgucv_第4页
第4页 / 共5页
车牌识别emgucv_第5页
第5页 / 共5页
亲,该文档总共5页,全部预览完了,如果喜欢就下载吧!
资源描述

《车牌识别emgucv》由会员分享,可在线阅读,更多相关《车牌识别emgucv(5页珍藏版)》请在金锄头文库上搜索。

1、using System;using System.Collections.Generic;using System.Text;using System.Drawing;using Emgu.Util;using Emgu.CV;using Emgu.CV.Structure;using tessnet2;using System.Diagnostics; namespace LicensePlateRecognition / / A license plate detector / public class LicensePlateDetector : DisposableObject pr

2、ivate Tesseract _ocr; / / Create a license plate detector / public LicensePlateDetector() /create OCR _ocr = new Tesseract(); /You can download more language definition data from /Languages supported includes: /Dutch, Spanish, German, Italian, French and English _ocr.Init(eng, false); / / Detect lic

3、ense plate from the given image / / The image to search license plate from / A list of images where the detected license plate region is stored / A list of images where the detected license plate region with noise removed is stored / A list where the region of license plate, defined by an MCvBox2D i

4、s stored / The list of words for each license plate public ListList DetectLicensePlate(Image img, ListImage licensePlateList, ListImage filteredLicensePlateList, List boxList) /Stopwatch w = Stopwatch.StartNew(); ListList licenses = new ListList(); using (Image gray = img.Convert() using (Image cann

5、y = new Image(gray.Size) using (MemStorage stor = new MemStorage() CvInvoke.cvCanny(gray, canny, 100, 50, 3); Contour contours = canny.FindContours( Emgu.CV.CvEnum.CHAIN_APPROX_METHOD.CV_CHAIN_APPROX_SIMPLE, Emgu.CV.CvEnum.RETR_TYPE.CV_RETR_TREE, stor); FindLicensePlate(contours, gray, canny, licens

6、ePlateList, filteredLicensePlateList, boxList, licenses); /w.Stop(); return licenses; private void FindLicensePlate( Contour contours, Image gray, Image canny, ListImage licensePlateList, ListImage filteredLicensePlateList, List boxList, ListList licenses) for (; contours != null; contours = contour

7、s.HNext) Contour approxContour = contours.ApproxPoly(contours.Perimeter * 0.05, contours.Storage); if (approxContour.Area 100 & approxContour.Total = 4) /img.Draw(contours, new Bgr(Color.Red), 1); if (!IsParallelogram(approxContour.ToArray() Contour child = contours.VNext; if (child != null) FindLic

8、ensePlate(child, gray, canny, licensePlateList, filteredLicensePlateList, boxList, licenses); continue; MCvBox2D box = approxContour.GetMinAreaRect(); double whRatio = (double)box.size.Width / box.size.Height; if (!(3.0 whRatio & whRatio 8.0) Contour child = contours.VNext; if (child != null) FindLi

9、censePlate(child, gray, canny, licensePlateList, filteredLicensePlateList, boxList, licenses); continue; Image plate = gray.Copy(box); Image filteredPlate = FilterPlate(plate); List words; using (Bitmap bmp = filteredPlate.Bitmap) words = _ocr.DoOCR(bmp, filteredPlate.ROI); licenses.Add(words); lice

10、nsePlateList.Add(plate); filteredLicensePlateList.Add(filteredPlate); boxList.Add(box); / / Check if the four points forms a parallelogram / / The four points that defines a polygon / True if the four points defines a parallelogram private static bool IsParallelogram(Point pts) LineSegment2D edges = PointCollection.PolyLine(pts, true); double diff1 = Math.Abs(edges0.Length - edges2.Length); double diff2 = Math.Abs(edges1.Length - edges3.Length); if (diff1 / edges0.Length = 0.05 & diff1 / edges2.Length = 0.05

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 建筑/环境 > 建筑资料

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号