Problem with "drawnow" function and axes - GUI MATLAB

I developed an interface (GUI), containing 2 axes. Each axes is assiociated with a "pushbutton" called "StartCam". What basicilly happens is that when pushbutton is called, the following call-back function is called:
function StartCam1_Callback(hObject, eventdata, handles)
url = 'http://192.168.1.2:80/jpg/image.jpg?timestamp=';
ss = imread(url);
fh = image(ss);
while(1)
ss = imread(url);
set(fh,'CData',ss);
axes(handles.axes1);
drawnow;
end
% --- Executes on button press in StartCam2.
function StartCam2_Callback(hObject, eventdata, handles)
url = 'http://192.168.1.3:80/jpg/image.jpg?timestamp=';
ss = imread(url);
fh = image(ss);
while(1)
ss = imread(url);
set(fh,'CData',ss);
axes(handles.axes2);
drawnow;
end
Two IP cameras with Two url's as shown above in the code, the problem is when the I run the GUI, I cant get to stream cam1 on axes1 and cam2 on axes2.
I thought using axes(handles.axes1); before drawnow is supposed to draw the stream on axes2 but it gives back an error.
So,How can I draw each stream on its individual axes ?? Thanks % code end

2 Comments

What error? Please post the full error message.
Actually, there isnt an error, both pushbuttons work fine, but all on the same axes, instead of "StartCam1"--> "Axes1" and "StartCam2" -- >"Axes2", they both draw on Axes1. Sorry for the mix up

Sign in to comment.

Answers (1)

Try
fh = imshow(ss, 'Parent', handles.axes1); % or axes 2 depending on which you want.

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Asked:

on 12 Jun 2013

Community Treasure Hunt

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

Start Hunting!