Im making a gui for motion detection program .This is where im finding difficulty.I want display the result in edit box of gui but im getting an error "Error while evaluating uicontrol Callback". Can anyone tell me how to solve it ? ?
1 view (last 30 days)
Show older comments
function untitled13_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
guidata(hObject, handles);
function varargout = untitled13_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
function pushbutton1_Callback(hObject, eventdata, handles)
vid = videoinput('winvideo', '2','YUY2_640x480');
set(vid, 'ReturnedColorSpace', 'RGB');
start(vid)
preview(vid)
img = getsnapshot(vid);
pause(2)
img1 = getsnapshot(vid);
img12 = rgb2gray(img1);
img13 = rgb2gray(img);
dif =sum(sum(img12 - img13));
disp (dif)
set(handles.edit1,'string',num2str(dif));
function edit1_Callback(hObject, eventdata, handles)
function edit1_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
when i run this i get an error Error while evaluating uicontrol Callback
1 Comment
matt dash
on 13 Dec 2014
When you need help with an error, post the entire red error message, which explains where in your code the error occurs. This helps readers more easily identify what went wrong.
Accepted Answer
Image Analyst
on 13 Dec 2014
Edited: Image Analyst
on 13 Dec 2014
Well like Matt says, it's not clear because you didn't include the entire error message. But I can see some things wrong right off the bat. You're not subtracting correctly. The images need to be converted to double or you'll only find pixels where img12 is brighter than img13.
%dif =sum(sum(img12 - img13)); % NO!
%disp (dif) % Also No. Don't print to the command line!
meanDifferenceImage = abs(double(img12) - double(img13));
meanDifference = mean(meanDifference(:))
str = sprintf('The mean difference = %.2f gray levels.', meanDifference);
set(handles.edit1,'string', str);
6 Comments
More Answers (0)
See Also
Categories
Find more on Migrate GUIDE Apps in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!