SIFT算子车标识别算法MATLAB仿真实践

1.软件版本

matlab2017b

2.系统概述

本系统分为定位部分(包括车牌的定位和车标的定位)和车标特征向量提取和识别部分。本文车标的定位是根据车牌和车标的先验知识,提出一种由粗到精的车标定位方法。首先通过成熟的车牌定位方法对车牌进行定位,再根据车牌与车标的相对位置可以估计出车标的大概区域;接着利用 SOBLE 边缘检测算子对车标估计区域同时进行垂直边缘的检测和水平边缘的检测,分割车标区域与背景区域;接着再利用数学形态学进行腐蚀膨胀处理得到车标的精确区域。车标特征向量的提取利用 SIFT 算子进行提取。SIFT 算子的主要优点是信息量丰富,独特性好,适合在海量数据中进行快速、准确的匹配。通过 SIFT 算子对车标进行特征提取和特征向量的生成,最后通过欧式距离判断待匹配的车标向量与模板库的车标向量的相似性,最终达到识别出车标的作用。


3.部分程序  

登录后复制

clc;clear;close all;warning off;addpath 'func\'%导入车标,进行模式识别%转换为灰度图I1 = 
rgb2gray(imread('type/1.jpg'));I2 = rgb2gray(imread('type/2.jpg'));I3 = rgb2gray(imread('type/3.jpg'));
I4 = rgb2gray(imread('type/4.jpg'));Img2= imread('images\20.jpg');%配准线连接数量间隔设置for kk = 1:4    
if kk == 1       Img1 = I1;     end    if kk == 2       Img1 = I2;     end        if kk == 3       Img1 = I3;
end     if kk == 4       Img1 = I4;     end%将图片大小进行统一Img2         
= imresize(Img2,[480,640]);%%%车牌的定位[R,C,K] = size(Img2);Img3    = zeros(R,C);for i = 1:R    
for j = 1:C        %候选区域的确定        if (Img2(i,j,1)<20) & (Img2(i,j,2)<20)  & (Img2(i,j,3)>100)
Img3(i,j) = 1;        end    endend%%%车标的初步定位BW0 = bwareaopen(Img3,400);[rows,cols] = size(BW0); [L,n]
= bwlabel(BW0);for i=1 : n    [r,c]=find(L==i);    a1(i)=max(r);    a2(i)=min(r);    b1(i)=max(c);    
b2(i)=min(c);    w(i)=b1(i)-b2(i);    h(i)=a1(i)-a2(i);    square = w(i)*h(i);    if square > 1000       
Yc = (a1(i) + a2(i))/2;       Xc = (b1(i) + b2(i))/2;    endendXc2 = Xc;Yc2 = Yc-75;xl  = Yc2-40;xr  
= Yc2+40;yl  = Xc2-50;yr  = Xc2+50;CB  = Img2(xl:Yc2+40,Xc2-50:Xc2+50,:);figure(1);imshow(Img2);
hold onplot([b2:b1],a1*ones(size([b2:b1])),'r','linewidth',2);hold onplot([b2:b1],a2*ones(size([b2:b1])),
'r','linewidth',2);hold onplot(b1*ones(size([a2:a1])),[a2:a1],'r','linewidth',2);hold onplot(b2*ones(size(
[a2:a1])),[a2:a1],'r','linewidth',2);hold onplot([yl:yr],xl*ones(size([yl:yr])),'g','linewidth',2);
hold onplot([yl:yr],xr*ones(size([yl:yr])),'g','linewidth',2);hold onplot(yr*ones(size([xl:xr])),
[xl:xr],'g','linewidth',2);hold onplot(yl*ones(size([xl:xr])),[xl:xr],'g','linewidth',2);
hold ontitle('车标初步定位'); im1 = Img1;im2 = rgb2gray(CB);%基于SIFT的定位gray1=(im1);gray2=(im2);
[des1,loc1]=func_sift(gray1);[des2,loc2]=func_sift(gray2);figure(2);func_drawPoints(im1,loc1,im2,loc2);
Num=2;Thresh=0.85;match=func_BidirectionalMatch(des1,des2,Num,Thresh);clear des1 des2if isempty(match) == 0    
loc1=loc1(match(:,1),:);    loc2=loc2(match(:,2),:);    figure(3);    func_linePoints(im1,loc1,im2,loc2);    
Lens(kk) = length(match);else    Lens(kk) = 0;endpause(1);end[V,I] = max(Lens);if I == 1   figure;   
imshow(Img2);   title('科鲁兹车','fontsize',16);endif I == 2   figure;   imshow(Img2);   
title('别克车','fontsize',16);   endif I == 3   figure;   imshow(Img2);   title('凯迪拉克车','fontsize',16);   
endif I == 4   figure;   imshow(Img2);   title('大众车','fontsize',16);   end1.2.3.4.5.6.7.8.9.10.11.12.13.14.
15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.31.32.33.34.35.36.37.38.39.40.41.42.43.44.45.46.47.48.49.50.
51.52.53.54.55.56.57.58.59.60.61.62.63.64.65.66.67.68.69.70.71.72.73.74.75.76.77.78.79.80.81.82.83.84.85.86.
87.88.89.90.91.92.93.94.95.96.97.98.99.100.101.102.103.104.105.106.107.108.109.110.111.112.113.114.115.116.
117.118.119.120.121.122.123.124.125.126.127.128.129.130.131.132.133.134.135.136.137.138.139.140.141.142.143.
144.145.146.




登录后复制
function [des,loc]=func_sift(im)[row,col]=size(im);
% Convert into PGM imagefile, readable by "keypoints" executablef=fopen('tmp.pgm','w');
if f==-1    error('Could not create file tmp.pgm.');endfprintf(f, 'P5\n%d\n%d\n255\n', col, row);
fwrite(f,im','uint8');fclose(f);% Call keypoints executableif isunix    command = '!./sift ';
else    command = '!siftWin32 ';endcommand = [command ' <tmp.pgm >tmp.key'];eval(command);
% Open tmp.key and check its headerg=fopen('tmp.key','r');if g==-1    error('Could not open file tmp.key.');
end[header,cnt]=fscanf(g,'%d %d',[1 2]);if cnt~=2    error('Invalid keypoint file beginning.');
endnum=header(1);len=header(2);if len~=128    error('Keypoint descriptor length invalid (should be 128).');
end% Creates the two output matrices (use known size for efficiency)loc=double(zeros(num,4));
des=double(zeros(num,128));for k=1:num    [vector,cnt]=fscanf(g, '%f %f %f %f', [1 4]);   
 if cnt~=4        error('Invalid keypoint file format');    end    loc(k,:)=vector(1,:);     
 [descrip, count] = fscanf(g, '%d', [1 len]);    if (count ~= 128)        
 error('Invalid keypoint file value.');    end    descrip = descrip / sqrt(sum(descrip.^2));    
 des(k, :) = descrip(1, :);endfclose(g);for k=1:size(des,1)    des(k,:)=des(k,:)/sum(des(k,:));
 enddelete tmp.key tmp.pgm1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.28.
 29.30.31.32.33.34.35.36.37.38.39.40.41.42.43.44.45.46.47.48.49.50.51.52.53.54.55.56.57.58.59.

4.仿真结论

【车标识别】基于SIFT算子的车标识别算法matlab仿真_matlab


【车标识别】基于SIFT算子的车标识别算法matlab仿真_车牌定位_02


【车标识别】基于SIFT算子的车标识别算法matlab仿真_车标识别_03


免责声明:本文系网络转载或改编,未找到原创作者,版权归原作者所有。如涉及版权,请联系删

QR Code
微信扫一扫,欢迎咨询~

联系我们
武汉格发信息技术有限公司
湖北省武汉市经开区科技园西路6号103孵化器
电话:155-2731-8020 座机:027-59821821
邮件:tanzw@gofarlic.com
Copyright © 2023 Gofarsoft Co.,Ltd. 保留所有权利
遇到许可问题?该如何解决!?
评估许可证实际采购量? 
不清楚软件许可证使用数据? 
收到软件厂商律师函!?  
想要少购买点许可证,节省费用? 
收到软件厂商侵权通告!?  
有正版license,但许可证不够用,需要新购? 
联系方式 155-2731-8020
预留信息,一起解决您的问题
* 姓名:
* 手机:

* 公司名称:

姓名不为空

手机不正确

公司不为空