i am final year student and doing FYP on Egg's grading and dirt inspection using Image Processing Technique . After do an image segmentation, i need to calculate the area for grade and calculate pixel of dirt on egg, i have build GUI, my problem 1st is:
1. The live video handles is run in other axes,
-Press 'start' button, the cam of live video run.
-then Press 'capture' button to capture image on live video.
-after that, Press 'Process" button, to do egg segmentation. Using subplot, i want to show original image that capture before and binary image, the problem occur in this step, the binary image in subplot axes is not display, but the live video are run in subplot axes of binary image. In video that handles axes show the same original image that capture before.
-Last, Press 'Stop' button to stop the live video.
Error that written in command window:
??? Error using ==> imaqdevice.getsnapshot at 65
A timeout occurred during GETSNAPSHOT.
Warning: The TimerFcn callback is being disabled.
To enable the callback, set the TimerFcn property.
so, i attach the code for my GUI please help me out.. suggest me any solution asap.. i will be thankful to you..
% --- Executes just before FYP1 is made visible.
function FYP1_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 FYP1 (see VARARGIN)
% Choose default command line output for FYP1
handles.output = hObject;
% Putting the object into manual trigger mode and then
% starting the object will make GETSNAPSHOT return faster
% since the connection to the camera will already have
% been established.
handles.video = videoinput('winvideo', 1, 'RGB24_640x480');
set(handles.video,'TimerPeriod', 0.02, ...
'TimerFcn',['if(~isempty(gco)),'...
'handles=guidata(gcf);'... % Update handles
'image(getsnapshot(handles.video));'... % Get picture using GETSNAPSHOT and put it into axes using IMAGE
'set(handles.cameraAxes,''ytick'',[],''xtick'',[]),'... % Remove tickmarks and labels that are inserted when using IMAGE
'else '...
'delete(imaqfind);'... % Clean up - delete any image acquisition objects
'end']);
handles.video.FrameGrabInterval = 5;
triggerconfig(handles.video,'manual');
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes myCameraGUI wait for user response (see UIRESUME)
uiwait(handles.FYP1);
% --- Outputs from this function are returned to the command line.
function varargout = FYP1_OutputFcn(hObject, eventdata, 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
handles.output = hObject;
varargout{1} = handles.output;
% --- Executes on button press in startStopCamera.
function startStopCamera_Callback(hObject, eventdata, handles)
% Start/Stop Camera
if strcmp(get(handles.startStopCamera,'String'),'Start Camera')
% Camera is off. Change button string and start camera.
set(handles.startStopCamera,'String','Stop Camera')
start(handles.video)
else
% Camera is on. Stop camera and change button string.
set(handles.startStopCamera,'String','Start Camera')
stop(handles.video)
end
% --- Executes on button press in SnapAndSave.
function SnapAndSave_Callback(hObject, eventdata, handles)
%capturing an image and Save tu current location
snappedImage = getsnapshot(handles.video);
image(snappedImage);
str=sprintf('egg%d.jpg',1);
imwrite(snappedImage,str,'jpg');
% --- Executes on button press in ProcessImage.
function ProcessImage_Callback(hObject, eventdata, handles)
global b
global bw
%Read image in specific folder
RGB = imread ('egg1.jpg');
%Convert RGB to Grayscale
I = rgb2gray(RGB);
MF = medfilt2(I,[3 3]);
%Threshold the Image,A binary version of the image
%A=imcrop(MF);
%imwrite(A, 'Crop.png');
%B=imread('Crop.png');
level = graythresh(MF);
bw = im2bw(MF,level);
bw = bwareaopen(bw, 50);
b = medfilt2(bw,[3 3]);
subplot(2,3,3),
imshow(RGB)
title('Original image')
subplot(2,3,2),
imshow(b)
title('Binary image')
|