Thread Subject: Simulink Video to GUI

Subject: Simulink Video to GUI

From: Jingwei

Date: 22 Nov, 2009 12:39:03

Message: 1 of 7

Hello,

is it possible to display the Video from a VideoViewer block in my Simulink model onto a GUI?

or do i have to convert it into the MATLAB workspace and covert it back using ActiveX or Axes? i have no idea. ):

the video should only play after the a button is pressed.

any help will be appreciated. :D

Many Thanks! (:

Subject: Simulink Video to GUI

From: Alec Rogers

Date: 24 Nov, 2009 20:59:27

Message: 2 of 7

Hi Jingwei,

If you wish to display individual video frames from Simulink in a MATLAB
figure, then you should save the data to the MATLAB workspace (as you
suggest).

In general, the Simulink video viewers are designed to output the data
as Simulink is running, so they don't store the data.

You can also use the To Multimedia File block to store data, which might
be a good idea if you have a large amount of video data (i.e. this would
  avoid storing all of the data in the MATLAB workspace).

Regards,
-alec


Jingwei wrote:
> Hello,
>
> is it possible to display the Video from a VideoViewer block in my Simulink model onto a GUI?
>
> or do i have to convert it into the MATLAB workspace and covert it back using ActiveX or Axes? i have no idea. ):
>
> the video should only play after the a button is pressed.
>
> any help will be appreciated. :D
>
> Many Thanks! (:

Subject: Simulink Video to GUI

From: Jingwei

Date: 25 Nov, 2009 11:58:05

Message: 3 of 7

Hi Alec!

Thanks for your response! (:

for the saving of data into the MATLAB workspace, is it still possible if the video output from SIMULINK is LIVE from a video device?

as you mentioned, its making use of the VIDEO-TO-WORKSPACE block in Simulink right? and writing codes in the GUI to read the data from the workspace display these back into video for the GUI?

do you mind pointing me in the right direction with some coding guides? :X

really appreciate it. many thanks! :D

Jingwei

Alec Rogers <alec.rogers@mathworks.com> wrote in message <hehhff$9hn$1@fred.mathworks.com>...
> Hi Jingwei,
>
> If you wish to display individual video frames from Simulink in a MATLAB
> figure, then you should save the data to the MATLAB workspace (as you
> suggest).
>
> In general, the Simulink video viewers are designed to output the data
> as Simulink is running, so they don't store the data.
>
> You can also use the To Multimedia File block to store data, which might
> be a good idea if you have a large amount of video data (i.e. this would
> avoid storing all of the data in the MATLAB workspace).
>
> Regards,
> -alec
>
>
> Jingwei wrote:
> > Hello,
> >
> > is it possible to display the Video from a VideoViewer block in my Simulink model onto a GUI?
> >
> > or do i have to convert it into the MATLAB workspace and covert it back using ActiveX or Axes? i have no idea. ):
> >
> > the video should only play after the a button is pressed.
> >
> > any help will be appreciated. :D
> >
> > Many Thanks! (:

Subject: Simulink Video to GUI

From: Alec Rogers

Date: 25 Nov, 2009 12:32:22

Message: 4 of 7

Hi Jingwei,

As far as saving data is concerned, it doesn't really matter what the
source of the data is, as long as an appropriate sink is connected.

And yes, the Video To Workspace block might work for your needs.

If you have not already, I would encourage you to look at the following
demos, and try replacing the video display blocks with the Video To
Workspace block:

http://www.mathworks.com/products/viprocessing/demos.html

Several examples using video from a device are found in the section
"Live Video Processing".

Regards,
-alec


Jingwei wrote:
> Hi Alec!
>
> Thanks for your response! (:
>
> for the saving of data into the MATLAB workspace, is it still possible if the video output from SIMULINK is LIVE from a video device?
>
> as you mentioned, its making use of the VIDEO-TO-WORKSPACE block in Simulink right? and writing codes in the GUI to read the data from the workspace display these back into video for the GUI?
>
> do you mind pointing me in the right direction with some coding guides? :X
>
> really appreciate it. many thanks! :D
>
> Jingwei
>
> Alec Rogers <alec.rogers@mathworks.com> wrote in message <hehhff$9hn$1@fred.mathworks.com>...
>> Hi Jingwei,
>>
>> If you wish to display individual video frames from Simulink in a MATLAB
>> figure, then you should save the data to the MATLAB workspace (as you
>> suggest).
>>
>> In general, the Simulink video viewers are designed to output the data
>> as Simulink is running, so they don't store the data.
>>
>> You can also use the To Multimedia File block to store data, which might
>> be a good idea if you have a large amount of video data (i.e. this would
>> avoid storing all of the data in the MATLAB workspace).
>>
>> Regards,
>> -alec
>>
>>
>> Jingwei wrote:
>>> Hello,
>>>
>>> is it possible to display the Video from a VideoViewer block in my Simulink model onto a GUI?
>>>
>>> or do i have to convert it into the MATLAB workspace and covert it back using ActiveX or Axes? i have no idea. ):
>>>
>>> the video should only play after the a button is pressed.
>>>
>>> any help will be appreciated. :D
>>>
>>> Many Thanks! (:

Subject: Simulink Video to GUI

From: Jingwei

Date: 25 Nov, 2009 13:17:17

Message: 5 of 7

Thanks again for the prompt reply! (:

yupps, i know how to do that,

the problem for me would be to attached the 'workspace video data' back into the GUI, maybe some sample codes or examples for the GUI .m file?

been stuck on this for quite some time. ):

Many Thanks! (:

Jingwei

Alec Rogers <alec.rogers@mathworks.com> wrote in message <hej84m$1i7$1@fred.mathworks.com>...
> Hi Jingwei,
>
> As far as saving data is concerned, it doesn't really matter what the
> source of the data is, as long as an appropriate sink is connected.
>
> And yes, the Video To Workspace block might work for your needs.
>
> If you have not already, I would encourage you to look at the following
> demos, and try replacing the video display blocks with the Video To
> Workspace block:
>
> http://www.mathworks.com/products/viprocessing/demos.html
>
> Several examples using video from a device are found in the section
> "Live Video Processing".
>
> Regards,
> -alec
>
>
> Jingwei wrote:
> > Hi Alec!
> >
> > Thanks for your response! (:
> >
> > for the saving of data into the MATLAB workspace, is it still possible if the video output from SIMULINK is LIVE from a video device?
> >
> > as you mentioned, its making use of the VIDEO-TO-WORKSPACE block in Simulink right? and writing codes in the GUI to read the data from the workspace display these back into video for the GUI?
> >
> > do you mind pointing me in the right direction with some coding guides? :X
> >
> > really appreciate it. many thanks! :D
> >
> > Jingwei
> >
> > Alec Rogers <alec.rogers@mathworks.com> wrote in message <hehhff$9hn$1@fred.mathworks.com>...
> >> Hi Jingwei,
> >>
> >> If you wish to display individual video frames from Simulink in a MATLAB
> >> figure, then you should save the data to the MATLAB workspace (as you
> >> suggest).
> >>
> >> In general, the Simulink video viewers are designed to output the data
> >> as Simulink is running, so they don't store the data.
> >>
> >> You can also use the To Multimedia File block to store data, which might
> >> be a good idea if you have a large amount of video data (i.e. this would
> >> avoid storing all of the data in the MATLAB workspace).
> >>
> >> Regards,
> >> -alec
> >>
> >>
> >> Jingwei wrote:
> >>> Hello,
> >>>
> >>> is it possible to display the Video from a VideoViewer block in my Simulink model onto a GUI?
> >>>
> >>> or do i have to convert it into the MATLAB workspace and covert it back using ActiveX or Axes? i have no idea. ):
> >>>
> >>> the video should only play after the a button is pressed.
> >>>
> >>> any help will be appreciated. :D
> >>>
> >>> Many Thanks! (:

Subject: Simulink Video to GUI

From: Alec Rogers

Date: 25 Nov, 2009 14:34:33

Message: 6 of 7

OK, so assuming that you have a variable containing video data in the
MATLAB workspace:

 >> whos vout
   Name Size Bytes Class Attributes
   vout 4-D 2304000 single

 >> size(vout)
ans =
    120 160 3 10


You can do one of several things to view it:

1) Use mplay
mplay(vout)

2) Use something more primitive
for i=1:10
     image(vout(:,:,:,i));
     drawnow;
end


There are more examples of this type in the documentation entitled
"Working with Images in MATLAB Graphics":

http://www.mathworks.com/access/helpdesk/help/techdoc/creating_plots/f2-145.html

Regards,
-alec


PS: I am assuming that you want to display the data from MATLAB. If you
are talking about getting the data back into same Simulink model, then
you probably don't want to use a sink block. Instead, you would just
use MATLAB code in User-Defined Function within Simulink (e.g. the Fcn,
MATLAB Fcn, or Embedded MATLAB Function blocks).


Jingwei wrote:
> Thanks again for the prompt reply! (:
>
> yupps, i know how to do that,
>
> the problem for me would be to attached the 'workspace video data' back into the GUI, maybe some sample codes or examples for the GUI .m file?
>
> been stuck on this for quite some time. ):
>
> Many Thanks! (:
>
> Jingwei
>
> Alec Rogers <alec.rogers@mathworks.com> wrote in message <hej84m$1i7$1@fred.mathworks.com>...
>> Hi Jingwei,
>>
>> As far as saving data is concerned, it doesn't really matter what the
>> source of the data is, as long as an appropriate sink is connected.
>>
>> And yes, the Video To Workspace block might work for your needs.
>>
>> If you have not already, I would encourage you to look at the following
>> demos, and try replacing the video display blocks with the Video To
>> Workspace block:
>>
>> http://www.mathworks.com/products/viprocessing/demos.html
>>
>> Several examples using video from a device are found in the section
>> "Live Video Processing".
>>
>> Regards,
>> -alec
>>
>>
>> Jingwei wrote:
>>> Hi Alec!
>>>
>>> Thanks for your response! (:
>>>
>>> for the saving of data into the MATLAB workspace, is it still possible if the video output from SIMULINK is LIVE from a video device?
>>>
>>> as you mentioned, its making use of the VIDEO-TO-WORKSPACE block in Simulink right? and writing codes in the GUI to read the data from the workspace display these back into video for the GUI?
>>>
>>> do you mind pointing me in the right direction with some coding guides? :X
>>>
>>> really appreciate it. many thanks! :D
>>>
>>> Jingwei
>>>
>>> Alec Rogers <alec.rogers@mathworks.com> wrote in message <hehhff$9hn$1@fred.mathworks.com>...
>>>> Hi Jingwei,
>>>>
>>>> If you wish to display individual video frames from Simulink in a MATLAB
>>>> figure, then you should save the data to the MATLAB workspace (as you
>>>> suggest).
>>>>
>>>> In general, the Simulink video viewers are designed to output the data
>>>> as Simulink is running, so they don't store the data.
>>>>
>>>> You can also use the To Multimedia File block to store data, which might
>>>> be a good idea if you have a large amount of video data (i.e. this would
>>>> avoid storing all of the data in the MATLAB workspace).
>>>>
>>>> Regards,
>>>> -alec
>>>>
>>>>
>>>> Jingwei wrote:
>>>>> Hello,
>>>>>
>>>>> is it possible to display the Video from a VideoViewer block in my Simulink model onto a GUI?
>>>>>
>>>>> or do i have to convert it into the MATLAB workspace and covert it back using ActiveX or Axes? i have no idea. ):
>>>>>
>>>>> the video should only play after the a button is pressed.
>>>>>
>>>>> any help will be appreciated. :D
>>>>>
>>>>> Many Thanks! (:

Subject: Simulink Video to GUI

From: Abdul

Date: 9 Jul, 2010 07:33:07

Message: 7 of 7

Hello every one.. i have a question also related to GUI.
I have a model in Simulink & i am running it through real time camera.. or u can say in that model i acquire video live from my web cam ok.
Now i want to make a GUI button what when i press it my model open (That i done already)
2) to Run that model from GUI bottom.. How can i run it??
3) Display live video results in GUI new Dialog box or window..??

Plz guide me with step 2 & 3.. thankx..
Regards
Abdul Wahab

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
simulink video ... rodolfo 4 Jan, 2012 03:30:46
simulink video ... Abdul 9 Jul, 2010 03:34:09
gui Jingwei 22 Nov, 2009 07:44:06
video viewer Jingwei 22 Nov, 2009 07:44:06
simulink Jingwei 22 Nov, 2009 07:44:05
rssFeed for this Thread

Contact us at files@mathworks.com