您好,欢迎访问三七文档
当前位置:首页 > 机械/制造/汽车 > 汽车理论 > 车牌识别(包括车牌检测-车牌跟踪-车牌识别)源代码下载
³µÅÆʶ±ð£¨°üÀ¨³µÅƼì²â£¬³µÅƸú×Ù£¬³µÅÆʶ±ð£©Ô´´úÂëÏÂÔØ£º±¾³ÌÐò¿ª·¢»·¾³£ºvc6.0opencv1.0ÕûÌ幦ÄÜ£ºÊÇΪÁËʵÏÖ³µÅÆ×Ô¶¯¸ú×Ù£¬¼ì²â£¬²¢ÅÄÕÕ£¬¶¨Î»£¬Ê¶±ð£¬µ«ÊǸú×ÙºÍÅÄÕÕµÈÓÚûÓÐʵÏÖ¡£ÊµÏÖ¹¦ÄÜ£ºÄÜʵÏÖÊÓƵÖÐÎïÌå¸ú×Ù£¬µ«±ØÐëÊÇÊÖ¶¯È¦×¡²ÅÐУ¬ÉãÏñÍ·ÊÇusbÉãÏñÍ·.´ò¿ª³µÅÆͼƬ£¬ÄܽøÐж¨Î»£¬³µÅƷָ×Ö·û·Ö¸î£¬×Ö·ûʶ±ð¡£²Ù×÷²½Ö裺³ÌÐòÖ÷½çÃ棺Óдò¿ªÉãÏñÍ·£¬¹Ø±ÕÉãÏñÍ·£¬½ØȡͼƬ£¬³µÅÆʶ±ð´ò¿ªÉãÏñÍ·£¬¿ÉÒÔ¿´µ½ÊÓƵÖлÃ棬Òƶ¯Êó±êȦסÎïÌ壬¿ÉÒÔ×Ô¶¯¸ú×Ù¡£½ØȡͼƬ£¬ÔÚ´ò¿ªÉèÉãÏñÍ·µÄÇé¿öÏ£¬¿ÉÒÔ½ØÈ¡²¢±£´æÒ»ÕÅͼƬ¡£¹Ø±ÕÉãÏñÍ·£¬²»ÓÃÉãÏñͷʱ£¬ÐèÏȹرÕÉãÏñÍ·£¬²»È»Ö´ÐÐÆäËûµÄ»áÓдíÎó¡£³µÅÆʶ±ð£¬µ¯³ö³ÌÐò×Ó½çÃæ¡£ÔÚ³ÌÐò×Ó½çÃæÀÒÀ´ÎÓÖ´ò¿ªÍ¼Æ¬£¬Í¼Ïñ¶þÖµ»¯£¬³µÅƶ¨Î»£¬×Ö·û·Ö¸î£¬×Ö·ûʶ±ð°´Å¥¡£°´Å¥µã»÷˳ÐòÊÇ£º´ò¿ªÍ¼Æ¬£¬Í¼Ïñ¶þÖµ»¯£¬³µÅƶ¨Î»£¬×Ö·û·Ö¸î£¬×Ö·ûʶ±ð¡£²Ù×÷Íê¾Í¿ÉÒÔ¿´µ½½á¹û¡£Ö»ÒªÍ¼Æ¬´óСºÏÊÊ£¨²»ÄÜÌ«´ó£©£¬Ò»°ã¶¼ÄܽÏ׼ȷµÄ½á¹û¡£³µÅƶ¨Î»Ê¶±ðÄÇ¿éÓÐÏêϸעÊÍ¡£²¿·Ö´úÂëÈçÏ£ºvoidCOpencvCarDlg::OnOpencamera(){//TODO:AddyourcontrolnotificationhandlercodehereIplImage*frame=0;IplImage*framecopy=0;capture=cvCaptureFromCAM(-1);if(!capture){MessageBox(ÉãÏñÍ·¶ÁÈ¡´íÎó...,NULL,MB_ICONEXCLAMATION|MB_ICONWARNING|MB_OK);cvWaitKey(0);}cvNamedWindow(CamShift,1);cvSetMouseCallback(CamShift,on_mouse,NULL);for(;;)//½øÈëÊÓƵ֡´¦ÀíÖ÷Ñ»·{inti,bin_w,c;framecopy=cvQueryFrame(capture);if(!framecopy)break;if(!frame)frame=cvCreateImage(cvSize(framecopy-width,framecopy-height),framecopy-depth,framecopy-nChannels);imageSave=cvCreateImage(cvSize(framecopy-width,framecopy-height),framecopy-depth,framecopy-nChannels);cvCopy(framecopy,imageSave,0);if(framecopy-origin==IPL_ORIGIN_TL)cvCopy(framecopy,frame,0);elsecvFlip(framecopy,frame,0);if(!image)//¸Õ¿ªÊ¼ÏȽ¨Á¢Ò»Ð©»º³åÇø{image=cvCreateImage(cvGetSize(frame),8,3);//image-origin=frame-origin;hsv=cvCreateImage(cvGetSize(frame),8,3);hue=cvCreateImage(cvGetSize(frame),8,1);mask=cvCreateImage(cvGetSize(frame),8,1);//·ÖÅäÑÚĤͼÏñ¿Õ¼äbackproject=cvCreateImage(cvGetSize(frame),8,1);//·ÖÅä·´ÏòͶӰͼ¿Õ¼ä£¬´óСһÑù£¬µ¥Í¨µÀhist=cvCreateHist(1,&hdims,CV_HIST_ARRAY,&hranges,1);//·ÖÅ佨Á¢Ö±·½Í¼¿Õ¼ähistimg=cvCreateImage(cvSize(320,200),8,3);//·ÖÅäÓÃÓÚ»Ö±·½Í¼µÄ¿Õ¼äcvZero(histimg);//±³¾°ÎªºÚÉ«}cvCopy(frame,image,0);cvCvtColor(image,hsv,CV_BGR2HSV);//°ÑͼÏñ´ÓRGB±íɫϵתΪHSV±íɫϵif(track_object)//Èç¹ûµ±Ç°ÓÐÐèÒª¸ú×ÙµÄÎïÌå{int_vmin=vmin,_vmax=vmax;cvInRangeS(hsv,cvScalar(0,smin,MIN(_vmin,_vmax),0),cvScalar(180,256,MAX(_vmin,_vmax),0),mask);//ÖÆ×÷ÑÚĤ°å£¬Ö»´¦ÀíÏñËØֵΪH£º0~180£¬S£ºsmin~256£¬V£ºvmin~vmaxÖ®¼äµÄ²¿·ÖcvSplit(hsv,hue,0,0,0);//È¡µÃH·ÖÁ¿if(track_object0)//Èç¹ûÐèÒª¸ú×ÙµÄÎïÌ廹ûÓнøÐÐÊôÐÔÌáÈ¡£¬Ôò½øÐÐÑ¡È¡¿òÀàµÄͼÏñÊôÐÔÌáÈ¡{floatmax_val=0.f;cvSetImageROI(hue,selection);//ÉèÖÃÔÑ¡Ôñ¿òcvSetImageROI(mask,selection);//ÉèÖÃMaskµÄÑ¡Ôñ¿òcvCalcHist(&hue,hist,0,mask);//µÃµ½Ñ¡Ôñ¿òÄÚÇÒÂú×ãÑÚĤ°åÄÚµÄÖ±·½Í¼cvGetMinMaxHistValue(hist,0,&max_val,0,0);cvConvertScale(hist-bins,hist-bins,max_val?255./max_val:0.,0);//¶ÔÖ±·½Í¼×ªÎª0~255cvResetImageROI(hue);//removeROIcvResetImageROI(mask);track_window=selection;track_object=1;cvZero(histimg);bin_w=histimg-width/hdims;for(i=0;ihdims;i++){intval=cvRound(cvGetReal1D(hist-bins,i)*histimg-height/255);CvScalarcolor=hsv2rgb(i*180.f/hdims);cvRectangle(histimg,cvPoint(i*bin_w,histimg-height),cvPoint((i+1)*bin_w,histimg-height-val),color,-1,8,0);//»Ö±·½Í¼µ½Í¼Ïñ¿Õ¼ä}}cvCalcBackProject(&hue,backproject,hist);//µÃµ½hueµÄ·´ÏòͶӰͼcvAnd(backproject,mask,backproject,0);//µÃµ½·´ÏòͶӰͼmaskÄÚµÄÄÚÈÝcvCamShift(backproject,track_window,cvTermCriteria(CV_TERMCRIT_EPS|CV_TERMCRIT_ITER,10,1),&track_comp,&track_box);//ʹÓÃMeanShiftËã·¨¶ÔbackprojectÖеÄÄÚÈݽøÐÐËÑË÷£¬·µ»Ø¸ú×Ù½á¹ûtrack_window=track_comp.rect;//µÃµ½¸ú×Ù½á¹ûµÄ¾ØÐοòif(backproject_mode)cvCvtColor(backproject,image,CV_GRAY2BGR);//ÏÔʾģʽif(image-origin)track_box.angle=-track_box.angle;cvEllipseBox(image,track_box,CV_RGB(255,0,0),3,CV_AA,0);//»³ö¸ú×Ù½á¹ûµÄλÖÃ}if(select_object&&selection.width0&&selection.height0)//Èç¹ûÕý´¦ÓÚÎïÌåÑ¡Ôñ£¬»³öÑ¡Ôñ¿ò{cvSetImageROI(image,selection);cvXorS(image,cvScalarAll(255),image,0);cvResetImageROI(image);}c=cvWaitKey(10);cvShowImage(CamShift,image);DrawPicToHDC(image,IDC_SHOWVIDEO);}}
本文标题:车牌识别(包括车牌检测-车牌跟踪-车牌识别)源代码下载
链接地址:https://www.777doc.com/doc-4169241 .html