嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元微信扫码支付:2 元
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
比较简陋的车辆牌照识别,起个抛砖引玉的作用
需要引用百度AipSdk,Newtonsoft.Json,自行在网上下载
API_KEY和SECRET_KEY 自行申请
richTextBox6.Text = "";
var client = new Baidu.Aip.Ocr.Ocr(API_KEY, SECRET_KEY);
filePath = FileDialogHelper.OpenImage();
if (!string.IsNullOrEmpty(filePath))
{
pictureBox1.Image = Image.FromFile(filePath);
var image = File.ReadAllBytes(filePath);
pictureBox1.Refresh();
// 如果有可选参数
var options = new Dictionary<string, object>
{
{"multi_detect", "true"}
};
var result = client.LicensePlate(image, options);
LicensePlate.RootObject rb = JsonConvert.DeserializeObject<LicensePlate.RootObject>(result.ToString());
List<LicensePlate.Words_result> Result_info = rb.words_result;
string value = "";
richTextBox6.Text = "";
List<LicensePlate.Vertexes_location> mylocation = new List<LicensePlate.Vertexes_location>();
if (Result_info == null)
{
richTextBox6.Text = "无法识别车辆牌照";
return;
}
value = "共识别到" Result_info.Count.ToString() "个车牌" "\r\n";
for (int i = 0; i < Result_info.Count; i )
{
mylocation = Result_info[i].vertexes_location;
DrawLine(mylocation[0].x, mylocation[0].y, mylocation[1].x, mylocation[1].y, pictureBox1);
pictureBox1.Refresh();
DrawLine(mylocation[1].x, mylocation[1].y, mylocation[2].x, mylocation[2].y, pictureBox1);
pictureBox1.Refresh();
DrawLine(mylocation[2].x, mylocation[2].y, mylocation[3].x, mylocation[3].y, pictureBox1);
pictureBox1.Refresh();
DrawLine(mylocation[3].x, mylocation[3].y, mylocation[0].x, mylocation[0].y, pictureBox1);
pictureBox1.Refresh();
value = "第" (i 1).ToString() "个" Result_info[i].color " " Result_info[i].number "\r\n";
richTextBox6.Text = richTextBox6.Text "\r\n" value;
}
pictureBox1.Refresh();