基于MATLAB的QR二维码解码技术的程序
张海桐-20122586-基于matlab算术编码的编码和解码系统设计

目录
第 1 章 绪论.............................................................................................................................. 1 1.1 算数编码研究背景及意义............................................................................................ 1 1.2 算数编码算法的发展历程............................................................................................ 1 1.3 算数编码的思想.............................................................................................................2 1.4 算数编码的译码思想.................................................................................................... 2
根据设计要求,应用 matlab 进行编码和译码。在 GUI 界面里输入一个字符串, 得出结果。并进行解码,验证输入的字符串。 三、基本工作量
1.相应的实例解析。 2.相应的程序框图。 3.设计 GUI 界面 4.参考文献不少于 10 篇,其中外文文献不少于 2 篇。 四、应遵守的法规及主要参考文献 1.有关信源编码的文献及资料。 2.有算数编码的资料。 3.有关 GUI 界面设计的资料。 4.有编码和解码的文献及资料。 五、进度安排 1—2 周 生产实习 3—6 周 毕业实习,熟悉软件,查阅相关资料,完成开题报告 7—9 周 确定完成系统的思路,制定具体设计计划 10—14 周 进行具体设计 15—16 周 毕业设计说明书撰写
毕设论文_加密二维码识别子系统的设计与实现

ห้องสมุดไป่ตู้
北京理工大学本科生毕业设计(论文)
Abstract
National Code Management Centre in order to improve code information service levels, improve business efficiency code, need to establish a new organization code of business information collection systems.
第 2 章 需求分析.............................................................................................................. 4 2.1 需求简要概括.................................................................................................... 4 2.2 本章小结.............................................................................................................6
II
北京理工大学本科生毕业设计(论文)
第 1 章 绪论.......................................................................................................................1 1.1 研究背景与意义................................................................................................1 1.2 国内外研究情况................................................................................................2 1.3 课题研究对象.................................................................................................... 3 1.4 本文组织结构.................................................................................................... 3
第17章_QR软解码-解码流程3获取二维码信息.

目
1.实验描述
2.实验原理 3.实验实现
录
4.关键代码解析
战略性信息产业教育服务提供商
联世界 育未来——创新物联教育
1.实验描述
【实验目的】 了解二维码基本概念; 理解QR码的解码原理; 掌握软解码二维码信息获取的代码实现。
战略性信息产业教育服务提供商
录
4.关键代码解析
战略性信息产业教育服务提供商
联世界 育未来——创新物联教育
3.实验实现
实验步骤: 第一步: 硬件连接 通过串口线连接二维码实验箱的串口与PC端的串口,在 二维码实验箱触摸彩屏选择“软解码”模块。 第二步:创建“Demo5_QR软解码-解码流程3获取二维 码信息”WPF应用程序。 (1)打开Visual Studio 2012,新建“Demo5_QR软 解码-解码流程3获取二维码信息”项目。
战略性信息产业教育服务提供商
联世界 育未来——创新物联教育图17-2战略性信息产业教育服务提供商 联世界 育未来——创新物联教育
五、点击“校验级别”,如图17-3所示
图17-3
战略性信息产业教育服务提供商 联世界 育未来——创新物联教育
六、点击“版本号”,如图17-4所示;
图17-4
战略性信息产业教育服务提供商 联世界 育未来——创新物联教育
战略性信息产业教育服务提供商
联世界 育未来——创新物联教育
目
1.实验描述
2.实验原理 3.实验实现
录
4.关键代码解析
战略性信息产业教育服务提供商
联世界 育未来——创新物联教育
4.关键代码解析
(1)校验级别,本段代码通过 Softdecode.getCheckLevel();获取校验级别
基于MATLAB的QR二维码解码技术的程序

function varargout = QRMain(varargin)% QRMAIN MATLAB code for QRMain.fig% QRMAIN, by itself, creates a new QRMAIN or raises the existing% singleton*.%% H = QRMAIN returns the handle to a new QRMAIN or the handle to% the existing singleton*.%% QRMAIN('CALLBACK',hObject,eventData,handles,...) calls the local% function named CALLBACK in QRMAIN.M with the given input arguments. %% QRMAIN('Property','Value',...) creates a new QRMAIN or raises the% existing singleton*. Starting from the left, property value pairs are% applied to the GUI before QRMain_OpeningFcn gets called. An% unrecognized property name or invalid value makes property application% stop. All inputs are passed to QRMain_OpeningFcn via varargin.%% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)".%% See also: GUIDE, GUIDATA, GUIHANDLES% Edit the above text to modify the response to help QRMain% Last Modified by GUIDE v2.5 11-Apr-2017 20:19:20% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct('gui_Name', mfilename, ...'gui_Singleton', gui_Singleton, ...'gui_OpeningFcn', @QRMain_OpeningFcn, ...'gui_OutputFcn', @QRMain_OutputFcn, ...'gui_LayoutFcn', [] , ...'gui_Callback', []);if nargin && ischar(varargin{1})gui_State.gui_Callback = str2func(varargin{1});endif nargout[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});elsegui_mainfcn(gui_State, varargin{:});end% End initialization code - DO NOT EDIT% --- Executes just before QRMain is made visible.function QRMain_OpeningFcn(hObject, eventdata, handles, varargin)% This function has no output args, see OutputFcn.% hObject handle to figure% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% varargin command line arguments to QRMain (see V ARARGIN)% Choose default command line output for QRMainhandles.output = hObject;% Update handles structureguidata(hObject, handles);% UIWAIT makes QRMain wait for user response (see UIRESUME)% uiwait(handles.figure1);% --- Outputs from this function are returned to the command line.function varargout = QRMain_OutputFcn(hObject, eventdata, handles)% varargout cell array for returning output args (see V ARARGOUT);% hObject handle to figure% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Get default command line output from handles structurevarargout{1} = handles.output;% --- Executes on button press in OpenQRPic.function OpenQRPic_Callback(hObject, eventdata,handles) %%%%%%%%打开图像global im;[filename,pathname]=uigetfile({'*.*';'*.bmp';'*.jpg';'*.tif';'*.jpg'},'选择图像');if isequal(filename,0)||isequal(pathname,0)errordlg('您还没有选取图片!!','温馨提示');%如果没有输入,则创建错误对话框return;elseimage=[pathname,filename];%合成路径+文件名im=imread(image);%读取图像figureimshow(im);%在坐标axes1显示原图像title('原始QR图像');end% hObject handle to OpenQRPic (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % --- Executes on button press in pushbutton2.function pushbutton2_Callback(hObject, eventdata, handles)% hObject handle to pushbutton2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % --- Executes on button press in DecodeQR.function DecodeQR_Callback(hObject, eventdata, handles)%%%%%%%%%%%%%%%%%%% QR解码global I_otsu; %global 定义全局变量global im;global KL;global Ijibian;I_jiema=Ijibian;I_jiema=I_otsu; %二值I_jiema=KL;I_jiema=im;%str=zxing_decode(I_jiema) %解码%set(handles.edit1,'string',[get(handles.edit1,'string') str]);%set(handles.text,'string',[get(handles.text,'string') str]);set(handles.edit1,'String',str); %显示字符% --- Executes on button press in GrayGen.function GrayGen_Callback(hObject, eventdata,handles) %%%%%%%%%%%%%%%%%%% 灰度化处理global im;global II;I=im;[w,h,l]=size(I); %图像大小II=[];for i=1:hfor j=1:wII(j,i)=0.3*I(j,i,1)+0.59*I(j,i,2)+0.11*I(j,i,3); %灰度化处理公式endendfigure,imshow(II,[]) %显示图像title('QR二维码灰度化处理');% --- Executes on button press in SmoothGen.function SmoothGen_Callback(hObject, eventdata, handles)%%%%%%%%%%%%%%%%%%% 平滑处理global II;global I3;III=uint8(II); %图像转换0-255Ix=imnoise(III,'salt & pepper',0.02); %对灰度化图像人为加噪声I3=medfilt2(Ix,[3,3]); %平滑处理figureimshow(Ix)title('QR二维码加噪处理');figureimshow(I3)title('QR二维码平滑处理');% --- Executes on button press in Binaryzation.function Binaryzation_Callback(hObject, eventdata, handles)%%%%%%%%%%%%%%%%%%% 二值化处理global I3;global I_otsu;I_otsu=otsut(I3); %二值化处理figureimshow(I_otsu,[])title('QR二维码二值化处理');% function edit1_Callback(hObject, eventdata, handles)% % hObject handle to edit1 (see GCBO)% % eventdata reserved - to be defined in a future version of MATLAB% % handles structure with handles and user data (see GUIDATA)%% % Hints: get(hObject,'String') returns contents of edit1 as text% % str2double(get(hObject,'String')) returns contents of edit1 as a double% --- Executes during object creation, after setting all properties.function edit1_CreateFcn(hObject, eventdata, handles)% hObject handle to edit1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');end% --- Executes on button press in ImageRotate.function ImageRotate_Callback(hObject, eventdata, handles) %%%% 旋转校正 4.bmpglobal im;%倾斜校正:二值化,取边缘,Hough变换得到角度,旋转I=im;bw=rgb2gray(I); %rgb转换为灰度图bw=im2bw(I,graythresh(bw)); %二值化过程bw=double(bw);BW=edge(bw,'canny'); %canny边缘处理BW1=BW;figureimshow(BW1);title('边缘处理图像'); %显示图像[H,T,R]=hough(BW);figure,imshow(H,[],'XData',T,'YData',R,'InitialMagnification','fit');xlabel('\theta'),ylabel('\rho');axis on, axis normal,hold on;P=houghpeaks(H,4,'threshold',ceil(0.3*max(H(:)))); %hough变化峰值检测x=T(P(:,2)); y = R(P(:,1));plot(x,y,'s','color','white');lines=houghlines(BW,T,R,P,'FillGap',50,'MinLength',7); %hough检测线段figure,imshow(BW),title('直线标识图像');max_len = 0;hold on;for k=1:length(lines) %主要把线条和点显示出来xy=[lines(k).point1;lines(k).point2];% 标出线段plot(xy(:,1),xy(:,2),'LineWidth',2,'Color','green');% 标出线段的起始和终端点plot(xy(1,1),xy(1,2),'x','LineWidth',2,'Color','yellow');plot(xy(2,1),xy(2,2),'x','LineWidth',2,'Color','red');len=norm(lines(k).point1-lines(k).point2);Len(k)=len;if (len>max_len)max_len=len;xy_long=xy;endend% 强调最长的部分plot(xy_long(:,1),xy_long(:,2),'LineWidth',2,'Color','blue');[L1 Index1]=max(Len(:));% 最长线段的起始和终止点x1=[lines(Index1).point1(1) lines(Index1).point2(1)];y1=[lines(Index1).point1(2) lines(Index1).point2(2)];% 求得线段的斜率K1=-(lines(Index1).point1(2)-lines(Index1).point2(2))/...(lines(Index1).point1(1)-lines(Index1).point2(1))angle=atan(K1)*180/pi %显示角度A = imrotate(I,-angle,'bilinear');% imrate 是逆时针的所以取一个负号figure,imshow(A);%imwrite(A,'4qingxie_jiaozheng')% --- Executes on button press in AberrationAdj.function AberrationAdj_Callback(hObject, eventdata, handles) %%%% 畸变校正11.bmpglobal im;global Ijibian;syms a1a2a3a4b1b2b3b4real;I=im;x=[1:256];y=[1:256];control_outpoint=[14 64 %原图像顶点26 221206 38246 196];control_inputpoint=[1 1 %几何畸变图像顶点1 255255 1255 255];x1=control_inputpoint(:,1); %原图像第一列y1=control_inputpoint(:,2); %原图像第二列A=[control_outpoint(1,1) control_outpoint(1,2)control_outpoint(1,1)*control_outpoint(1,2) 1control_outpoint(2,1) control_outpoint(2,2)control_outpoint(2,1)*control_outpoint(2,2) 1control_outpoint(3,1) control_outpoint(3,2)control_outpoint(3,1)*control_outpoint(3,2) 1control_outpoint(4,1) control_outpoint(4,2)control_outpoint(4,1)*control_outpoint(4,2) 1];a=linsolve(A,x1); %等价于a=sym(A)/sym(x1) b=linsolve(A,y1); %等价于a=sym(A)/sym(y1)f1=@(x,y) a(1)*x+a(2)*y+a(3)*x*y+a(4); %定义变换函数f2=@(x,y) b(1)*x+b(2)*y+b(3)*x*y+b(4);for i=1:256for j=1:256x1(i,j)=f1(i,j);y1(i,j)=f2(i,j);I1(i,j)=interp2(x,y,I,x1(i,j),y1(i,j),'bilinear'); %双线性插值%I1(i,j)=interp2(x1(i,j),y1(i,j),I,x,y,'bilinear');endendIjibian=I1;figureimshow(I1);function edit3_Callback(hObject, eventdata, handles)% hObject handle to edit3 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of edit3 as text% str2double(get(hObject,'String')) returns contents of edit3 as a double% --- Executes during object creation, after setting all properties.function edit3_CreateFcn(hObject, eventdata, handles)% hObject handle to edit3 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');end% --- Executes on button press in QRGen.function QRGen_Callback(hObject, eventdata, handles) %%%% 自制QR (用英文)global KL;str3=get(handles.edit3,'string') %得到string数据KL=qrgen(str3,300,300); %生成相应QR二维码figureimshow(KL,[])imwrite(KL,'KL.png')% --- Executes on button press in QRgenDecode.function QRgenDecode_Callback(hObject, eventdata,handles) %%%%%%%%自制QR解码显示global KL;I_jiema=imread('KL.bmp');str2=zxing_decode(I_jiema) %解码过程set(handles.edit1,'String',str2);% --- Executes on key press with focus on QRgenDecode and none of its controls. function QRgenDecode_KeyPressFcn(hObject, eventdata, handles)% hObject handle to QRgenDecode (see GCBO)% eventdata structure with the following fields (see UICONTROL)% Key: name of the key that was pressed, in lower case% Character: character interpretation of the key(s) that was pressed% Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed% handles structure with handles and user data (see GUIDATA)% --- Executes on button press in pushbutton11.function pushbutton11_Callback(hObject, eventdata, handles)% hObject handle to pushbutton11 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA) AllFigureHandle=get(0,'Children'); % Contain Figure and GUIflag=rem(AllFigureHandle,1);%OnlyPictureHandle=AllFigureHandle(find(flag==0)); % Exclude GUI,because GUI'handle is decimalclose(OnlyPictureHandle);% --- If Enable == 'on', executes on mouse press in 5 pixel border.% --- Otherwise, executes on mouse press in 5 pixel border or over DecodeQR. function DecodeQR_ButtonDownFcn(hObject, eventdata, handles)% hObject handle to DecodeQR (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)。
(完整版)二维码的生成与实现(matlab)

课程设计报告课题名称:二维码的生成与识别项目完成人(班级、学号、姓名):项目完成时间: 2017/6/15一、引言1、编写目的本学期学习《数字图像处理》,包含很多知识点,像:图像编码与压缩、图像相关变换、图像增强技术、图像复原技术,这些知识点的应用在实际编程中都非常重要。
纸上得来终觉浅,绝知此事要躬行。
所以,这次课程设计的目的主要就是巩固所学的数字图像处理的相关知识。
最终是我们通过该教学环节,把该课程以及相关知识融会贯通。
2、背景由于受信息的容量限制,一维条码仅仅是对“物品”的标识,而不是对“物品”的描述,故一维条码的使用不得不依赖数据库存在。
在使用上受到了极大的限制,效率很低。
二维码正是为了解决一维条码无法解决的问题而产生的。
二维码具有高密度、高可靠性等特点,可以用来表示数据文件、图像等,实现信息获取、网站跳转、广告推送、手机电商、优惠促销、会员管理等功能,具有很强的研究意义。
3、参考资料《数字图像处理》第三版胡学龙二、设计方案1、图像采集图像主要来自网上在线生成的二维码图像和该程序生成的二维码图像。
2、算法分析预处理过程灰度化-----平滑处理------二值化1.灰度化:一般都是为了减小图像原始数据量,便于后续处理时计算量更少,因为图像处理不一定需要对彩色图像的RGB三个分量都进行处理2.平滑处理:图像平滑是指用于突出图像的宽大区域、低频成分、主干部分或抑制图像噪声和干扰高频成分,使图像亮度平缓渐变,减小突变梯度,改善图像质量的图像处理方法。
图像平滑的方法包括:插值方法,线性平滑方法,卷积法等等。
这样的处理方法根据图像噪声的不同进行平滑,比如椒盐噪声,就采用线性平滑方法!3.二值化:图像二值化就是将图像上的像素点的灰度值设置为0或255,也就是将整个图像呈现出明显的黑白效果。
二维码解码二维码解码主要使用的是ZXing库,ZXing是个很经典的条码/二维码识别的开源类库3、代码实现打开图像function pushbutton1_Callback(hObject, eventdata, handles) global im;[filename,pathname]=uigetfile({'*.*';'*.bmp';'*.jpg';'*.tif';'*.jpg'} ,'选择图像');if isequal(filename,0)||isequal(pathname,0)errordlg('您还没有选取图片!!','温馨提示');%如果没有输入,则创建错误对话框return;elsedisp(['User selected',fullfile(pathname,filename)]);fprintf('fffffff%s\n',filename);im=imread(filename);%读取图像figureimshow(im);%在坐标axes1显示原图像title('原始图像');End灰度化处理function pushbutton4_Callback(hObject, eventdata, handles)global im;global II;I=im;[w,h,l]=size(I); %图像大小II=[];for i=1:hfor j=1:wII(j,i)=0.3*I(j,i,1)+0.59*I(j,i,2)+0.11*I(j,i,3); %灰度化处理公式endendfigure,imshow(II,[]) %显示图像title('二维码灰度化处理');平滑处理function pushbutton5_Callback(hObject, eventdata, handles)global II;global I3;III=uint8(II); %图像转换0-255Ix=imnoise(III,'salt & pepper',0.02); %对灰度化图像人为加噪声I3=medfilt2(Ix,[3,3]); %平滑处理figureimshow(Ix)title('二维码加噪处理');figureimshow(I3)title('二维码平滑处理');二值化处理function pushbutton6_Callback(hObject, eventdata, handles)global I3;global I_otsu;I_otsu=otsut(I3); %二值化处理figureimshow(I_otsu,[])title('二维码二值化处理');旋转校正function pushbutton7_Callback(hObject, eventdata, handles) global im;%倾斜校正:二值化,取边缘,Hough变换得到角度,旋转I=im;bw=rgb2gray(I); %rgb转换为灰度图bw=im2bw(I,graythresh(bw)); %二值化过程bw=double(bw);BW=edge(bw,'canny'); %canny边缘处理BW1=BW;figureimshow(BW1);title('canny 边界图像'); %显示图像[H,T,R]=hough(BW);figure,imshow(H,[],'XData',T,'YData',R,'InitialMagnification','fit'); xlabel('\theta'),ylabel('\rho');axis on, axis normal,hold on;P=houghpeaks(H,4,'threshold',ceil(0.3*max(H(:)))); %hough变化峰值检测x=T(P(:,2)); y = R(P(:,1));plot(x,y,'s','color','white');lines=houghlines(BW,T,R,P,'FillGap',50,'MinLength',7); %hough检测线段figure,imshow(BW),title('直线标识图像');max_len = 0;hold on;for k=1:length(lines) %主要把线条和点显示出来xy=[lines(k).point1;lines(k).point2];% 标出线段plot(xy(:,1),xy(:,2),'LineWidth',2,'Color','green');% 标出线段的起始和终端点plot(xy(1,1),xy(1,2),'x','LineWidth',2,'Color','yellow');plot(xy(2,1),xy(2,2),'x','LineWidth',2,'Color','red');len=norm(lines(k).point1-lines(k).point2);Len(k)=len;if (len>max_len)max_len=len;xy_long=xy;endend% 强调最长的部分plot(xy_long(:,1),xy_long(:,2),'LineWidth',2,'Color','blue');[L1 Index1]=max(Len(:));% 最长线段的起始和终止点x1=[lines(Index1).point1(1) lines(Index1).point2(1)];y1=[lines(Index1).point1(2) lines(Index1).point2(2)];% 求得线段的斜率K1=-(lines(Index1).point1(2)-lines(Index1).point2(2))/...(lines(Index1).point1(1)-lines(Index1).point2(1))angle=atan(K1)*180/pi %显示角度A = imrotate(I,-angle,'bilinear');% imrate 是逆时针的所以取一个负号figure,imshow(A);解码function pushbutton3_Callback(hObject, eventdata, handles)global I_otsu; %global 定义全局变量global im;global KL;global Ijibian;I_jiema=Ijibian;I_jiema=I_otsu; %二值I_jiema=KL;I_jiema=im;str=zxing_decode(I_jiema) %解码set(handles.edit1,'String',str); %显示字符三、出错处理1、出错信息2、出错处理方法及补救措施主要是由于导入的jar包文件的路径错误而导致的,所以修改好对应的路径即可。
基于树莓派的QR二维码信息获取

基于树莓派的QR二维码信息获取作者:周丹丹杨静任楠来源:《电子技术与软件工程》2017年第08期摘要采用视频采集模块对QR二维码进行捕捉,然后传入到树莓派中,通过算法和Zbar的结合对采集到的视频信息进行解码和转换,并将得到的数据信息储存在数据库中,同时输出。
利用树莓派和zbar,顺利实现了对QR二维码信息的提取,储存和输出。
测试结果表明,基于树莓派的QR二维码信息获取的设计能够完成识别、提取,解码,数据库储存和显示输出。
【关键词】树莓派 ZbarQR 二维码数据库随着计算机视觉与人工智能的发展,信息社会的高速发展,信息技术、自动化技术已逐渐渗透进人们的日常生活中。
信息采集是信息技术中的重要环节,条码技术是一种常用的自动化信息采集技术。
二维码是在普通一维条码上扩展出另一维具有可读性的条码,具有比一维条码大得多的信息容量,可以不依赖于后台的数据库或联网;同时,二维码有一维条码没有的“容错机制”,即使在条码被污损或残缺等情况下,其中的信息仍然可以被正确地还原。
QR 码是常用的矩阵式二维码的一种,又名快速响应矩阵码(Quick Response Code),于1994 年由日本DENSO WAVE 公司发明。
QR 码目前主要应用在自动化文字传输、数字内容下载、网址快速链接、身份鉴别与商务交易等方面本文中,笔者采用微处理器树莓派对QR二维码通过算法处理与计算分析,对QR码中蕴藏的信息进行获取,并将获取到的信息存放在数据库中。
1 硬件设计本系统的硬件部分主要由视频采集模块、显示输出模块和树莓派B+微处理器及其周边外设配置组成。
系统在基于树莓派 B + 微处理器和嵌入式 Linux 系统平台上,首先通过USB 摄像头捕获QR二维码图像信息,将图像信息传入到树莓派开发板内,通过图像处理算法程序对其进行数据分析、解码,然后通过显示器将处理结果进行输出,并将视频信息解码后的内容存入到数据库中,系统硬件结构方框图如图 1 所示。
《基于机器视觉的工业产品QR码识别》

《基于机器视觉的工业产品QR码识别》一、引言随着工业自动化和智能制造的快速发展,机器视觉技术在工业领域的应用越来越广泛。
其中,QR码识别技术作为机器视觉的一个重要应用方向,对于工业产品的追溯、监控和管理具有重要意义。
本文将介绍基于机器视觉的工业产品QR码识别技术,分析其原理、方法及在工业生产中的应用,并探讨其未来发展趋势。
二、机器视觉与QR码识别技术机器视觉是一种利用计算机图像处理技术实现自动识别、分析和理解的技术。
而QR码(Quick Response Code)是一种常见的二维条码,具有信息容量大、可靠性高、易制作等特点。
基于机器视觉的QR码识别技术,通过图像采集、预处理、特征提取和匹配等步骤,实现对QR码的快速、准确识别。
三、QR码识别技术原理及方法1. 图像采集与预处理:使用工业相机等设备对QR码进行图像采集,然后进行灰度化、二值化、去噪等预处理操作,以便后续的特征提取。
2. 特征提取:通过图像处理算法提取QR码的黑白矩阵特征、几何特征和空间特征等,为后续的匹配和识别提供依据。
3. 匹配与识别:将提取的特征与预先存储的QR码特征库进行匹配,通过算法对匹配结果进行评估和筛选,最终实现QR码的识别。
四、工业产品QR码识别的应用1. 产品追溯与监控:通过QR码识别技术,可以实现对工业产品的追溯和监控,包括产品生产、流通、销售等各个环节的信息记录和查询。
2. 生产自动化:将QR码识别技术应用于生产线自动化控制,可以实现生产过程的自动化、智能化和高效化。
3. 仓库管理:通过QR码识别技术,可以实现对仓库物品的快速、准确盘点和管理,提高仓库作业效率。
五、基于机器视觉的QR码识别技术的优势与挑战优势:1. 快速、准确:基于机器视觉的QR码识别技术具有高速度、高精度的特点,可以实现对QR码的快速、准确识别。
2. 非接触式:该技术无需与QR码直接接触,即可实现识别,适用于各种复杂环境。
3. 信息量大:QR码具有信息容量大的特点,可以存储大量产品信息,便于实现产品追溯和监控。
QR码在Android手机平台的解码算法研究的开题报告

QR码在Android手机平台的解码算法研究的开题报告一、研究背景二维码在现代社会中得到了广泛的应用,如超市商品售价查询、公共停车场缴费、广告招贴等等,其中二维码的一种– QR码,也因其容错性与数据量大降低了读取时的出错率,在Android手机中得到了广泛的应用。
本文主要研究的问题则是在Android手机平台上如何进行QR码的解码识别。
二、研究目的在现代社会中,二维码越来越多地出现在各种场景中,而这些二维码的识别与解码算法也变得越来越重要。
本文旨在通过研究QR码的解码算法,实现在Android手机平台上的QR码解码。
三、研究内容1、QR码原理研究:QR码的基本构成以及生成原理2、QR码解码算法研究:对QR码解码算法的研究,并进行Android 环境下的适配3、实现:将QR码解码算法应用于Android平台,生成一个可行的QR码解码应用程序。
四、预期效果在Android平台上实现一个快速、准确的QR码解码应用程序,为不同领域在移动设备端的QR码识别提供方便,加快了用户的工作效率,提升用户的使用体验。
五、研究方法1、文献调研法:通过查阅相关文献,了解QR码解码算法的研究和技术发展现状,总结二维码技术的发展进程,确定本研究的主要研究方向和内容。
2、理论分析法:采用数学分析、图像处理等理论方法,对QR码解码算法原理进行深入分析研究,找出QR码解码算法在移动设备上的优化方法。
3、实践探究法:利用Java语言与开源库ZXing,完成QR码解码程序的设计及实现,并在各种数据集下进行实验验证,得出QR码解码算法在移动设备上的性能指标。
六、研究意义本文的主要意义在于,在Android平台上实现一个QR码解码应用程序,提供更快捷、更精准的QR码安卓端解码服务,为不同领域提供一个安全、便捷、高效的二维码识别方案。
二维码技术的发展在近年来得到了迅猛的发展,因此本研究将对二维码识别在各个领域的应用起到一定的倡导作用。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
function varargout = QRMain(varargin)% QRMAIN MATLAB code for QRMain.fig% QRMAIN, by itself, creates a new QRMAIN or raises the existing% singleton*.%% H = QRMAIN returns the handle to a new QRMAIN or the handle to% the existing singleton*.%% QRMAIN('CALLBACK',hObject,eventData,handles,...) calls the local% function named CALLBACK in QRMAIN.M with the given input arguments. %% QRMAIN('Property','Value',...) creates a new QRMAIN or raises the% existing singleton*. Starting from the left, property value pairs are% applied to the GUI before QRMain_OpeningFcn gets called. An% unrecognized property name or invalid value makes property application% stop. All inputs are passed to QRMain_OpeningFcn via varargin.%% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)".%% See also: GUIDE, GUIDATA, GUIHANDLES% Edit the above text to modify the response to help QRMain% Last Modified by GUIDE v2.5 11-Apr-2017 20:19:20% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct('gui_Name', mfilename, ...'gui_Singleton', gui_Singleton, ...'gui_OpeningFcn', @QRMain_OpeningFcn, ...'gui_OutputFcn', @QRMain_OutputFcn, ...'gui_LayoutFcn', [] , ...'gui_Callback', []);if nargin && ischar(varargin{1})gui_State.gui_Callback = str2func(varargin{1});endif nargout[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});elsegui_mainfcn(gui_State, varargin{:});end% End initialization code - DO NOT EDIT% --- Executes just before QRMain is made visible.function QRMain_OpeningFcn(hObject, eventdata, handles, varargin)% This function has no output args, see OutputFcn.% hObject handle to figure% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% varargin command line arguments to QRMain (see V ARARGIN)% Choose default command line output for QRMainhandles.output = hObject;% Update handles structureguidata(hObject, handles);% UIWAIT makes QRMain wait for user response (see UIRESUME)% uiwait(handles.figure1);% --- Outputs from this function are returned to the command line.function varargout = QRMain_OutputFcn(hObject, eventdata, handles)% varargout cell array for returning output args (see V ARARGOUT);% hObject handle to figure% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Get default command line output from handles structurevarargout{1} = handles.output;% --- Executes on button press in OpenQRPic.function OpenQRPic_Callback(hObject, eventdata,handles) %%%%%%%%打开图像global im;[filename,pathname]=uigetfile({'*.*';'*.bmp';'*.jpg';'*.tif';'*.jpg'},'选择图像');if isequal(filename,0)||isequal(pathname,0)errordlg('您还没有选取图片!!','温馨提示');%如果没有输入,则创建错误对话框return;elseimage=[pathname,filename];%合成路径+文件名im=imread(image);%读取图像figureimshow(im);%在坐标axes1显示原图像title('原始QR图像');end% hObject handle to OpenQRPic (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % --- Executes on button press in pushbutton2.function pushbutton2_Callback(hObject, eventdata, handles)% hObject handle to pushbutton2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % --- Executes on button press in DecodeQR.function DecodeQR_Callback(hObject, eventdata, handles)%%%%%%%%%%%%%%%%%%% QR解码global I_otsu; %global 定义全局变量global im;global KL;global Ijibian;I_jiema=Ijibian;I_jiema=I_otsu; %二值I_jiema=KL;I_jiema=im;%str=zxing_decode(I_jiema) %解码%set(handles.edit1,'string',[get(handles.edit1,'string') str]);%set(handles.text,'string',[get(handles.text,'string') str]);set(handles.edit1,'String',str); %显示字符% --- Executes on button press in GrayGen.function GrayGen_Callback(hObject, eventdata,handles) %%%%%%%%%%%%%%%%%%% 灰度化处理global im;global II;I=im;[w,h,l]=size(I); %图像大小II=[];for i=1:hfor j=1:wII(j,i)=0.3*I(j,i,1)+0.59*I(j,i,2)+0.11*I(j,i,3); %灰度化处理公式endendfigure,imshow(II,[]) %显示图像title('QR二维码灰度化处理');% --- Executes on button press in SmoothGen.function SmoothGen_Callback(hObject, eventdata, handles)%%%%%%%%%%%%%%%%%%% 平滑处理global II;global I3;III=uint8(II); %图像转换0-255Ix=imnoise(III,'salt & pepper',0.02); %对灰度化图像人为加噪声I3=medfilt2(Ix,[3,3]); %平滑处理figureimshow(Ix)title('QR二维码加噪处理');figureimshow(I3)title('QR二维码平滑处理');% --- Executes on button press in Binaryzation.function Binaryzation_Callback(hObject, eventdata, handles)%%%%%%%%%%%%%%%%%%% 二值化处理global I3;global I_otsu;I_otsu=otsut(I3); %二值化处理figureimshow(I_otsu,[])title('QR二维码二值化处理');% function edit1_Callback(hObject, eventdata, handles)% % hObject handle to edit1 (see GCBO)% % eventdata reserved - to be defined in a future version of MATLAB% % handles structure with handles and user data (see GUIDATA)%% % Hints: get(hObject,'String') returns contents of edit1 as text% % str2double(get(hObject,'String')) returns contents of edit1 as a double% --- Executes during object creation, after setting all properties.function edit1_CreateFcn(hObject, eventdata, handles)% hObject handle to edit1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');end% --- Executes on button press in ImageRotate.function ImageRotate_Callback(hObject, eventdata, handles) %%%% 旋转校正 4.bmpglobal im;%倾斜校正:二值化,取边缘,Hough变换得到角度,旋转I=im;bw=rgb2gray(I); %rgb转换为灰度图bw=im2bw(I,graythresh(bw)); %二值化过程bw=double(bw);BW=edge(bw,'canny'); %canny边缘处理BW1=BW;figureimshow(BW1);title('边缘处理图像'); %显示图像[H,T,R]=hough(BW);figure,imshow(H,[],'XData',T,'YData',R,'InitialMagnification','fit');xlabel('\theta'),ylabel('\rho');axis on, axis normal,hold on;P=houghpeaks(H,4,'threshold',ceil(0.3*max(H(:)))); %hough变化峰值检测x=T(P(:,2)); y = R(P(:,1));plot(x,y,'s','color','white');lines=houghlines(BW,T,R,P,'FillGap',50,'MinLength',7); %hough检测线段figure,imshow(BW),title('直线标识图像');max_len = 0;hold on;for k=1:length(lines) %主要把线条和点显示出来xy=[lines(k).point1;lines(k).point2];% 标出线段plot(xy(:,1),xy(:,2),'LineWidth',2,'Color','green');% 标出线段的起始和终端点plot(xy(1,1),xy(1,2),'x','LineWidth',2,'Color','yellow');plot(xy(2,1),xy(2,2),'x','LineWidth',2,'Color','red');len=norm(lines(k).point1-lines(k).point2);Len(k)=len;if (len>max_len)max_len=len;xy_long=xy;endend% 强调最长的部分plot(xy_long(:,1),xy_long(:,2),'LineWidth',2,'Color','blue');[L1 Index1]=max(Len(:));% 最长线段的起始和终止点x1=[lines(Index1).point1(1) lines(Index1).point2(1)];y1=[lines(Index1).point1(2) lines(Index1).point2(2)];% 求得线段的斜率K1=-(lines(Index1).point1(2)-lines(Index1).point2(2))/...(lines(Index1).point1(1)-lines(Index1).point2(1))angle=atan(K1)*180/pi %显示角度A = imrotate(I,-angle,'bilinear');% imrate 是逆时针的所以取一个负号figure,imshow(A);%imwrite(A,'4qingxie_jiaozheng')% --- Executes on button press in AberrationAdj.function AberrationAdj_Callback(hObject, eventdata, handles) %%%% 畸变校正11.bmpglobal im;global Ijibian;syms a1a2a3a4b1b2b3b4real;I=im;x=[1:256];y=[1:256];control_outpoint=[14 64 %原图像顶点26 221206 38246 196];control_inputpoint=[1 1 %几何畸变图像顶点1 255255 1255 255];x1=control_inputpoint(:,1); %原图像第一列y1=control_inputpoint(:,2); %原图像第二列A=[control_outpoint(1,1) control_outpoint(1,2)control_outpoint(1,1)*control_outpoint(1,2) 1control_outpoint(2,1) control_outpoint(2,2)control_outpoint(2,1)*control_outpoint(2,2) 1control_outpoint(3,1) control_outpoint(3,2)control_outpoint(3,1)*control_outpoint(3,2) 1control_outpoint(4,1) control_outpoint(4,2)control_outpoint(4,1)*control_outpoint(4,2) 1];a=linsolve(A,x1); %等价于a=sym(A)/sym(x1) b=linsolve(A,y1); %等价于a=sym(A)/sym(y1)f1=@(x,y) a(1)*x+a(2)*y+a(3)*x*y+a(4); %定义变换函数f2=@(x,y) b(1)*x+b(2)*y+b(3)*x*y+b(4);for i=1:256for j=1:256x1(i,j)=f1(i,j);y1(i,j)=f2(i,j);I1(i,j)=interp2(x,y,I,x1(i,j),y1(i,j),'bilinear'); %双线性插值%I1(i,j)=interp2(x1(i,j),y1(i,j),I,x,y,'bilinear');endendIjibian=I1;figureimshow(I1);function edit3_Callback(hObject, eventdata, handles)% hObject handle to edit3 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of edit3 as text% str2double(get(hObject,'String')) returns contents of edit3 as a double% --- Executes during object creation, after setting all properties.function edit3_CreateFcn(hObject, eventdata, handles)% hObject handle to edit3 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');end% --- Executes on button press in QRGen.function QRGen_Callback(hObject, eventdata, handles) %%%% 自制QR (用英文)global KL;str3=get(handles.edit3,'string') %得到string数据KL=qrgen(str3,300,300); %生成相应QR二维码figureimshow(KL,[])imwrite(KL,'KL.png')% --- Executes on button press in QRgenDecode.function QRgenDecode_Callback(hObject, eventdata,handles) %%%%%%%%自制QR解码显示global KL;I_jiema=imread('KL.bmp');str2=zxing_decode(I_jiema) %解码过程set(handles.edit1,'String',str2);% --- Executes on key press with focus on QRgenDecode and none of its controls. function QRgenDecode_KeyPressFcn(hObject, eventdata, handles)% hObject handle to QRgenDecode (see GCBO)% eventdata structure with the following fields (see UICONTROL)% Key: name of the key that was pressed, in lower case% Character: character interpretation of the key(s) that was pressed% Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed% handles structure with handles and user data (see GUIDATA)% --- Executes on button press in pushbutton11.function pushbutton11_Callback(hObject, eventdata, handles)% hObject handle to pushbutton11 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA) AllFigureHandle=get(0,'Children'); % Contain Figure and GUIflag=rem(AllFigureHandle,1);%OnlyPictureHandle=AllFigureHandle(find(flag==0)); % Exclude GUI,because GUI'handle is decimalclose(OnlyPictureHandle);% --- If Enable == 'on', executes on mouse press in 5 pixel border.% --- Otherwise, executes on mouse press in 5 pixel border or over DecodeQR. function DecodeQR_ButtonDownFcn(hObject, eventdata, handles)% hObject handle to DecodeQR (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)。