0

I am using a GUI (called MainVidGUI, using GUIDE, the OpeningFcn is the basic one created by GUIDE) which has axes (called hcam), and by pressing a button (called Acquisition), I want to modify a frame from a live video stream and show the modified frame on the axes.

Currently the code looks like this:

Button callback function:

function Acquisition_Callback(hObject, eventdata, handles)
  global DevAdapt DevID DevFormat
  vid=videoinput(DevAdapt,DevID,DevFormat);
  vid.ReturnedColorspace = 'grayscale';
  set(vid,'TimerPeriod',0.1);
  triggerconfig(vid,'manual');
  set(vid,'FramesPerTrigger',1);
  set(vid,'TriggerRepeat',1000);
  start(vid);
  set(vid,'TimerFcn',{@lane_detection,handles});

Timer callback function:

function lane_detection(vid, event, handles)
   trigger(vid);
   previewframe = getdata(vid,1);
   %code here that modifies the previewframe a little bit
   set(MainVidGUI,'CurrentAxes',handles.hcam);
   imshow(previewframe)

When the acquisition button is pressed the timer is enabled and the images are modified, however they are presented at a new Figure 1 window instead of the GUI axes. Is there any way to fix this?

1 Answers1

0

Read the help for the imshow function. Specify the axes you want to draw on for the 'Parent' property in the call to imshow.

wakjah
  • 4,541
  • 1
  • 18
  • 23