Code Generation failed: How to use a Matlab algorithm inside a Simulink MATLAB Function Block?

1 回表示 (過去 30 日間)
Apoorv Lokhande
Apoorv Lokhande 2016 年 6 月 8 日
回答済み: M.Khan 2016 年 6 月 9 日
I am trying to do a project from Thingspeak, the link is Thingspeak Project . The simulink model given in the project contains a ForegroundDetector block which we can not find in the Simulink library browser. So, I concluded that it is a matlab function block containing a ForegroundDetector function. I made a Simulink model to compute the foreground mask & made a similar function block using this code,
function fgMask = fcn(image)
%#codegen
detector = vision.ForegroundDetector(...
'NumTrainingFrames', 5, 'InitialVariance', 30*30);
fgMask = step(detector, image);
My model is
The result I get in the Diagnostic viewer is this:
Here 'TrafficSurveillance' refers to the name of my model. I have reached this very brief code after many edits & cuts with the same problem everytime. Acually the algorithm is large & I want to implement the algorithm using few matlab blocks doing different functions of the algorithm. But this problem is prevalent with the ever short code.
When I typed mex -setup in the command window,
Is there a problem with my code or the model? How may I implement the project?

回答 (3 件)

M.Khan
M.Khan 2016 年 6 月 8 日
vision.ForegroundDetector does not support MATLAB function block. It's listed in this table .
The model in Thingspeak Project uses a MATLAB System block. Just specify vision.ForegroundDetector in the "System object name" edit box and it should work.
Thanks,
Mohammad

M.Khan
M.Khan 2016 年 6 月 9 日
Yes, you need to change the compiler. One of the supported compilers is Microsoft Visual C++ 2012.
- Mohammad

Apoorv Lokhande
Apoorv Lokhande 2016 年 6 月 9 日
Hi Mohammad,
Thanks for this information. I applied the Matlab System block with vision.ForegroundDetector & I got the same block as in the project. But still, I am getting the same diagnostic report.
Do I need to change the compiler? I have Windows SDK 7.1 installed.

コミュニティ

その他の回答  ThingSpeak コミュニティ

カテゴリ

Help Center および File ExchangeImage Processing and Computer Vision についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by