#include <stdio.h>
#include <stdlib.h>
#include <time.h>
//#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define pi 3.14
#define RADIAN(angle) ((angle)*3.14/180.0)
#define max(a,b) (((a) > (b)) ? (a) : (b))
#define min(a,b) (((a) < (b)) ? (a) : (b))
typedef unsigned long DWORD;
typedef int BOOL;
typedef unsigned char BYTE;
typedef unsigned short WORD;
typedef float FLOAT;
typedef unsigned char byte;
//#define MAX(a,b,c) a>(b>c?b:c)?a:
struct BMP_img
{
WORD bfType;
DWORD size;
DWORD reser;
DWORD header_length;
DWORD infoheader_length;
DWORD width;
DWORD height;
WORD biplanes;
WORD bmp_type; /* 8bit 24bit; */
DWORD compres;
DWORD datasize;
DWORD bixpm;
DWORD biypm;
DWORD clrused;
DWORD relclrused;
BYTE *image;
byte *header_info;
DWORD lineBytes;
};
struct Bmp1{
DWORD width;
DWORD height;
byte strc[67][800];
BYTE *image;
int p1[15];//xl
int p2[15];//xr
int p3[15];//yu
int p4[15];//yd
int up;
int down;
byte strr[7][2500];
byte string[7];
float ang;//倾斜角度
};
struct HSV{
float H;
float S;
int V;
};
struct RGB{
byte bitb;
byte bitg;
byte bitr;
byte re;
};
void read_img(FILE *infile, struct BMP_img *img);
//void read_img(FILE *infile, struct BMP_img *img);
void displaytwo(struct Bmp1 img,byte *srcBmp,byte *dstBmp,int yuzhi);
unsigned char myGetMedianNum(unsigned char * bArray, int iFilterLen);
void cuizhitouying(struct Bmp1 *img,byte *temp);
void sob(byte *srcBmp,int width,int height,int type);
void shuipingtouying(struct Bmp1 *img,byte *temp);
//void display(BMP_img img,byte *temp);
void grayScale(struct BMP_img img,byte *srcBmp,byte *dstBmp);
void junheng(struct BMP_img img,byte *srcBmp,byte *dstBmp);
void CutBmp(struct BMP_img img,struct Bmp1 *img1,int HL,int HH,int VL,int VH);
void CutBmp1(struct Bmp1 *img1,int HL,int HH,int VL,int VH);
void testhsv(float h,float s,float v,byte r,byte g,byte b);
void hsvzation(byte *image,struct HSV *hsv,int width,int height);
void location(byte *image,int width,int height,int yuzhi,int *HL,int *HH,int *VL,int *VH);
void huidu(struct Bmp1 img,byte *srcBmp,byte *dstBmp);
void bmptwo(struct Bmp1 img,byte *srcBmp,byte *dstBmp,byte yuzhi);
void Thiningtest(struct BMP_img img,byte *srcBmp,byte *dstBmp);
void Thining(byte *srcBmp,int width,int height);
void ThinnerRosenfeld(void *image, unsigned long lx, unsigned long ly);
void delpoint(byte *dst,int width,int height,int yuzhi);
void Erosion(byte *image,int width,int height,int type,int num);
void deljunzao(byte *dst,int width,int height,int yuzhi);
void pingjun(byte *dst,int width,int height);
void changeGray(byte *srcBmp,byte *dstBmp,int width,int height,int nWidth,int nHeight);
byte *changeRGB(byte *srcBmp,int width,int height,int *lwidth,int *lheight,float f);
void strBmp(struct Bmp1 *img,byte *temp);
void guiyi(struct Bmp1 *img);
void readstr(FILE *infile, byte *srcBmp);
char *myitoa(int num, char *str, int radix); // 整数字符串转换。
void readmoban(char *path,struct Bmp1 *img2);
void writebmp(const char *path,const char *name,byte *temp);
int cmpstr(byte *src,byte *moban);
void Hough(struct Bmp1 *img);
void strout(struct Bmp1 *img);
void edgesob8(byte *image,int width,int height);
void edgesob4(byte *image,int width,int height);//4邻域
int hough(byte *srcBmp,int width,int height);
void Dilation(byte *image,int width,int height,int type,int num);
void RotateGray(byte *image,int width,int height, float iRotateAngle);
byte *RotateRGB(byte *image, float iRotateAngle,int width,int height,int *lwidth,int *lheight);
void xuanzhuan(struct Bmp1 *img1);
byte *myMalloc(int num,const byte *bmp,int type);
void guiyiRGB(struct Bmp1 *img1);
void outtext(struct Bmp1 img1,int x,int y);
int calstr(byte *srcBmp);
void main()
{
FILE *f;
int i,j,k;
byte *temp,*temp1;
//char path[80]="//root//Desktop//车牌识别1//车牌图片//test//example10.bmp";
//char path1[80]="//root//Desktop//车牌识别1//车牌定位颜色//moban//";
// char path[80]="C:\\Documents and Settings\\liujia\\桌面\\test\\example06.bmp";
// char path1[80]="C:\\Documents and Settings\\liujia\\桌面\\test\\moban\\";
char path[80] = "../test/2.bmp";
char path1[80] = "../test/moban/";
int HL=0,HH=0,VH=0,VL=0;
struct BMP_img img;
struct Bmp1 img1;
if((f=fopen(path,"rb"))==NULL)
{
printf( "\n 不能打开 %s \n", path);
exit(-1);
}
read_img(f, &img);
fclose(f);
temp=myMalloc(img.height*img.width*4,temp,0);//(byte *)malloc(sizeof(byte)*img.height*img.width*4);// byte *temp2=(byte *)malloc(sizeof(byte)*img.height*img.width);
temp1=myMalloc(img.height*img.width*4,temp,0);
location(img.image,img.width,img.height,15,&HL,&HH,&VL,&VH);
CutBmp(img,&img1,HL,HH,VL,VH);
Hough(&img1);
xuanzhuan(&img1);
location(img1.image,img1.width,img1.height,0,&HL,&HH,&VL,&VH);
CutBmp1(&img1,HL,HH,VL,VH);
huidu(img1,img1.image,temp);
displaytwo(img1,temp,temp1,30);
delpoint(temp1,img1.width,img1.height,3);
shuipingtouying(&img1,temp1);
delpoint(temp1,img1.width,img1.height,2);
cuizhitouying(&img1,temp1);
memset(temp,0,sizeof(char)*img1.width*img1.height);
strBmp(&img1,temp1);//把车牌字符放到数组里面
guiyi(&img1);
readmoban(path1,&img1);
strout(&img1);
outtext(img1,0,600);
//getch();
system("stty -echo");
getchar();
system("stty echo");
}
void read_img(FILE *infile, struct BMP_img *img)
{
DWORD i,j,l,n,bitcolor;
double gray;
DWORD line24;
DWORD line8;
struct RGB *bitmap;
fread(&img->bfType,sizeof(WORD),1,infile);//printf("\n打开的图为 %d",img->bfType);
fread(&img->size,sizeof(DWORD),1,infile); printf("\nBMP size:%d",img->size);printf(" ");
fread(&img->reser,sizeof(DWORD),1,infile);//printf("\n保留位:");
fread(&img->header_length,sizeof(DWORD),1,infile); printf("\nheader length:%d",img->header_length);printf(" ");
fread(&img->infoheader_length,sizeof(DWORD),1,infile);
fread(&img->width, sizeof(DWORD), 1, infile);
fread(&img->height, sizeof(DWORD), 1, infile); printf( "\nwidth:%d height:%d ", img->width, img->height);printf(" ");
fread(&img->biplanes, sizeof(WORD), 1, infile);
fread(&img->bmp_type, sizeof(WORD), 1, infile); printf("\nBMP Tpye:%d ", img->bmp_type);
fread(&img->compres, sizeof(DWORD), 1, infile); //if(img->compres==0) {printf("\nbmp图片为非压缩!");}printf(" ");
fread(&img->datasize, sizeof(DWORD), 1, infile); printf("\nBMP Data Size:%d ",img->datasize);printf(" ");
fread(&img->bixpm, sizeof(DWORD), 1, infile);
fread(&img->biypm, sizeof(DWORD), 1, infile);
fread(&img->clrused, sizeof(DWORD), 1, infile); //printf("\n实际使用颜色数=%d ",img->clrused);printf(" ");
fread(&img->relclrused, sizeof(DWORD), 1, infile);
img->lineBytes=(img->width*img->bmp_type+31)/32*4;
printf("\nLineBytes :%d\n",img->lineBytes);printf(" ");
line24=(img->width*24+31)/32*4;
line8=(img->width*8+31)/32*4;
if(img->bmp_type==1){bitcolor=2;printf("不能读取退出");exit(-1);}
if(img->bmp_type==4){bitcolor=16;printf("不能读取退出");exit(-1);}
if(img->bmp_type==8)
{
byte *temp=(BYTE*)malloc(img->height*line8*sizeof(BYTE));
memset(temp,0x00,img->height*img->lineBytes*sizeof(BYTE));
bitcolor=256;
bitmap=(struct RGB *)calloc(bitcolor,sizeof(struct RGB));
img->image=(unsigned char *)malloc(sizeof(unsigned char)*(line8*img->height));
memset(img->image,0x00,sizeof(byte)*line8*img->height);
if(img->image==NULL) {fprintf(stderr, "\n Allocation error for temp in read_bmp() \n");}
fseek(infile
linux下的车牌识别c语言代码
3星 · 超过75%的资源 需积分: 50 49 浏览量
2016-03-06
10:25:31
上传
评论 4
收藏 3.97MB RAR 举报
kylin_56
- 粉丝: 4
- 资源: 1
最新资源
- 基于MATLAB的钢板表面缺陷检测系统
- MS SQL里生成行政区域县区信息表和相应数据
- delphi实现DBGrid全选和反选功能
- 25C11F41-2B2A-4D1A-AAA8-7C654526B129.pdf
- Android Studio Jellyfish(android-studio-2023.3.1.18-cros.deb)
- MVC+EF框架+EasyUI实现权限管理源码程序
- python第66-75天,Day66-75.rar
- python后端服务project-of-tornado.rar
- python测验,hello-tornado.rar
- 基于SpringBoot+Vue3快速开发平台、自研工作流引擎源码设计.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈