1.èªå©å»ºç«åç½ç«å¼åçåºå«
2.Cè¯è¨å车åºç®¡çç³»ç»
3.Python三行代码实现车牌识别
èªå©å»ºç«åç½ç«å¼åçåºå«
èªå©å»ºç«ä¸è¬æ¯ç¨å·²ç»æå½¢çç½ç«ç³»ç»æ¡æ¶æ¨¡æ¿ï¼åªè¦å°å 容填å å°æ¡æ¶ä¸ï¼åéå°±è½åä¸ä¸ªç½ç«ã
å¼åç½ç«æ¯èªå·±æ ¹æ®éæ±ï¼å®å¶èåï¼å¯ä»¥å®ç°ç»å¤§å¤æ°åè½å设计ä¸çéæ±ã
èªå©å»ºç«çé度快ãè´¹ç¨ä½ãåè½å®ç¨ï¼ä½æ¯å®æ æ³å®ç°é«è¦æ±çèºæ¯è®¾è®¡ä»¥å个æ§åçåè½å¼åï¼å æ¤èªå©å»ºç«ä¸è¬éåäºå¤äºåæåå±é¶æ®µï¼å¯¹ç½ç«åè½éæ±è¿ä¸é«çå ¬å¸æ个人使ç¨ï¼
ç½ç«å¼åå¨æé¿ï¼è´¹ç¨é«ï¼å¨èºæ¯ååè½çå®ç°ä¸ä¸åå°ä»»ä½çéå¶åææï¼ä¸è¬å·²ç»æè¿å»ºç«ç»éªçå ¬å¸ä¼éæ©å®å¶å¼åçæ¹å¼ã
å æ¤æå¥½æ ¹æ®èªå·±çéæ±å¹¶ç»åé¢ç®çå¤æ¹é¢å ç´ éæ©åéçç½ç«å»ºè®¾æ¹å¼æ¹å¼ï¼æ²¡æåªä¸ªå¥½åªä¸ªä¸å¥½ã
Cè¯è¨å车åºç®¡çç³»ç»
/*----------------------------------------------------------------
// Copyright (C) æ²é³å·¥ç¨å¦é¢ä¿¡æ¯å®å ¨å·¥ä½å®¤
// çæææã
//
// æ件åï¼æ¨¡æå车åºé®é¢.cpp
// æ件åè½æè¿°ï¼æ¨¡æå车åºé®é¢
//
//
// å建æ è¯ï¼
//
// ä¿®æ¹æ è¯ï¼
// ä¿®æ¹æè¿°ï¼å®æç¼ç
//----------------------------------------------------------------*/
//头æ件
#include <iostream>
#include <malloc.h>
#include <string>
#include <windows.h>
//常éå®ä¹
#define MAX_STOP 4 //å®ä¹å车åºæ大å车æ°
#define MAX_PLATE //å®ä¹è½¦çå·æ大é¿åº¦
#define TIME_COUNT "ç§" //å®ä¹æ¶é´åä½
#define TIME_MS_TO_CONUT //å®ä¹æ¶é´è¿å¶ï¼æ为ç±TIME_COUNTå°æ¯«ç§çè¿å¶
#define UNIT_PRICE //å®ä¹åä½æ¶é´æ¶è´¹æ å
using namespace std; //使ç¨stdå½å空é´
//æ°æ®ç»æå®ä¹
//å®ä¹åå¨æ±½è½¦ä¿¡æ¯çç»æä½
typedef struct
{
char license_plate[MAX_PLATE]; //汽车çç §å·ç ï¼å®ä¹ä¸ºä¸ä¸ªå符æéç±»å
char state; //汽车å½åç¶æï¼å符p表示åæ¾å¨å车ä½ä¸ï¼å符s表示åæ¾å¨ä¾¿éä¸ï¼æ¯è¾è½¦çåå§ç¶æç¨å符iæ¥è¿è¡è¡¨ç¤º
int time; //汽车åå ¥å车åºæ¶çæ¶é´ï¼ç¨æ¥è®¡æ¶æ¶è´¹
}CAR;
//å®ä¹æ¨¡æå车åºçæ ç»æ
typedef struct
{
CAR STOP[MAX_STOP]; //汽车信æ¯çåå¨ç©ºé´
int top; //ç¨æ¥æ示æ 顶ä½ç½®çéææé
}SeqStack;
//å®ä¹æ¨¡æ便éçéåç»æ
typedef struct node
{
CAR WAIT; //汽车信æ¯çåå¨ç©ºé´
struct node *next; //ç¨æ¥æ示éåä½ç½®çå¨ææé
}QNode; //é¾éåèç¹çç±»å
//å®ä¹é¾éåçæ¶å°¾æé
typedef struct
{
QNode *front,车牌查询*rear;
}LQueue; //å°å¤´å°¾æéå°è£ å¨ä¸èµ·çé¾é
//å½æ°å£°æ
int Empty_LQueue(LQueue *q); //å¤é空
int LeaveCheck(SeqStack parking , char *license_plate); //æ£æ¥ç¦»å¼ç车æ¯å¦å¨å车åºä¸
int QueueLength(LQueue *q); //å¤éé¿åº¦
int Out_LQueue(LQueue *&sidewalk , char *license_plate); //åºéæä½
int StackEmpty(SeqStack parking); //å¤ææ æ¯å¦ä¸ºç©º
int StackFull(SeqStack parking); //å¤ææ æ¯å¦ä¸ºæ»¡
int StackPop(SeqStack &parking); //åºæ æä½
int StackTop(SeqStack parking , char *license_plate , int &time);//åæ 顶å ç´
void Car_come(SeqStack &parking , LQueue *&sidewalk); //æ车å°æ¥æ¶çæä½
void Car_leave(SeqStack &parking , LQueue *&sidewalk); //æ车离å¼çæä½
void Display(SeqStack parking); //æ¾ç¤ºå车åºå çææä¿¡æ¯ è°è¯æ¶ç¨
void InitStack(SeqStack &parking); //åå§åæ
void InitList(LQueue *&sidewalk); //åå§åéå
void In_LQueue(LQueue *&sidewalk , char *license_plate); //è¿éæä½
void Input_Check(char *license_plate); ////æ£éªè¾å ¥ç车çæ¯å¦åæ³
void StackPush(SeqStack &parking , char *license_plate , int stop_time);//è¿æ æä½
void main()
{
//å®ä¹åé
SeqStack parking;
LQueue *sidewalk = NULL;
char *choice = new char;
int flag = 1; //å®ä¹ä¸ä¸ªåé å¤ææ¯å¦éåº
//åå§åä¸ä¸ªä¸ºç©ºçå车åº
InitStack(parking);
//åå§åä¸ä¸ªä¸ºç©ºç便é
InitList(sidewalk);
//è¿è¡çé¢ååè½éæ©
while(flag)
{
cout<<"\n\t å车åºæ¨¡æ管çç³»ç» \n\n";
cout<<"\t|--------------------------------------------------|\n\n";
cout<<"\t|æ¬ç¨åºä¸ºå车åºç模æ管çç³»ç»ï¼æ车å°æ¥æ¶è¯·æCé®ã|\n\n";
cout<<"\t|ç¶åæ ¹æ®å±å¹æ示è¿è¡ç¸å ³æä½ï¼æ车è¦èµ°æ¶è¯·ælé®ã|\n\n";
cout<<"\t|ç¶åæ ¹æ®å±å¹æ示è¿è¡ç¸å ³æä½ï¼æ¥çå车åºè¯·æDé®ã|\n\n";
cout<<"\t|ç¶åæ ¹æ®å±å¹æ示è¿è¡ç¸å ³æä½ï¼è¦éåºç³»ç»è¯·æQé®ã|\n\n";
cout<<"\t|--------------------------------------------------|\n\n";
cout<<"请éæ©æä½ï¼";
gets(choice);
if(1 != strlen(choice))
{
cout<<"请æ£ç¡®è¾å ¥é项!";
continue;
}
else
{
switch(*choice)
{
case 'c':
case 'C':
{
Car_come(parking,sidewalk);break;
}
case 'l':
case 'L':
{
Car_leave(parking,sidewalk);break;
}
case 'q':
case 'Q':
{
flag=0;break;
}
case 'd':
case 'D':
{
Display(parking);break;
}
default:
cout<<"éæ©ä¸æ£ç¡®ï¼è¯·éæ°éæ©ï¼\n";
}
}
}
}
//æ车å°æ¥æ¶çæä½
void Car_come(SeqStack &parking , LQueue *&sidewalk)
{
//å®ä¹åé
char license_plate[MAX_PLATE];
cout<<"请è¾å ¥è½¦è¾ç车çå·ç ï¼";
Input_Check(license_plate);
//å¤æå车åºæ¯å¦å·²æ»¡ï¼æ»¡åè¿å ¥ä¾¿éï¼ä¸æ»¡è¿å ¥å车åº
if(StackFull(parking))
{
In_LQueue(sidewalk , license_plate); //è¿å ¥ä¾¿é
cout<<"å车åºå·²æ»¡è¯·å¨ä¾¿éçå,æ¨çä½ç½®ä¸º"<<QueueLength(sidewalk)
<<endl;
}
else
{
StackPush(parking , license_plate , GetTickCount()); //è¿å ¥å车åº
cout<<"请è¿å ¥å车åºä¸ç"<<parking.top+1<<"å·å车ä½\n";
}
// Display(parking);
}
//æ车离å¼æ¶çæä½
void Car_leave(SeqStack &parking , LQueue *&sidewalk)
{
//å®ä¹åé
SeqStack tmpparking; //å®ä¹ä¸´æ¶å车åº
char leave_license_plate[MAX_PLATE]; //è¦ç¦»å¼ç车çå·
char license_plate[MAX_PLATE]; //åæ¾ä»å车åºä¸è¯»åºæ¥ç车çä¿¡æ¯
int time;
InitStack(tmpparking); //åå§å临æ¶å车åº
//å¤æå车åºä¸æ¯å¦æ车
if(StackEmpty(parking))
{
cout<<"å½åå车åºä¸æ²¡æ车\n";
return; //éåºåå½æ°
}
cout<<"请è¾å ¥è¦ç¦»å¼ç车çç §ï¼";
Input_Check(leave_license_plate);
cout<<"å½åå车åºä¸æ"<<parking.top+1<<"è¾è½¦\n";
if(LeaveCheck(parking , leave_license_plate)) //å¤æ车æ¯å¦å¨å车åºä¸
{
//车å¨å车åºä¸
cout<<"æ¨ç车å¨"<<LeaveCheck(parking , leave_license_plate)<<"å·è½¦ä½ä¸\n";
while(StackTop(parking , license_plate , time)
&& (strcmp(parking.STOP[parking.top].license_plate , leave_license_plate) != 0))
{
strcpy(parking.STOP[parking.top].license_plate , license_plate);
cout<<"çç §ä¸º"<<license_plate<<"ç车ææ¶éåºå车åº"<<parking.top+1<<"å·ä½\n";
StackPush(tmpparking , license_plate , time); //å车åºä¸ç车ææ¶éåº è¿å ¥ä¸´æ¶å车åº
StackPop(parking); //åºæ
}
cout<<"çç §ä¸º"<<license_plate<<"ç车离å¼å车åº"<<parking.top+1<<"å·ä½\n";
cout<<"æ¨å¨å车åºä¸åäº"<<(GetTickCount()-time)/TIME_MS_TO_CONUT<<TIME_COUNT<<endl; //è¾åºæåæ¶é´ä¿¡æ¯
cout<<"åºç¼´è´¹ç¨ä¸º"<<(GetTickCount()-time)/TIME_MS_TO_CONUT*UNIT_PRICE<<"å \n";; //è¾åºè´¹ç¨ä¿¡æ¯
StackPop(parking); //åºæ
//å°ä¸´æ¶å车åºä¸ç车ååå车åº
while(StackEmpty(tmpparking) != 1)
{
StackTop(tmpparking , license_plate , time);
StackPush(parking , license_plate , time);
cout<<"çç §ä¸º"<<license_plate<<"ç车è¿å ¥å车åº"<<parking.top+1<<"å·ä½\n";
license_plate[0] = '\0';
StackPop(tmpparking);
}
if(parking.top+1 == MAX_STOP-1) //å¤æ车离å¼åå车åºæ¯å¦å满
if(QueueLength(sidewalk)) //å¦æå满åå¤æ便éä¸æ¯å¦æ车
{
//便éä¸æ车 åä»ä¾¿éä¸åå ¥å车åº
Out_LQueue(sidewalk , license_plate); //åºé
StackPush(parking , license_plate , GetTickCount()); //å ¥æ
cout<<"å¨ä¾¿éä¸çç §ä¸º"<<license_plate<<"ç车è¿å ¥å车åº"<<parking.top+1<<"å·ä½\n";
}
}
else
//车ä¸å¨å车åºä¸
cout<<"æ¨ç车ä¸å¨å车åºä¸ï¼\n";
}
//åå§å顺åºæ
void InitStack(SeqStack &parking)
{
parking.top = -1;
}
//å¤æ 空
int StackEmpty(SeqStack parking)
{
if(parking.top == -1)
return 1;
else
return 0;
}
//å¤æ 满
int StackFull(SeqStack parking)
{
if(parking.top == MAX_STOP-1)
return 1;
else
return 0;
}
//å ¥æ
void StackPush(SeqStack &parking , char *license_plate , int stop_time)
{
parking.top++;
strcpy(parking.STOP[parking.top].license_plate , license_plate);
parking.STOP[parking.top].state = 'p';
parking.STOP[parking.top].time = stop_time;
}
//åºæ è¿åæ 顶æé
int StackPop(SeqStack &parking)
{
if(StackEmpty(parking))
return 0;
else
return parking.top--;
}
//åæ 顶å ç´
int StackTop(SeqStack parking , char *license_plate , int &time)
{
if(StackEmpty(parking))
return 0;
else
{
strcpy(license_plate , parking.STOP[parking.top].license_plate);
time = parking.STOP[parking.top].time;
return 1;
}
}
//æ¾ç¤ºææ
void Display(SeqStack parking)
{
if(parking.top == -1)
printf("å车åºä¸ºç©º\n");
else
{
while(parking.top != -1)
{
cout<<"车çå·ä¸ºï¼"<<parking.STOP[parking.top].license_plate;
cout<<"ï¼åå¨"<<parking.top + 1 <<"å·è½¦ä½ä¸";
cout<<"ï¼å·²å"<<(GetTickCount()-parking.STOP[parking.top].time)/TIME_MS_TO_CONUT<<TIME_COUNT<<endl;
parking.top--;
}
}
}
//åå§åéå
void InitList(LQueue *&sidewalk)
{
sidewalk = (LQueue *)malloc(sizeof(LQueue));
sidewalk->front=sidewalk->rear = NULL;
}
//å ¥é
void In_LQueue(LQueue *&sidewalk,char *license_plate)
{
QNode *car_on_sidewalk;
car_on_sidewalk = (QNode *)malloc(sizeof(QNode)); //为æ°èç¹å¼è¾æ°ç©ºé´
strcpy(car_on_sidewalk->WAIT.license_plate , license_plate); //å°æ°æ®åå ¥èç¹
car_on_sidewalk->WAIT.state = 's'; //åå ¥å车信æ¯
car_on_sidewalk->WAIT.time = GetTickCount(); //åå ¥å车æ¶é´
car_on_sidewalk->next = NULL;
if(Empty_LQueue(sidewalk)) //é空åå建第ä¸ä¸ªèç¹
sidewalk->front = sidewalk->rear = car_on_sidewalk;
else
{
//éé空æå ¥éå°¾
sidewalk->rear->next = car_on_sidewalk;
sidewalk->rear = car_on_sidewalk;
}
}
//å¤é空
int Empty_LQueue(LQueue *q)
{
if(q->front == NULL)
return 1;
else
return 0;
}
//å¤éé¿åº¦ è¿åéé¿
int QueueLength(LQueue *q)
{
QNode *p=q->front;
int i=0;
while(p != NULL)
{
i++;
p=p->next;
}
return i;
}
//åºé æåè¿å1 é空è¿å0
int Out_LQueue(LQueue *&sidewalk,char *license_plate)
{
QNode *car_on_sidewalk;
if(Empty_LQueue(sidewalk)) //å¦æé空è¿å0
return 0;
car_on_sidewalk = sidewalk->front;
strcpy(license_plate , car_on_sidewalk->WAIT.license_plate);//ååºé头å ç´
if(sidewalk->front == sidewalk->rear) //éä¸åªæä¸ä¸ªå ç´
sidewalk->front = sidewalk->rear=NULL; //å é¤å ç´
else
sidewalk->front = sidewalk->front->next; //é头æéå移
free(car_on_sidewalk); //éæ¾æé
return 1;
}
//æ£æ¥ç¦»å¼ç车æ¯å¦å¨å车åºä¸ è¿å车å¨å车åºä¸ä½ç½® ä¸å¨åè¿å0
int LeaveCheck(SeqStack parking,char *license_plate)
{
int flag = parking.top+1; //å®ä¹åéè®°å½å½å车å¨å车åºä¸ä½ç½®
if(StackEmpty(parking))
return 0;
else
{
//æ¥æ¾ç¦»å¼è½¦æå¨ä½ç½®
while(parking.top != -1 && strcmp(parking.STOP[parking.top].license_plate , license_plate) != 0)
{
flag--;
parking.top--;
}
return flag;
}
}
//æ£éªè¾å ¥ç车çæ¯å¦åæ³
void Input_Check(char *license_plate)
{
int flag = 1;
int i;
string tmpstr;
while(flag)
{
cin>>tmpstr;
getchar();
if(tmpstr.length()<MAX_PLATE)
{
for(i=0;i<;i++)
license_plate[i] = tmpstr.c_str()[i];
flag = 0;
}
else
cout<<"è¾å ¥æ误ï¼è¯·éæ°è¾å ¥ï¼";
}
}
以åç课设 ä½ ççå§ çº¯æå·¥ç~~
Python三行代码实现车牌识别
Python三行代码实现车牌识别
本文将介绍使用Python和hyperlpr3库实现车牌识别的简化方法。代码简洁高效,号录适合技术学习与交流。入查美发框架系统源码
实现步骤
1. **导入依赖库
**在Python环境中,询源首先确保安装了`hyperlpr3`库,码车搜狐畅游源码本文实验环境为Python 3.7。牌号广州引流源码
2. **新建车牌识别实例
**使用`hyperlpr3`库中的录入`LicensePlateCatcher`函数创建车牌识别实例。
3. **读取车牌识别
**使用OpenCV(cv2)库加载文件,源码为后续车牌识别做准备。车牌查询
4. **开展车牌号码识别
**利用先前创建的号录实例对中的车牌进行识别,获取车牌号码。入查
完整源代码
详细代码实现请关注公众号:实用办公编程技能
微信号:Excel-Python
欢迎在公众号留言讨论!询源
关注公众号,码车人脉裂变源码获取更多实用技术教程。牌号
录入glibc源码学习公众号内容涵盖:
录入glibc源码学习1. Python词云图分析剧评
录入glibc源码学习2. 用几行代码制作Gif动图
录入glibc源码学习3. Python简易计算器
录入glibc源码学习4. Python生成二维码
录入glibc源码学习5. 用Python控制摄像头
录入glibc源码学习6. Python视频播放
录入glibc源码学习7. Python制作照片阅读器
录入glibc源码学习8. Python文本自动播读
录入glibc源码学习9. 用Python制作简易时钟
录入glibc源码学习. 手写数字识别
录入glibc源码学习. 图像文本识别
录入glibc源码学习. 小说词频分析图
录入glibc源码学习