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 次查看(过去 30 天)
显示 更早的评论
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 个评论
matt dash
2014-12-13
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.
采纳的回答
Image Analyst
2014-12-13
编辑:Image Analyst
2014-12-13
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);
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Migrate GUIDE Apps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!