首页
统计
留言
Search
1
测试1
2,065 阅读
2
测试2
1,320 阅读
3
typecho内嵌B站视频
1,115 阅读
4
测试3神经猫
1,079 阅读
5
Matlab 计算机视觉实验-UI
1,026 阅读
Java学习记录
Matlab学习记录
测试
路径规划学习
登录
Search
Mango57
累计撰写
22
篇文章
累计收到
2
条评论
首页
栏目
Java学习记录
Matlab学习记录
测试
路径规划学习
页面
统计
留言
搜索到
3
篇与
Matlab学习记录
的结果
2022-05-27
Matlab生成栅格地图
clc clear close all %% 构建颜色MAP图 cmap = [1 1 1; ... % 1-白色-空地 0 0 0; ... % 2-黑色-静态障碍 1 0 0; ... % 3-红色-动态障碍 1 1 0;... % 4-黄色-起始点 1 0 1;... % 5-品红-目标点 0 1 0; ... % 6-绿色-到目标点的规划路径 0 1 1]; % 7-青色-动态规划的路径 % 构建颜色MAP图 colormap(cmap); %% 构建栅格地图场景 % 栅格界面大小:行数和列数 rows = 10; cols = 20; % 定义栅格地图全域,并初始化空白区域 field = ones(rows, cols); % 障碍物区域 obsRate = 0.3; obsNum = floor(rows*cols*obsRate); obsIndex = randi([1,rows*cols],obsNum,1); field(obsIndex) = 2; % 起始点和目标点 startPos = 2; goalPos = rows*cols-2; field(startPos) = 4; field(goalPos) = 5; %% 画栅格图 image(1.5,1.5,field); grid on; set(gca,'gridline','-','gridcolor','k','linewidth',2,'GridAlpha',0.5); set(gca,'xtick',1:cols+1,'ytick',1:rows+1); axis image;
2022年05月27日
388 阅读
0 评论
0 点赞
2022-05-09
Matlab A*算法
参考原地址 为了方便学习查看,贴了过来,仅个人自用!{lamp/}1、pathfinding.m起始角本文件,规定了障碍点,边界点,起点,终点及地图规模。clear; clc; disp('A Star Path Planing start!!') map.XYMAX=20; %%代表我们要画一个地图的长和宽 map.start=[1,1]; %起始点 注意必须在地图范围内 map.goal=[18,18]; %目标点 注意必须在地图范围内 obstacle=GetBoundary(map);%得到边界数据 nObstacle=0;%在地图中随机加入XX个障碍物 obstacle=GetObstacle(nObstacle,obstacle,map);%障碍物和边界坐标 obstacle = [obstacle;4,1; 4,2; 4,3; 4,4; 3,4 ;2,4;];%全封死的情况,是没有路的 %obstacle = [obstacle;1,2;2,1;2,2];%此也为全封死的情况,也没有路的 %obstacle = [obstacle;1,3;2,3;3,3;3,2;3,1];%此也为全封死情况,也没有路的 % %load('obstacle1.mat'); %画出网格线 PlotGrid(map); hold on; %画出障碍点 FillPlot(obstacle,'k'); path=AStar(obstacle,map)%A*算法 %画出路径 % if length(path)>=1 plot(path(:,1),path(:,2),'-c','LineWidth',5);hold on; end %}2、AStar.m核心代码function path=AStar(obstacle,map) %{ Astar算法思路 1.将起始点放在Openlist中 2.重复以下过程: 首先判断是否到达目标点,或无路径 >>如果终点已加入到Openlist中,则已找到路径(此时起始点就是目标点,无需再找) >>Openlist为空,无路径 a.按照Openlist中的第三列(代价函数F)进行排序,查找F值最小的节点 b.把这个F值最小的节点移到Closelist中作为 当前节点 c.对当前节点周围的8个相邻节点: >>如果它不可达,忽略它 >>如果它在Closelist中,忽略它 >>如果它不在Openlist中,加放Openlist,并把当前节点设置为它的父节点,记录该节点的F值 >>如果它已经在Openlist中,检查经当前节点到达那里是否更好(用G或F值判断), >如果更好,则将当前节点设置为其父节点,并更新F,G值;如果不好,则不作处理 3.保存路径 %} %用于存储路径 path=[]; %OpenList open=[]; %CloseList close=[]; %findFlag用于判断while循环是否结束 findFlag=false; %================1.将起始点放在Openlist中====================== %open变量每一行 [节点坐标,代价值F=G+H,代价值G,父节点坐标] open =[map.start(1), map.start(2) , 0+h(map.start,map.goal) , 0 , map.start(1) , map.start(2)]; %更新状态--下一步的八个点 next=MotionModel(); %=======================2.重复以下过程============================== while ~findFlag %--------------------首先判断是否达到目标点,或无路径----- if isempty(open(:,1)) disp('No path to goal!!'); return; end %判断目标点是否出现在open列表中 [isopenFlag,Id]=isopen(map.goal,open); if isopenFlag disp('Find Goal!!'); close = [open(Id,:);close] findFlag=true; break; end %------------------a.按照Openlist中的第三列(代价函数F)进行排序,查找F值最小的节点 [Y,I] = sort(open(:,3)); %对OpenList中第三列排序 open=open(I,:);%open中第一行节点是F值最小的 %------------------b.将F值最小的节点(即open中第一行节点),放到close第一行(close是不断积压的),作为当前节点 close = [open(1,:);close]; current = open(1,:); open(1,:)=[];%因为已经从open中移除了,所以第一列需要为空 %--------------------c.对当前节点周围的8个相邻节点,算法的主体:------------------------ for in=1:length(next(:,1)) %获得相邻节点的坐标,代价值F先等于0,代价值G先等于0 ,后面两个值是其父节点的坐标值,暂定为零(因为暂时还无法判断其父节点坐标是多少) m=[current(1,1)+next(in,1) , current(1,2)+next(in,2) , 0 , 0 , 0 ,0]; m(4)=current(1,4)+next(in,3); % m(4) 相邻节点G值 m(3)=m(4)+h(m(1:2),map.goal);% m(3) 相邻节点F值 %>>如果它不可达,忽略它,处理下一个相邻节点 (注意,obstacle这个数组中是包括边界的) if isObstacle(m,obstacle) continue; end %flag == 1:相邻节点 在Closelist中 targetInd = close中行号 %flag == 2:相邻节点不在Openlist中 targetInd = [] %flag == 3:相邻节点 在Openlist中 targetInd = open中行号 [flag,targetInd]=FindList(m,open,close); %>>如果它在Closelist中,忽略此相邻节点 if flag==1 continue; %>>如果它不在Openlist中,加入Openlist,并把当前节点设置为它的父节点 elseif flag==2 m(5:6)=[current(1,1),current(1,2)];%将当前节点作为其父节点 open = [open;m];%将此相邻节点加放openlist中 %>>剩下的情况就是它在Openlist中,检查由当前节点到相邻节点是否更好,如果更好则将当前节点设置为其父节点,并更新F,G值;否则不操作 else %由当前节点到达相邻节点更好(targetInd是此相邻节点在open中的行号 此行的第3列是代价函数F值) if m(3) < open(targetInd,3) %更好,则将此相邻节点的父节点设置为当前节点,否则不作处理 m(5:6)=[current(1,1),current(1,2)];%将当前节点作为其父节点 open(targetInd,:) = m;%将此相邻节点在Openlist中的数据更新 end end %下面的end是判断八个相邻节点的for循环的end end %=====绘制====== PlotGrid(map); hold on; pause(0.01); %绘制节点close和open节点 FillPlot(close,'r'); hold on; FillPlot(open,'g') hold on; end %追溯路径 path=GetPath(close,map.start);3、FindList.m检查给定节点是否open列表中 是否在close列表中function [flag,targetInd]=FindList(m,open,close) %{ 函数功能: 如果相邻节点(m存储其信息) 已经在Closelist中,则flag = 1 targetInd = 其所在close的行数,用来定位 如果相邻节点(m存储其信息) 不在Openlist 中,则flag = 2 targetInd = [] 如果相邻节点(m存储其信息) 已经在Openlist 中,则flag = 3 targetInd = 其所在open的行数,用来定位 %} %如果openlist为空,则一定不在openlist中 if isempty(open) flag = 2; targetInd = []; else %open不为空时,需要检查是否在openlist中 %遍历openlist,检查是否在openlist中 for io = 1:length(open(:,1)) if isequal( m(1:2) , open(io,1:2) ) %在Openlist中 flag = 3; targetInd = io; return; else %不在Openlist中 flag = 2; targetInd = []; end end end %如果能到这一步,说明: 一定不在Openlist中 那么需要判断是否在closelist中 %遍历Closelist(注意closelist不可能为空) for ic = 1:length(close(:,1)) if isequal( m(1:2) , close(ic,1:2) ) %在Closelist中 flag = 1; targetInd = ic; return;%在Closelist中直接return end end %{ 以下代码用于测试此函数的正确性: open = [ 1,1 ; 2,2; 3,3; 4,4; 5,5; 6,6; 7,7; 8,8; 9,9]; %还有一种情况:open列表为空 close = [1,2 ; 2,3; 3,4; 4,5; 5,6; 6,7; 7,8]; m1 = [5,6]; %在close中 此时flag应为1 targetInd 应为 5 m2 = [0,0]; %不在open中, 此时flag应为2 targetInd 应为空[] m3 = [3,3]; %在open中 此时flag应为3 targetInd 应为 3 [flag,targetInd] = FindList(m1,open,close) %flag = 1 targetInd = 5 [flag,targetInd] = FindList(m2,open,close) %flag = 2 targetInd = [] [flag,targetInd] = FindList(m3,open,close) %flag = 3 targetInd = 3 %} end4、GetBoundary.mfunction boundary=GetBoundary(map) %获得地图的边界的坐标 boundary=[]; for i1=0:(map.XYMAX+1) boundary=[boundary;[0 i1]]; end for i2=0:(map.XYMAX+1) boundary=[boundary;[i2 0]]; end for i3=0:(map.XYMAX+1) boundary=[boundary;[map.XYMAX+1 i3]]; end for i4=0:(map.XYMAX+1) boundary=[boundary;[i4 map.XYMAX+1]]; end end5、GetObstacle.mfunction obstacle=GetObstacle(nob,obstacle,map) %生成障碍点的坐标 ob=round(rand([nob,2])*map.XYMAX); %生成的障碍点有可能是和start点和goal点坐标重合的,需要删除,removeInd为重合点的数组索引index removeInd=[]; %遍历ob数组,检查哪些坐标与start和goal重合,并将其索引存在removeInd中 for io=1:length(ob(:,1)) if(isequal(ob(io,:),map.start) || isequal(ob(io,:),map.goal)) removeInd=[removeInd;io]; end end %将重复的节点置空,去掉 ob(removeInd,:)=[]; %将ob障碍点加入到obstacle中(obstacle中已经包括边界节点的坐标了,这里还要再加上内部障碍点的坐标) obstacle=[obstacle;ob];6、GetPath最后得到整个路径的坐标function path=GetPath(close,start) ind=1; path=[]; while 1 path=[path; close(ind,1:2)]; if isequal(close(ind,1:2),start) break; end for io=1:length(close(:,1)) if isequal(close(io,1:2),close(ind,5:6)) ind=io; break; end end end end7、h.m启发函数的代价值,这里采用的是曼哈顿距离function hcost = h( m,goal ) %计算启发函数代价值 ,这里采用曼哈顿算法 hcost =10* abs( m(1)-goal(1) )+10*abs( m(2)-goal(2) ); end8、isObstacle.m判断一个节点是否为障碍点(边界点也认为是障碍点)function flag = isObstacle( m,obstacle ) %判断节点m是否为障碍点,如果是就返为1,不是就返回0 for io=1:length(obstacle(:,1)) if isequal(obstacle(io,:),m(1:2)) flag=true; return; end end flag=false; end9、isopen.m判断一个节点是否在open列表中,感觉这个函数的功能和3中的FindList函数功能有些重复,但还是编了这个函数function [isopenFlag,Id] = isopen( node,open ) %判断节点是否在open列表中,在open中,isopenFlag = 1,不在open中,isopenFlag = 0 .并反回索引号 isopenFlag = 0; Id = 0; %如果open列表为空,则不在open列表中 if isempty(open) isopenFlag = 0; else %open列表不为空时 for i = 1:length( open(:,1) ) if isequal( node(1:2) , open(i,1:2) ) %在Openlist中 isopenFlag = 1; Id = i; return; end end end end10、MotionModel.m得到当前节点周边的八个相邻节点的坐标差值和移动距离function next = MotionModel() %当前节点 周围的八个相邻节点 与 当前节点的坐标差值(前两列) %当前节点 周围的八个相邻节点 与 当前节点的距离值(最后一列) next = [-1,1,14;... 0,1,10;... 1,1,14;... -1,0,10;... 1,0,10;... -1,-1,14;... 0,-1,10;... 1,-1,14]; end11、PlotGrid.m绘制function PlotGrid( map ) %PLOTGRID Summary of this function goes here % Detailed explanation goes here %绘制网格 for i = 1:map.XYMAX+3 line([-0.5,map.XYMAX+1.5],[i-1.5,i-1.5]); end for j = 1:map.XYMAX+3 line([j-1.5,j-1.5],[-0.5,map.XYMAX+1.5]); end hold on; plot(map.start(1),map.start(2),'og'); hold on; plot(map.goal(1),map.goal(2),'ob'); axis([-1.5,map.XYMAX+2.5,-1.5,map.XYMAX+2.5]); axis equal; end12、FillPlot.mfunction FillPlot(coord,color) %coord为给出的点的坐标,为 n by 2 的向量,第一列为点的x坐标,第二列为点的y坐标 %我们画出以这些点为中心,边长为1的填充正方形 color为颜色 如color = 'k'时,表示黑色 for i = 1:length(coord(:,1)) x = coord(i,1); y = coord(i,2); X = [x-0.5,x+0.5,x+0.5,x-0.5]; Y = [y-0.5,y-0.5,y+0.5,y+0.5]; fill(X,Y,color); hold on; end axis equal; end
2022年05月09日
442 阅读
0 评论
0 点赞
2022-05-01
Matlab 计算机视觉实验-UI
UI代码classdef app1 < matlab.apps.AppBase % Properties that correspond to app components properties (Access = public) UIFigure matlab.ui.Figure UIAxes2 matlab.ui.control.UIAxes UIAxes matlab.ui.control.UIAxes Panel matlab.ui.container.Panel Button matlab.ui.control.Button Button_3 matlab.ui.control.Button Button_2 matlab.ui.control.Button SobelButton matlab.ui.control.Button CannyButton matlab.ui.control.Button Button_4 matlab.ui.control.Button Button_5 matlab.ui.control.Button Button_6 matlab.ui.control.Button Button_7 matlab.ui.control.Button Button_8 matlab.ui.control.Button Button_9 matlab.ui.control.Button Button_10 matlab.ui.control.Button Button_12 matlab.ui.control.Button Button_13 matlab.ui.control.Button end properties (Access = private) end % Callbacks that handle component events methods (Access = private) % Button pushed function: Button function ButtonPushed(app, event) global I flie K [filename,filepath] = uigetfile({ '*.jpg';'*.bmp';'*.tif';'*.png';'*.jpeg'},'载入图像'); if isequal(filename,0)||isequal(filepath,0) errordlg('没有选中文件','出错'); return; else %file=[pathname,filename]; file=[filepath,filename]; I=fullfile(file); K=imread(file); imshow(K,'Parent',app.UIAxes2); end end % Button pushed function: Button_2 function Button_2Pushed(app, event) global I BW K %[x,map]=imread(K); %BW = rgb2gray([x,map]); BW = rgb2gray(K); %app.Image2.ImageSource=I1; imshow(BW,'Parent',app.UIAxes); end % Button pushed function: SobelButton function SobelButtonPushed(app, event) global I K %[x,map]=imread(I); %BW = rgb2gray([x,map]); BW = rgb2gray(K); BW1=edge(BW,'Sobel'); imshow(BW1,'Parent',app.UIAxes); end % Button pushed function: CannyButton function CannyButtonPushed(app, event) global K %[x,map]=imread(I); %BW = rgb2gray([x,map]); BW = rgb2gray(K); BW2=edge(BW,'Canny'); imshow(BW2,'Parent',app.UIAxes); end % Button pushed function: Button_3 function Button_3Pushed(app, event) global K noise1 noise1= imnoise(K,'salt & pepper'); imshow(noise1,'Parent',app.UIAxes); end % Button pushed function: Button_4 function Button_4Pushed(app, event) global K noise2 noise2= imnoise(K,'gaussian'); imshow(noise2,'Parent',app.UIAxes); end % Button pushed function: Button_5 function Button_5Pushed(app, event) global K faceDetector = vision.CascadeObjectDetector(); % 构造检测器对象。 facebox = step(faceDetector, K); % 开始检测,将结果存储到facebox变量中 finalImage = insertShape(K, 'Rectangle', facebox,'LineWidth',5); imshow(finalImage,'Parent',app.UIAxes); end % Button pushed function: Button_6 function Button_6Pushed(app, event) global vid faceDetector = vision.CascadeObjectDetector(); vid = videoinput('winvideo', 1, 'YUY2_640x480'); set(vid,'ReturnedColorSpace','rgb'); vidRes=get(vid,'VideoResolution'); width=vidRes(1); height=vidRes(2); nBands=get(vid,'NumberOfBands'); figure('Name', 'Matlab调用摄像头', 'NumberTitle', 'Off', 'ToolBar', 'None', 'MenuBar', 'None'); uicontrol('String', 'Close', 'Callback', 'close(gcf)'); hImage=image(zeros(vidRes(2),vidRes(1),nBands)); preview(vid,hImage); end % Button pushed function: Button_7 function Button_7Pushed(app, event) faceDetector = vision.CascadeObjectDetector(); %enable viola jones algorithm bbox = [100 100 100 100]; vidDevice = imaq.VideoDevice('winvideo',1,'YUY2_640x480','ROI', [1 1 640 480],'ReturnedColorSpace','rgb'); boxInserter = vision.ShapeInserter('BorderColor','Custom','CustomBorderColor',[0 255 0]); nFrame =300; vidInfo = imaqhwinfo(vidDevice); vidHeight = vidInfo.MaxHeight; vidWidth = vidInfo.MaxWidth; videoPlayer = vision.VideoPlayer('Position',[300 100 640+30 480+30]); for k = 1:nFrame % start recording with 300 frames tic; % timer start videoFrame = step(vidDevice); % enable the image capture by webcam bbox = 4 * faceDetector.step(imresize(videoFrame, 1/4)); % boost video's fps videoOut = step(boxInserter, videoFrame, bbox); % highlight the boxes of face at video %release(boxInserter); step(videoPlayer, videoOut); % display the video live in video player end end % Button pushed function: Button_8 function Button_8Pushed(app, event) global I K %[x,map]=imread(I); %ori_im = rgb2gray([x,map]); %ori_im = imread(I); %ori_im = rgb2gray(uint8(ori_im)); ori_im = rgb2gray(uint8(K)); % fx = [5 0 -5;8 0 -8;5 0 -5]; % 高斯函数一阶微分,x方向(用于改进的Harris角点提取算法) fx = [-2 -1 0 1 2]; % x方向梯度算子(用于Harris角点提取算法) Ix = filter2(fx,ori_im); % x方向滤波 % fy = [5 8 5;0 0 0;-5 -8 -5]; % 高斯函数一阶微分,y方向(用于改进的Harris角点提取算法) fy = [-2;-1;0;1;2]; % y方向梯度算子(用于Harris角点提取算法) Iy = filter2(fy,ori_im); % y方向滤波 Ix2 = Ix.^2; Iy2 = Iy.^2; Ixy = Ix.*Iy; clear Ix; clear Iy; h= fspecial('gaussian',[7 7],2); % 产生7*7的高斯窗函数,sigma=2 Ix2 = filter2(h,Ix2); Iy2 = filter2(h,Iy2); Ixy = filter2(h,Ixy); height = size(ori_im,1); width = size(ori_im,2); result = zeros(height,width); % 纪录角点位置,角点处值为1 R = zeros(height,width); for i = 1:height for j = 1:width M = [Ix2(i,j) Ixy(i,j);Ixy(i,j) Iy2(i,j)]; % auto correlation matrix R(i,j) = det(M)-0.06*(trace(M))^2; end end cnt = 0; for i = 2:height-1 for j = 2:width-1 % 进行非极大抑制,窗口大小3*3 if R(i,j) > R(i-1,j-1) && R(i,j) > R(i-1,j) && R(i,j) > R(i-1,j+1) && R(i,j) > R(i,j-1) && R(i,j) > R(i,j+1) && R(i,j) > R(i+1,j-1) && R(i,j) > R(i+1,j) && R(i,j) > R(i+1,j+1) result(i,j) = 1; cnt = cnt+1; end end end Rsort=zeros(cnt,1); [posr, posc] = find(result == 1); for i=1:cnt Rsort(i)=R(posr(i),posc(i)); end [Rsort,ix]=sort(Rsort,1); Rsort=flipud(Rsort); ix=flipud(ix); ps=100; posr2=zeros(ps,1); posc2=zeros(ps,1); for i=1:ps posr2(i)=posr(ix(i)); posc2(i)=posc(ix(i)); end imshow(ori_im,'Parent',app.UIAxes); hold (app.UIAxes,'on') plot(app.UIAxes,posc2,posr2,'g+'); toc; end % Button pushed function: Button_9 function Button_9Pushed(app, event) cameraCalibrator; end % Button pushed function: Button_10 function Button_10Pushed(app, event) global I K %moveImg=imread(I); moveImg=rgb2gray(K); [imagePoints,boardSize] = detectCheckerboardPoints(moveImg);%检测棋盘格角点 %figure(1) %imshow(moveImg); %hold on; %plot(imagePoints(:,1),imagePoints(:,2),'ro'); movingPoints=imagePoints; %hold off % fixedImg=imread('4.jpg'); % fixedImg=rgb2gray(fixedImg); [imagePoints_fixedImg,boardSize_fixedImg] = detectCheckerboardPoints(fixedImg); %figure(2) %imshow(fixedImg); %hold on; %plot(imagePoints_fixedImg(:,1),imagePoints_fixedImg(:,2),'ro'); %hold off tempPoints1=reshape(imagePoints_fixedImg(:,1),boardSize_fixedImg(1)-1,boardSize_fixedImg(2)-1); tempPoints2=reshape(imagePoints_fixedImg(:,2),boardSize_fixedImg(1)-1,boardSize_fixedImg(2)-1); fixedPoints1=tempPoints1(1:boardSize(1)-1,1:boardSize(2)-1); fixedPoints2=tempPoints2(1:boardSize(1)-1,1:boardSize(2)-1); fixedPoints=[fixedPoints1(:),fixedPoints2(:)]; mytform = cp2tform(movingPoints,fixedPoints, 'projective');%求出投影变化的矩阵 registered = imtransform(moveImg, mytform, 'bicubic');%进行变化 imshow(imadjust(registered),'Parent',app.UIAxes); end % Button pushed function: Button_12 function Button_12Pushed(app, event) global I K %[x,map]=imread(I); %BW = rgb2gray([x,map]); BW = rgb2gray(K); W = fspecial('gaussian',[5,5],1); G = imfilter(BW, W, 'replicate'); imshow(G,'Parent',app.UIAxes); end % Button pushed function: Button_13 function Button_13Pushed(app, event) global K video_obj = videoinput('winvideo', 1, 'YUY2_640x480'); set(video_obj,'ReturnedColorSpace','rgb'); videoRes = get(video_obj, 'VideoResolution'); nBands = get(video_obj, 'NumberOfBands'); K = getsnapshot(video_obj); imshow(K,'parent',app.UIAxes2); imwrite(K,'C:\Users\17709\Desktop\gui\paizhao.jpg') end end % Component initialization methods (Access = private) % Create UIFigure and components function createComponents(app) % Create UIFigure and hide until all components are created app.UIFigure = uifigure('Visible', 'off'); app.UIFigure.Position = [100 100 855 563]; app.UIFigure.Name = 'UI Figure'; % Create UIAxes2 app.UIAxes2 = uiaxes(app.UIFigure); title(app.UIAxes2, '原图') xlabel(app.UIAxes2, '') ylabel(app.UIAxes2, '') app.UIAxes2.FontUnits = 'points'; app.UIAxes2.FontSize = 9; app.UIAxes2.CLim = [0 1]; app.UIAxes2.XColor = 'none'; app.UIAxes2.YColor = 'none'; app.UIAxes2.TitleFontWeight = 'bold'; app.UIAxes2.Position = [31 294 377 270]; % Create UIAxes app.UIAxes = uiaxes(app.UIFigure); title(app.UIAxes, '处理后的图') xlabel(app.UIAxes, '') ylabel(app.UIAxes, '') app.UIAxes.AmbientLightColor = 'none'; app.UIAxes.MinorGridLineStyle = 'none'; app.UIAxes.GridColor = 'none'; app.UIAxes.MinorGridColor = 'none'; app.UIAxes.XColor = 'none'; app.UIAxes.YColor = 'none'; app.UIAxes.TitleFontWeight = 'bold'; app.UIAxes.BackgroundColor = [0.9412 0.9412 0.9412]; app.UIAxes.Position = [472 294 371 270]; % Create Panel app.Panel = uipanel(app.UIFigure); app.Panel.ForegroundColor = [1 0 0]; app.Panel.TitlePosition = 'centertop'; app.Panel.Title = '功能区'; app.Panel.BackgroundColor = [0.9412 0.9412 0.9412]; app.Panel.FontSize = 18; app.Panel.Position = [31 33 796 238]; % Create Button app.Button = uibutton(app.Panel, 'push'); app.Button.ButtonPushedFcn = createCallbackFcn(app, @ButtonPushed, true); app.Button.Position = [670 12 113 47]; app.Button.Text = '打开图片'; % Create Button_3 app.Button_3 = uibutton(app.Panel, 'push'); app.Button_3.ButtonPushedFcn = createCallbackFcn(app, @Button_3Pushed, true); app.Button_3.Position = [26 149 100 25]; app.Button_3.Text = '椒盐噪声'; % Create Button_2 app.Button_2 = uibutton(app.Panel, 'push'); app.Button_2.ButtonPushedFcn = createCallbackFcn(app, @Button_2Pushed, true); app.Button_2.Position = [195 149 100 25]; app.Button_2.Text = '灰度化'; % Create SobelButton app.SobelButton = uibutton(app.Panel, 'push'); app.SobelButton.ButtonPushedFcn = createCallbackFcn(app, @SobelButtonPushed, true); app.SobelButton.Position = [195 107 100 22]; app.SobelButton.Text = 'Sobel'; % Create CannyButton app.CannyButton = uibutton(app.Panel, 'push'); app.CannyButton.ButtonPushedFcn = createCallbackFcn(app, @CannyButtonPushed, true); app.CannyButton.Position = [195 58 100 22]; app.CannyButton.Text = 'Canny'; % Create Button_4 app.Button_4 = uibutton(app.Panel, 'push'); app.Button_4.ButtonPushedFcn = createCallbackFcn(app, @Button_4Pushed, true); app.Button_4.Position = [26 106 100 25]; app.Button_4.Text = '高斯噪声'; % Create Button_5 app.Button_5 = uibutton(app.Panel, 'push'); app.Button_5.ButtonPushedFcn = createCallbackFcn(app, @Button_5Pushed, true); app.Button_5.Position = [348 106 100 25]; app.Button_5.Text = '人脸检测'; % Create Button_6 app.Button_6 = uibutton(app.Panel, 'push'); app.Button_6.ButtonPushedFcn = createCallbackFcn(app, @Button_6Pushed, true); app.Button_6.Position = [499 105 100 26]; app.Button_6.Text = '摄像头预览'; % Create Button_7 app.Button_7 = uibutton(app.Panel, 'push'); app.Button_7.ButtonPushedFcn = createCallbackFcn(app, @Button_7Pushed, true); app.Button_7.Position = [499 57 100 25]; app.Button_7.Text = '摄像头人脸检测'; % Create Button_8 app.Button_8 = uibutton(app.Panel, 'push'); app.Button_8.ButtonPushedFcn = createCallbackFcn(app, @Button_8Pushed, true); app.Button_8.Position = [348 149 100 25]; app.Button_8.Text = '角点检测'; % Create Button_9 app.Button_9 = uibutton(app.Panel, 'push'); app.Button_9.ButtonPushedFcn = createCallbackFcn(app, @Button_9Pushed, true); app.Button_9.Position = [642 149 100 25]; app.Button_9.Text = '相机标定'; % Create Button_10 app.Button_10 = uibutton(app.Panel, 'push'); app.Button_10.ButtonPushedFcn = createCallbackFcn(app, @Button_10Pushed, true); app.Button_10.Position = [642 105 100 26]; app.Button_10.Text = '倾斜矫正'; % Create Button_12 app.Button_12 = uibutton(app.Panel, 'push'); app.Button_12.ButtonPushedFcn = createCallbackFcn(app, @Button_12Pushed, true); app.Button_12.Position = [26 56 100 26]; app.Button_12.Text = '高斯平滑滤波'; % Create Button_13 app.Button_13 = uibutton(app.Panel, 'push'); app.Button_13.ButtonPushedFcn = createCallbackFcn(app, @Button_13Pushed, true); app.Button_13.Position = [499 148 100 26]; app.Button_13.Text = '拍照'; % Show the figure after all components are created app.UIFigure.Visible = 'on'; end end % App creation and deletion methods (Access = public) % Construct app function app = app1 % Create UIFigure and components createComponents(app) % Register the app with App Designer registerApp(app, app.UIFigure) if nargout == 0 clear app end end % Code that executes before app deletion function delete(app) % Delete UIFigure when app is deleted delete(app.UIFigure) end end end
2022年05月01日
1,026 阅读
0 评论
0 点赞