0
votes

I need to create a block in Simulink to deform a video streaming. I create this code for the 'Interpreted MATLAB Fcn' block of Simulink:

function B = deformation(A,tform)
%#codegen

B=imwarp(A,tform);

For me now the problem is:

  • how to create the block to provide the input of tform that is a structure
  • how to manage A, that is the signal from 'From Video device' block in Simulink

I already tested imwarp function for a static image, and I've already calculated tform values as input to imwarp

Is there a method to update calculated tform on a block of simulink. They should no change

1

1 Answers

1
votes

There are 3 ways to use Matlab functions in simulink.

  • Interpreted Matlab functions
  • level 1 Matlab s-functions
  • level 2 Matlab s-functions

Personally I neither like level 1 s-functions nor interpreted Matlab functions. For level 1 s-functions you gotta tell simulink which functions you plan to use, similar to an include. Interpreted Matlab functions are pretty restricted so I'd suggest you a level 2 Matlab s-function, as soon as you intend to do a little advanced stuff.

Also I'd suggest you to use 3 dimensional arrays instead of structs, a picture is a x*y*3 array which you can use in a simulink-block. You can use setInputDimension to get the input-size and set the output size according to your wishes (level 2 s-function).

Also if your problems is just the format struct you can write a simple script which transforms the struct into a three dimensional array, wich is no issue for simulink (in this case you can go with the interpreted matlab function).

At last: I am pretty sure you can't use structs to pass data between simulink blocks, except you read and write to the base workspace, and infact pass no real information between your blocks.

I hope that helped a little.