From: Samuel Dorrell on
"Kostas " <kosotiro(a)yahoo.gr> wrote in message <hsjf0f$8rs$1(a)fred.mathworks.com>...
> "Kostas " <kosotiro(a)yahoo.gr> wrote in message <hsh7d6$r74$1(a)fred.mathworks.com>...
> > Alec Rogers <alec.rogers(a)mathworks.com> wrote in message <hk98o2$glu$1(a)fred.mathworks.com>...
> > >
> > > Hi Muhammad,
> > >
> > > Using the EML block, you could use code similar to the following:
> > >
> > > function fcn(u)
> > > %#eml
> > > eml.extrinsic('image');
> > > persistent h;
> > >
> > > if isempty(h)
> > > h = image(u);
> > > else
> > > set(h, 'CData', u);
> > > drawnow;
> > > end
> > >
> > > There is a lot of good information about using that block (and other
> > > user-defined Simulink blocks) in the documentation. In order to display
> > > the image in the correct axes, you'll want to consult the documentation
> > > pertaining to Handle Graphics.
> > >
> > > Regards,
> > > -alec
> > >
> > >
> > > Muhammad Hafizuddin wrote:
> > > > Hai Alec...
> > > > Thanks for reply...
> > > >
> > > > i'm not familiar with S-function in matlab... can u explain me in
> > > > detail? or can u provide any page/website for my reference?... look at
> > > > ur coding, is it we replace To Video Display with another Function
> > > > block? or just add that coding under GUI?
> > > >
> > > > Thanks..
> > > >
> > > > Alec Rogers <alec.rogers(a)mathworks.com> wrote in message
> > > > <hk710q$1vr$1(a)fred.mathworks.com>...
> > > >> Hi Muhammad,
> > > >>
> > > >> There is no way to embed a To Video Display block in another GUI.
> > > >>
> > > >> Your best bet would be to write your own S-function (e.g. use the Fcn
> > > >> block) to update the cdata of the image in your GUI:
> > > >>
> > > >> h = image(255*rand(100));
> > > >>
> > > >> Then, at each time step:
> > > >>
> > > >> set(h, 'CData', 255*rand(100))
> > > >>
> > > >> Regards,
> > > >> -alec
> > > >>
> > > >> Muhammad Hafizuddin wrote:
> > > >> > Hai..
> > > >> > i have some problem during handle the To Video Display blocks. That
> > > >> > problems is how to insert video from To Video Display into my
> > > >> customs > GUI. For your references i attach this link that contain
> > > >> picture about > this...
> > > >> > > http://www.haffiezz.com/matlab/Capture.JPG
> > > >> > > this is my final project and i hope those read this msg and known
> > > >> that > solution can help me...
> >
> > Hi Alec,
> > And if we want to send the video to a specific GUI at a specific position?
>
> I mean that I have already constructed a GUI that communicates with a simulink model and changes its parameters. This simulink model is used to implement a DSP algorithm for video compression on DM6437 target and I want inside my GUI to see the input video and the output (compressed) video taken back from the DSP board. How can I take the output of the two Video Display blocks from simulink model? I would appreciate your help very much.
>
> Thanks beforehand,
> Alec

Hi Muhammad,

I haven't quite got my head round whether your gui is calling your simulation or whether your simulation is calling your gui but I think I understand your problem.

I'm presuming that your gui is periodically calliing your simulation and at the end of each period your want to display an image on your GUI. I think what you need is an additional 'To Workspace' block on your model (this can run in parralel with the video siplay on your simulink model). This passes your image to the base workspace at each time step. On your gui you need an axis and you can update the cdata each time control passes back to your gui by using the get and set commands (navigate the gui objects by using the children, parent commands, e.g. get(get(myGui,'Children')) ).

However, if your simulation is running constantly then you need some way to initiate the gui update from within your simulink model. But you mentioned that you were already updating some other controls in you gui from your simulink model, so perhaps you already know how to do this. (I'd be interested to know how you did it!) I hope this helps and its not to late to use for your final project

Best Regards
Sam
From: Kostas on
"Samuel Dorrell" <sdorrell(a)asl-vision.co.uk> wrote in message <hvqimp$423$1(a)fred.mathworks.com>...
> "Kostas " <kosotiro(a)yahoo.gr> wrote in message <hsjf0f$8rs$1(a)fred.mathworks.com>...
> > "Kostas " <kosotiro(a)yahoo.gr> wrote in message <hsh7d6$r74$1(a)fred.mathworks.com>...
> > > Alec Rogers <alec.rogers(a)mathworks.com> wrote in message <hk98o2$glu$1(a)fred.mathworks.com>...
> > > >
> > > > Hi Muhammad,
> > > >
> > > > Using the EML block, you could use code similar to the following:
> > > >
> > > > function fcn(u)
> > > > %#eml
> > > > eml.extrinsic('image');
> > > > persistent h;
> > > >
> > > > if isempty(h)
> > > > h = image(u);
> > > > else
> > > > set(h, 'CData', u);
> > > > drawnow;
> > > > end
> > > >
> > > > There is a lot of good information about using that block (and other
> > > > user-defined Simulink blocks) in the documentation. In order to display
> > > > the image in the correct axes, you'll want to consult the documentation
> > > > pertaining to Handle Graphics.
> > > >
> > > > Regards,
> > > > -alec
> > > >
> > > >
> > > > Muhammad Hafizuddin wrote:
> > > > > Hai Alec...
> > > > > Thanks for reply...
> > > > >
> > > > > i'm not familiar with S-function in matlab... can u explain me in
> > > > > detail? or can u provide any page/website for my reference?... look at
> > > > > ur coding, is it we replace To Video Display with another Function
> > > > > block? or just add that coding under GUI?
> > > > >
> > > > > Thanks..
> > > > >
> > > > > Alec Rogers <alec.rogers(a)mathworks.com> wrote in message
> > > > > <hk710q$1vr$1(a)fred.mathworks.com>...
> > > > >> Hi Muhammad,
> > > > >>
> > > > >> There is no way to embed a To Video Display block in another GUI.
> > > > >>
> > > > >> Your best bet would be to write your own S-function (e.g. use the Fcn
> > > > >> block) to update the cdata of the image in your GUI:
> > > > >>
> > > > >> h = image(255*rand(100));
> > > > >>
> > > > >> Then, at each time step:
> > > > >>
> > > > >> set(h, 'CData', 255*rand(100))
> > > > >>
> > > > >> Regards,
> > > > >> -alec
> > > > >>
> > > > >> Muhammad Hafizuddin wrote:
> > > > >> > Hai..
> > > > >> > i have some problem during handle the To Video Display blocks. That
> > > > >> > problems is how to insert video from To Video Display into my
> > > > >> customs > GUI. For your references i attach this link that contain
> > > > >> picture about > this...
> > > > >> > > http://www.haffiezz.com/matlab/Capture.JPG
> > > > >> > > this is my final project and i hope those read this msg and known
> > > > >> that > solution can help me...
> > >
> > > Hi Alec,
> > > And if we want to send the video to a specific GUI at a specific position?
> >
> > I mean that I have already constructed a GUI that communicates with a simulink model and changes its parameters. This simulink model is used to implement a DSP algorithm for video compression on DM6437 target and I want inside my GUI to see the input video and the output (compressed) video taken back from the DSP board. How can I take the output of the two Video Display blocks from simulink model? I would appreciate your help very much.
> >
> > Thanks beforehand,
> > Alec
>
> Hi Muhammad,
>
> I haven't quite got my head round whether your gui is calling your simulation or whether your simulation is calling your gui but I think I understand your problem.
>
> I'm presuming that your gui is periodically calliing your simulation and at the end of each period your want to display an image on your GUI. I think what you need is an additional 'To Workspace' block on your model (this can run in parralel with the video siplay on your simulink model). This passes your image to the base workspace at each time step. On your gui you need an axis and you can update the cdata each time control passes back to your gui by using the get and set commands (navigate the gui objects by using the children, parent commands, e.g. get(get(myGui,'Children')) ).
>
> However, if your simulation is running constantly then you need some way to initiate the gui update from within your simulink model. But you mentioned that you were already updating some other controls in you gui from your simulink model, so perhaps you already know how to do this. (I'd be interested to know how you did it!) I hope this helps and its not to late to use for your final project
>
> Best Regards
> Sam

Sorry for being late to answer! Actually, I've done it! Well, I used a Level 2 M-file S-function block and inside it I wrote the following code:

function inputmovie(block)

setup(block);

%endfunction

function setup(block)

%% Register number of ports
block.NumInputPorts = 3;
block.NumOutputPorts = 0;

%% Setup functional port properties
block.SetPreCompInpPortInfoToDynamic;

block.InputPort(1).DatatypeID = 3; %uint8
block.InputPort(1).Complexity = 'Real';
block.InputPort(1).SamplingMode = 'inherited';

block.InputPort(2).DatatypeID = 3; %uint8
block.InputPort(2).Complexity = 'Real';
block.InputPort(2).SamplingMode = 'inherited';

block.InputPort(3).DatatypeID = 3;%uint8
block.InputPort(3).Complexity = 'Real';
block.InputPort(3).SamplingMode = 'inherited';

%% Register dialog parameters
%block.NumDialogPrms = 1;


%% Register block methods
block.RegBlockMethod('SetInputPortDimensions', @SetInpPortDims);
block.RegBlockMethod('PostPropagationSetup', @DoPostPropSetup);
block.RegBlockMethod('Start', @Start);
block.RegBlockMethod('Outputs', @Output);
%endfunction

function SetInpPortDims(block,idx,di)
block.InputPort(1).Dimensions = di;
block.InputPort(2).Dimensions = di;
block.InputPort(3).Dimensions = di;

%endfunction

function DoPostPropSetup(block)
block.NumDworks = 1;
block.Dwork(1).Name = 'fighandle';
block.Dwork(1).Dimensions = 1;
block.Dwork(1).DatatypeID = 0;
block.Dwork(1).Complexity = 'Real';
%endfunction

function Start(block)

persistent hImage;
mainFigureHandle = CompressionGUI;
mainGUIdata = guidata(mainFigureHandle);

set(mainGUIdata.figure1,'colormap',colormap(gray(256)));


hImage = imshow(uint8(zeros(block.InputPort(1).Dimensions(1),block.InputPort(1).Dimensions(2),3)),'Parent',mainGUIdata.cameraAxes1);


set(hImage, 'EraseMode', 'none')
block.Dwork(1).Data = hImage;
%endfunction

function Output(block)

persistent hImage;
mainFigureHandle = CompressionGUI; %stores the figure handle of Quan's GUI here
mainGUIdata = guidata(mainFigureHandle);

set(mainGUIdata.figure1,'colormap',colormap(gray(256)));

hImage = block.Dwork(1).Data;

if ishandle(hImage)
CurFrame(:,:,1)=block.InputPort(1).Data;
CurFrame(:,:,2)=block.InputPort(2).Data;
CurFrame(:,:,3)=block.InputPort(3).Data;

set(hImage, 'CData',CurFrame,'Parent',mainGUIdata.cameraAxes1);
drawnow;
else
set_param(bdroot,'SimulationCommand','stop');
end
%endfunction


with this code I can update the cdata of my predefined GUI which calls and runs the simulink model and my model itself outputs its video data to my GUI.

Best regards,
Kostas
From: Muhammad Hafizuddin on
"Kostas " <kosotiro(a)yahoo.gr> wrote in message <i1pied$iud(a)fred.mathworks.com>...
> "Samuel Dorrell" <sdorrell(a)asl-vision.co.uk> wrote in message <hvqimp(a)fred.mathworks.com>...
> > "Kostas " <kosotiro(a)yahoo.gr> wrote in message <hsjf0frs$1(a)fred.mathworks.com>...
> > > "Kostas " <kosotiro(a)yahoo.gr> wrote in message <hsh7d6$r74(a)fred.mathworks.com>...
> > > > Alec Rogers <alec.rogers(a)mathworks.com> wrote in message <hk98o2$glu(a)fred.mathworks.com>...
> > > > >
> > > > > Hi Muhammad,
> > > > >
> > > > > Using the EML block, you could use code similar to the following:
> > > > >
> > > > > function fcn(u)
> > > > > %#eml
> > > > > eml.extrinsic('image');
> > > > > persistent h;
> > > > >
> > > > > if isempty(h)
> > > > > h = image(u);
> > > > > else
> > > > > set(h, 'CData', u);
> > > > > drawnow;
> > > > > end
> > > > >
> > > > > There is a lot of good information about using that block (and other
> > > > > user-defined Simulink blocks) in the documentation. In order to display
> > > > > the image in the correct axes, you'll want to consult the documentation
> > > > > pertaining to Handle Graphics.
> > > > >
> > > > > Regards,
> > > > > -alec
> > > > >
> > > > >
> > > > > Muhammad Hafizuddin wrote:
> > > > > > Hai Alec...
> > > > > > Thanks for reply...
> > > > > >
> > > > > > i'm not familiar with S-function in matlab... can u explain me in
> > > > > > detail? or can u provide any page/website for my reference?... look at
> > > > > > ur coding, is it we replace To Video Display with another Function
> > > > > > block? or just add that coding under GUI?
> > > > > >
> > > > > > Thanks..
> > > > > >
> > > > > > Alec Rogers <alec.rogers(a)mathworks.com> wrote in message
> > > > > > <hk710qvr$1(a)fred.mathworks.com>...
> > > > > >> Hi Muhammad,
> > > > > >>
> > > > > >> There is no way to embed a To Video Display block in another GUI.
> > > > > >>
> > > > > >> Your best bet would be to write your own S-function (e.g. use the Fcn
> > > > > >> block) to update the cdata of the image in your GUI:
> > > > > >>
> > > > > >> h = image(255*rand(100));
> > > > > >>
> > > > > >> Then, at each time step:
> > > > > >>
> > > > > >> set(h, 'CData', 255*rand(100))
> > > > > >>
> > > > > >> Regards,
> > > > > >> -alec
> > > > > >>
> > > > > >> Muhammad Hafizuddin wrote:
> > > > > >> > Hai..
> > > > > >> > i have some problem during handle the To Video Display blocks. That
> > > > > >> > problems is how to insert video from To Video Display into my
> > > > > >> customs > GUI. For your references i attach this link that contain
> > > > > >> picture about > this...
> > > > > >> > > http://www.haffiezz.com/matlab/Capture.JPG
> > > > > >> > > this is my final project and i hope those read this msg and known
> > > > > >> that > solution can help me...
> > > >
> > > > Hi Alec,
> > > > And if we want to send the video to a specific GUI at a specific position?
> > >
> > > I mean that I have already constructed a GUI that communicates with a simulink model and changes its parameters. This simulink model is used to implement a DSP algorithm for video compression on DM6437 target and I want inside my GUI to see the input video and the output (compressed) video taken back from the DSP board. How can I take the output of the two Video Display blocks from simulink model? I would appreciate your help very much.
> > >
> > > Thanks beforehand,
> > > Alec
> >
> > Hi Muhammad,
> >
> > I haven't quite got my head round whether your gui is calling your simulation or whether your simulation is calling your gui but I think I understand your problem.
> >
> > I'm presuming that your gui is periodically calliing your simulation and at the end of each period your want to display an image on your GUI. I think what you need is an additional 'To Workspace' block on your model (this can run in parralel with the video siplay on your simulink model). This passes your image to the base workspace at each time step. On your gui you need an axis and you can update the cdata each time control passes back to your gui by using the get and set commands (navigate the gui objects by using the children, parent commands, e.g. get(get(myGui,'Children')) ).
> >
> > However, if your simulation is running constantly then you need some way to initiate the gui update from within your simulink model. But you mentioned that you were already updating some other controls in you gui from your simulink model, so perhaps you already know how to do this. (I'd be interested to know how you did it!) I hope this helps and its not to late to use for your final project
> >
> > Best Regards
> > Sam
>
> Sorry for being late to answer! Actually, I've done it! Well, I used a Level 2 M-file S-function block and inside it I wrote the following code:
>
> function inputmovie(block)
>
> setup(block);
>
> %endfunction
>
> function setup(block)
>
> %% Register number of ports
> block.NumInputPorts = 3;
> block.NumOutputPorts = 0;
>
> %% Setup functional port properties
> block.SetPreCompInpPortInfoToDynamic;
>
> block.InputPort(1).DatatypeID = 3; %uint8
> block.InputPort(1).Complexity = 'Real';
> block.InputPort(1).SamplingMode = 'inherited';
>
> block.InputPort(2).DatatypeID = 3; %uint8
> block.InputPort(2).Complexity = 'Real';
> block.InputPort(2).SamplingMode = 'inherited';
>
> block.InputPort(3).DatatypeID = 3;%uint8
> block.InputPort(3).Complexity = 'Real';
> block.InputPort(3).SamplingMode = 'inherited';
>
> %% Register dialog parameters
> %block.NumDialogPrms = 1;
>
>
> %% Register block methods
> block.RegBlockMethod('SetInputPortDimensions', @SetInpPortDims);
> block.RegBlockMethod('PostPropagationSetup', @DoPostPropSetup);
> block.RegBlockMethod('Start', @Start);
> block.RegBlockMethod('Outputs', @Output);
> %endfunction
>
> function SetInpPortDims(block,idx,di)
> block.InputPort(1).Dimensions = di;
> block.InputPort(2).Dimensions = di;
> block.InputPort(3).Dimensions = di;
>
> %endfunction
>
> function DoPostPropSetup(block)
> block.NumDworks = 1;
> block.Dwork(1).Name = 'fighandle';
> block.Dwork(1).Dimensions = 1;
> block.Dwork(1).DatatypeID = 0;
> block.Dwork(1).Complexity = 'Real';
> %endfunction
>
> function Start(block)
>
> persistent hImage;
> mainFigureHandle = CompressionGUI;
> mainGUIdata = guidata(mainFigureHandle);
>
> set(mainGUIdata.figure1,'colormap',colormap(gray(256)));
>
>
> hImage = imshow(uint8(zeros(block.InputPort(1).Dimensions(1),block.InputPort(1).Dimensions(2),3)),'Parent',mainGUIdata.cameraAxes1);
>
>
> set(hImage, 'EraseMode', 'none')
> block.Dwork(1).Data = hImage;
> %endfunction
>
> function Output(block)
>
> persistent hImage;
> mainFigureHandle = CompressionGUI; %stores the figure handle of Quan's GUI here
> mainGUIdata = guidata(mainFigureHandle);
>
> set(mainGUIdata.figure1,'colormap',colormap(gray(256)));
>
> hImage = block.Dwork(1).Data;
>
> if ishandle(hImage)
> CurFrame(:,:,1)=block.InputPort(1).Data;
> CurFrame(:,:,2)=block.InputPort(2).Data;
> CurFrame(:,:,3)=block.InputPort(3).Data;
>
> set(hImage, 'CData',CurFrame,'Parent',mainGUIdata.cameraAxes1);
> drawnow;
> else
> set_param(bdroot,'SimulationCommand','stop');
> end
> %endfunction
>
>
> with this code I can update the cdata of my predefined GUI which calls and runs the simulink model and my model itself outputs its video data to my GUI.
>
> Best regards,
> Kostas

hi all..
thanks for your reply..

for kostas, can i request your m file or simulink file?