ERROR : The function 'pushbutton1_Callback' might be unused . AND any more

LINE 98 : The function 'pushbutton1_Callback' might be unused
LINE 114 : The function 'pushbutton2_Callback' might be unused
LINE 190 : The variable 'bbox' appears to change size on every loop iteration. Consider preallocation for speed
LINE 215 : The function 'pushbutton3_Callback' might be unused
function varargout = projek1(varargin)
% PROJEK1 MATLAB code for projek1.fig
% PROJEK1, by itself, creates a new PROJEK1 or raises the existing
% singleton*.
%
% H = PROJEK1 returns the handle to a new PROJEK1 or the handle to
% the existing singleton*.
%
% PROJEK1('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in PROJEK1.M with the given input arguments.
%
% PROJEK1('Property','Value',...) creates a new PROJEK1 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before projek1_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to projek1_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 projek1
% Last Modified by GUIDE v2.5 26-Mar-2020 14:25:50
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @projek1_OpeningFcn, ...
'gui_OutputFcn', @projek1_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before projek1 is made visible.
function projek1_OpeningFcn(hObject, ~, 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 projek1 (see VARARGIN)
% Choose default command line output for projek1
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
movegui(hObject, 'center');
clc
clear
% UIWAIT makes projek1 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = projek1_OutputFcn(~, ~, handles)
% varargout cell array for returning output args (see VARARGOUT);
% 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 structure
varargout{1} = handles.output;
reqToolboxes = {'Computer Vision System Toolbox', 'image Processing Toolbox'};
info = ver;
s=size(info);
flg = zeros(size(reqToolboxes));
reqSize = size(reqToolboxes,2);
for i=1:s(2)
for j=1:reqSize
if( strcmpi(info(1,i).Name,reqToolboxes{1,j}) )
flg(1,j)=1;
end
end
end
ret = prod(flg);
if ~ret
error('detectFaceParts requires: Computer Vision System Toolbox and Image Processing Toolbox. Please install these toolboxes.');
end
% --- Executes on button press in pushbutton1.
LINE 98 : function pushbutton1_Callback(hObject, ~, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[filename,pathname]=uigetfile('*.*');
if ~isequal(filename,0)
handles.data1 = imread(fullfile(pathname,filename));
guidata(hObject,handles);
axes(handles.axes1)
cla reset
imshow(handles.data1);
else
return
end
% --- Executes on button press in pushbutton2.
LINE 114 : function pushbutton2_Callback(~, ~, 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)
tic
X = handles.data1;
thresholdFace = 1;
thresholdParts = 1;
stdsize = 176;
nameDetector = {'LeftEye'; 'RightEye'; 'Mouth'; 'Nose'; };
mins = [[12 18]; [12 18]; [15 25]; [15 18]; ];
detector.stdsize = stdsize;
detector.detector = cell(5,1);
for k=1:4
minSize = int32([stdsize/5 stdsize/5]);
minSize = [max(minSize(1),mins(k,1)), max(minSize(2),mins(k,2))];
detector.detector{k} = vision.CascadeObjectDetector(char(nameDetector(k)), 'MergeThreshold', thresholdParts, 'MinSize', minSize);
end
detector.detector{5} = vision.CascadeObjectDetector('FrontalFaceCART', 'MergeThreshold', thresholdFace);
%%%%%%%%%%%%%%%%%%%%%%% detect face %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Detect faces
bbox = step(detector.detector{5}, X);
bbsize = size(bbox);
partsNum = zeros(size(bbox,1),1);
%%%%%%%%%%%%%%%%%%%%%%% detect parts %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
stdsize = detector.stdsize;
for k=1:4
if( k == 1 )
region = [1,int32(stdsize*2/3); 1, int32(stdsize*2/3)];
elseif( k == 2 )
region = [int32(stdsize/3),stdsize; 1, int32(stdsize*2/3)];
elseif( k == 3 )
region = [1,stdsize; int32(stdsize/3), stdsize];
elseif( k == 4 )
region = [int32(stdsize/5),int32(stdsize*4/5); int32(stdsize/3),stdsize];
else
region = [1,stdsize;1,stdsize];
end
bb = zeros(bbsize);
for i=1:size(bbox,1)
XX = X(bbox(i,2):bbox(i,2)+bbox(i,4)-1,bbox(i,1):bbox(i,1)+bbox(i,3)-1,:);
XX = imresize(XX,[stdsize, stdsize]);
XX = XX(region(2,1):region(2,2),region(1,1):region(1,2),:);
b = step(detector.detector{k},XX);
if( size(b,1) > 0 )
partsNum(i) = partsNum(i) + 1;
if( k == 1 )
b = sortrows(b,1);
elseif( k == 2 )
b = flipud(sortrows(b,1));
elseif( k == 3 )
b = flipud(sortrows(b,2));
elseif( k == 4 )
b = flipud(sortrows(b,3));
end
ratio = double(bbox(i,3)) / double(stdsize);
b(1,1) = int32( ( b(1,1)-1 + region(1,1)-1 ) * ratio + 0.5 ) + bbox(i,1);
b(1,2) = int32( ( b(1,2)-1 + region(2,1)-1 ) * ratio + 0.5 ) + bbox(i,2);
b(1,3) = int32( b(1,3) * ratio + 0.5 );
b(1,4) = int32( b(1,4) * ratio + 0.5 );
bb(i,:) = b(1,:);
end
end
LINE 190 : bbox = [bbox,bb];
end
%%%%%%%%%%%%%%%%%%%%%%% draw faces %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
bbox = [bbox,partsNum];
bbox(partsNum<=2,:)=[];
face = bbox(:,1: 4);
axes(handles.axes2)
cla reset
imshow(X);
hold on
[m, ~] = size(face);
for j = 1:m
rectangle('Position',[face(j,1),face(j,2),face(j,3),face(j,4)],'EdgeColor','y','LineWidth',2);
end
hold off
toc
% for k = 1:m
% imcrop(X,[face(k,1),face(k,2),face(k,3),face(k,4)]);
% end
% --- Executes on button press in pushbutton3.
LINE 215 : function pushbutton3_Callback(~, ~, ~)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
img = getframe(gca);
[filename2,pathname2] = uiputfile(...
{'*.bmp','bitmap image (*.bmp)';
'*.jpg','jpeg image(*.bmp)';
'*.*','All file(*.*)'},...
'Save Image');
if ~isequal(filename2,0)
imwrite(img.cdata,fullfile(pathname2,filename2));
else
return
end

 採用された回答

Rik
Rik 2020 年 5 月 5 日
編集済み: Rik 2020 年 5 月 5 日

1 投票

These are not errors, they are warnings given by mlint.
Because the reference to these functions is hidden away in the .fig file, mlint can't see if those functions are called anywhere. It warns you about this, because you might have a typo somewhere, or because maybe you can remove the unnecessary function from your file.
In this case all issues are due to the way GUIDE works. You don't need to remove those functions. If you want to learn about better GUI design, have a look here.

11 件のコメント

Fauzan Alghifari
Fauzan Alghifari 2020 年 5 月 6 日
i dont undrestand sir. please fixed my code
Walter Roberson
Walter Roberson 2020 年 5 月 6 日
click on the first line mentioned, line 98. Now Right click and select "Suppress this message in this file"
This will turn the warning off.
Rik
Rik 2020 年 5 月 6 日
編集済み: Rik 2020 年 5 月 6 日
There is nothing to be fixed. There are no errors, only warnings. If you do have error, attach the .m and .fig files.
Walter Roberson
Walter Roberson 2020 年 5 月 6 日
These are not error messages. You will get these messages in nearly all gui created with guide. They are normal for guide and do not indicate any problems.
MATLAB gives you the warning because it cannot see any calls to those routines. The calls probably do exist, but guide makes them in a strange way that MATLAB cannot detect just looking at the code.
Walter Roberson
Walter Roberson 2020 年 5 月 6 日
編集済み: Walter Roberson 2020 年 5 月 6 日
Suppose that you had
function father()
tell('mother', 'tell("Fauza", "come to eat")')
function tell(who, what)
feval(who, what)
function mother(what)
eval(what)
function fauzon(what)
disp(what)
Now, matlab asks "Is function fauzan used?". There are no direct calls to it. There are not even hidden direct calls to it. There is only data that would have to be modeled through several steps to make sure that fauzan() is called. Unless you have really good software modeling the only way to be sure that it is called is to execute the program.
MATLAB does not attempt to examine data and figure out the consequences the data being exactly what it is in order to determine whether a function is called. MATLAB just looks for obvious calls, and warns you if there are no obvious calls to a function. That does not mean that the function is definitely unused, just that it is not OBVIOUS to matlab that the function is used.
Fauzan Alghifari
Fauzan Alghifari 2020 年 5 月 6 日
it is file sir. help me . i dont undrestand sir
Rik
Rik 2020 年 5 月 6 日
What is your problem with this? Why do you think something is wrong?
Fauzan Alghifari
Fauzan Alghifari 2020 年 5 月 6 日
i dont run this program
Walter Roberson
Walter Roberson 2020 年 5 月 6 日
Change line 98 from
function pushbutton1_Callback(hObject, ~, handles)
to
function pushbutton1_Callback(hObject, ~, handles) %#ok<*DEFNU>
Fauzan Alghifari
Fauzan Alghifari 2020 年 5 月 8 日
line 190 please sir
Walter Roberson
Walter Roberson 2020 年 5 月 8 日
I knew you would encounter that, and I knew that you would not understand that it is only a warning, and I knew you would not know how to solve it. Sigh.
Your version also has a bug when there are no faces detected in a given image.
function varargout = projek1(varargin)
% PROJEK1 MATLAB code for projek1.fig
% PROJEK1, by itself, creates a new PROJEK1 or raises the existing
% singleton*.
%
% H = PROJEK1 returns the handle to a new PROJEK1 or the handle to
% the existing singleton*.
%
% PROJEK1('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in PROJEK1.M with the given input arguments.
%
% PROJEK1('Property','Value',...) creates a new PROJEK1 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before projek1_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to projek1_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 projek1
% Last Modified by GUIDE v2.5 26-Mar-2020 14:25:50
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @projek1_OpeningFcn, ...
'gui_OutputFcn', @projek1_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before projek1 is made visible.
function projek1_OpeningFcn(hObject, ~, 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 projek1 (see VARARGIN)
% Choose default command line output for projek1
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
movegui(hObject, 'center');
clc
clear
% UIWAIT makes projek1 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = projek1_OutputFcn(~, ~, handles)
% varargout cell array for returning output args (see VARARGOUT);
% 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 structure
varargout{1} = handles.output;
reqToolboxes = {{'Computer Vision System Toolbox', 'Computer Vision Toolbox'}, 'image Processing Toolbox'};
info = ver;
s=size(info);
flg = zeros(size(reqToolboxes));
reqSize = size(reqToolboxes,2);
for i=1:s(2)
for j=1:reqSize
if any( strcmpi(info(1,i).Name,reqToolboxes{1,j}) )
flg(1,j)=1;
end
end
end
ret = prod(flg);
if ~ret
error('detectFaceParts requires: Computer Vision System Toolbox and Image Processing Toolbox. Please install these toolboxes.');
end
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, ~, handles) %#ok<*DEFNU>
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[filename,pathname]=uigetfile('*.*');
if ~isequal(filename,0)
handles.data1 = imread(fullfile(pathname,filename));
guidata(hObject,handles);
axes(handles.axes1)
cla reset
imshow(handles.data1);
else
return
end
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(~, ~, 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)
tic
X = handles.data1;
thresholdFace = 1;
thresholdParts = 1;
stdsize = 176;
nameDetector = {'LeftEye'; 'RightEye'; 'Mouth'; 'Nose'; };
mins = [[12 18]; [12 18]; [15 25]; [15 18]; ];
detector.stdsize = stdsize;
detector.detector = cell(5,1);
for k=1:4
minSize = int32([stdsize/5 stdsize/5]);
minSize = [max(minSize(1),mins(k,1)), max(minSize(2),mins(k,2))];
detector.detector{k} = vision.CascadeObjectDetector(char(nameDetector(k)), 'MergeThreshold', thresholdParts, 'MinSize', minSize);
end
detector.detector{5} = vision.CascadeObjectDetector('FrontalFaceCART', 'MergeThreshold', thresholdFace);
%%%%%%%%%%%%%%%%%%%%%%% detect face %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Detect faces
bbox = step(detector.detector{5}, X);
bbsize = size(bbox);
partsNum = zeros(size(bbox,1),1);
%%%%%%%%%%%%%%%%%%%%%%% detect parts %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
stdsize = detector.stdsize;
newbbox = zeros([5 bbsize]);
newbbox(1,:,:) = bbox;
for k=1:4
if( k == 1 )
region = [1,int32(stdsize*2/3); 1, int32(stdsize*2/3)];
elseif( k == 2 )
region = [int32(stdsize/3),stdsize; 1, int32(stdsize*2/3)];
elseif( k == 3 )
region = [1,stdsize; int32(stdsize/3), stdsize];
elseif( k == 4 )
region = [int32(stdsize/5),int32(stdsize*4/5); int32(stdsize/3),stdsize];
else
region = [1,stdsize;1,stdsize];
end
bb = zeros(bbsize);
for i=1:size(bbox,1)
XX = X(bbox(i,2):bbox(i,2)+bbox(i,4)-1,bbox(i,1):bbox(i,1)+bbox(i,3)-1,:);
XX = imresize(XX,[stdsize, stdsize]);
XX = XX(region(2,1):region(2,2),region(1,1):region(1,2),:);
b = step(detector.detector{k},XX);
if( size(b,1) > 0 )
partsNum(i) = partsNum(i) + 1;
if( k == 1 )
b = sortrows(b,1);
elseif( k == 2 )
b = flipud(sortrows(b,1));
elseif( k == 3 )
b = flipud(sortrows(b,2));
elseif( k == 4 )
b = flipud(sortrows(b,3));
end
ratio = double(bbox(i,3)) / double(stdsize);
b(1,1) = int32( ( b(1,1)-1 + region(1,1)-1 ) * ratio + 0.5 ) + bbox(i,1);
b(1,2) = int32( ( b(1,2)-1 + region(2,1)-1 ) * ratio + 0.5 ) + bbox(i,2);
b(1,3) = int32( b(1,3) * ratio + 0.5 );
b(1,4) = int32( b(1,4) * ratio + 0.5 );
bb(i,:) = b(1,:);
end
end
newbbox(k+1,:,:) = bb;
end
bbox = reshape(newbbox, size(newbbox,1)*size(newbbox,2), size(newbbox,3));
%%%%%%%%%%%%%%%%%%%%%%% draw faces %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
bbox = [bbox,partsNum];
bbox(partsNum<=2,:)=[];
face = bbox(:,1: 4);
axes(handles.axes2)
cla reset
imshow(X);
hold on
[m, ~] = size(face);
for j = 1:m
rectangle('Position',[face(j,1),face(j,2),face(j,3),face(j,4)],'EdgeColor','y','LineWidth',2);
end
hold off
toc
% for k = 1:m
% imcrop(X,[face(k,1),face(k,2),face(k,3),face(k,4)]);
% end
% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(~, ~, ~)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
img = getframe(gca);
[filename2,pathname2] = uiputfile(...
{'*.bmp','bitmap image (*.bmp)';
'*.jpg','jpeg image(*.bmp)';
'*.*','All file(*.*)'},...
'Save Image');
if ~isequal(filename2,0)
imwrite(img.cdata,fullfile(pathname2,filename2));
else
return
end

サインインしてコメントする。

その他の回答 (1 件)

Fauzan Alghifari
Fauzan Alghifari 2020 年 5 月 6 日

0 投票

Unable to resolve the name vision.CascadeObjectDetector.
Error in projek1>pushbutton2_Callback (line 132)
detector.detector{k} = vision.CascadeObjectDetector(char(nameDetector(k)), 'MergeThreshold', thresholdParts, 'MinSize', minSize);
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in projek1 (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)projek1('pushbutton2_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback.

4 件のコメント

Walter Roberson
Walter Roberson 2020 年 5 月 6 日
You need Computer Vision Toolbox, R2012a or later.
There is little hope of getting that code working withotu Computer Vision Toolbox.
Fauzan Alghifari
Fauzan Alghifari 2020 年 5 月 6 日
I download file or no ?
Fauzan Alghifari
Fauzan Alghifari 2020 年 5 月 11 日
Thanks bro its work

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeIntroduction to Installation and Licensing についてさらに検索

製品

リリース

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by