live video handles is run in other axes when doing process of image

  • Follow


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')
0
Reply Mohammad 3/27/2011 6:39:04 PM

I don't understand why you're using subplot.  It looks like you're
using GUIDE.  If so, you don't use subplot, you just place one of more
axes on your form and switch to them with the axes command before you
do anything like call imshow().

axes(handles.axesImage1);
% Display image in axesImage1.
imshow(rgbImage);

axes(handles.axesImage2);
% Display image in axesImage2.
imshow(binaryImage);
0
Reply ImageAnalyst 3/27/2011 6:46:16 PM


ImageAnalyst <imageanalyst@mailinator.com> wrote in message <91896af0-4b72-4893-8b10-38b3baff96f3@n2g2000prj.googlegroups.com>...
> I don't understand why you're using subplot.  It looks like you're
> using GUIDE.  If so, you don't use subplot, you just place one of more
> axes on your form and switch to them with the axes command before you
> do anything like call imshow().
> 
> axes(handles.axesImage1);
> % Display image in axesImage1.
> imshow(rgbImage);
> 
> axes(handles.axesImage2);
> % Display image in axesImage2.
> imshow(binaryImage);

Thanks for your response, i have make 2 new axes, and set the handles, but the problem still the same, when i press the 'Process' button, the live video run in axesImage2. The binary image not shown in axesImage2. 
If i stop the live video, then i press the 'Process' button again, the image of rgb and binary show in correct axes. 

Errors in command window:
??? Error using ==> waitfor
Error while evaluating uicontrol Callback

??? 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.

Are the problem relate to  funtion 'GETSNAPSHOT' and 'TimerFcn' ?
 
0
Reply Mohammad 3/28/2011 2:33:04 AM

I don't know.  Somehow, somewhere you're not setting the current axes
to the right one, either by passing in the axes handle as an input
argument to some function or by using the axes() function.  Plus
you're adding confusion to the issue by talking about GETSNAPSHOT,
waitfor, subplot, and the timer.  I suggest you call the Mathworks and
have them walk you through it over the phone.
0
Reply ImageAnalyst 3/28/2011 3:39:11 AM

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <30426291-cacf-4246-982b-23cdb7ba2d1f@k3g2000prl.googlegroups.com>...
> I don't know.  Somehow, somewhere you're not setting the current axes
> to the right one, either by passing in the axes handle as an input
> argument to some function or by using the axes() function.  Plus
> you're adding confusion to the issue by talking about GETSNAPSHOT,
> waitfor, subplot, and the timer.  I suggest you call the Mathworks and
> have them walk you through it over the phone.

axes(handles.axesrgb);
% Display image in axesImage1.
imshow(RGB), title('Original image');

axes(handles.axesbinary);
% Display image in axesImage2.
imshow(b), title('Binary image');

i really setting the axes on the right one. same error occur. 

Thanks for your advice and suggestion. 
maybe i have to check the coding again. 
0
Reply Mohammad 3/28/2011 7:34:04 AM

4 Replies
575 Views

(page loaded in 0.134 seconds)

Similiar Articles:













7/24/2012 1:50:24 AM


Reply: