Create Level 2 S-Function Block from .M Filfe

1 view (last 30 days)
james
james on 19 Nov 2014
Commented: james on 19 Nov 2014
my .m file is pasted below
%%%%%%%%%%%%%%%%%%%%%%%%%%%
function showcameraonly
% Set up camera camera = cv.VideoCapture; camera.open('http://jamesquags.ddns.net/mjpg/video.mjpg')
pause(1); % Necessary in some environment. See help cv.VideoCapture
% Set up display window window = figure('KeyPressFcn',@(obj,evt)setappdata(obj,'flag',true)); setappdata(window,'flag',false);
% Start main loop while true % Grab and preprocess an image im = camera.read;
% Draw results
imshow(im);
% Terminate if any user input
flag = getappdata(window,'flag');
if isempty(flag)||flag, break; end
pause(.000000000000000000000000001);
end
% Close close(window);
end
%%%%%%%%%%%%%
This is a pretty good way to get live streaming video into Matlab for Computer Vision purposes. It references the OpenCV library and MEX files to allow Matlab to use them. This is a great method; however, it is very difficult to create a Simulink Block out of the code. I would like to create a Level 2 S-Function Block. Can anyone help me with this?
The Simulink system I would like to integrate this in is attached as a picture.
Thank you,
James

Answers (1)

Dima Lisin
Dima Lisin on 19 Nov 2014
Hi James,
If you have the Image Acquisition Toolbox, then you can use the From Video Device block.
  1 Comment
james
james on 19 Nov 2014
Dima,
Thank you very much for the response. Unfortunately we are working with a Power Over Ethernet IP Camera, and, as far as I know, there is no IP Camera support for Matlab. The From Video Device block does not support IP addresses.
-James

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!