Code Generation failed: How to use a Matlab algorithm inside a Simulink MATLAB Function Block?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/165963/image.png)
The result I get in the Diagnostic viewer is this:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/165964/image.png)
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,
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/165966/image.png)
Is there a problem with my code or the model? How may I implement the project?
0 comentarios
Respuestas (3)
M.Khan
el 8 de Jun. de 2016
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
0 comentarios
M.Khan
el 9 de Jun. de 2016
Yes, you need to change the compiler. One of the supported compilers is Microsoft Visual C++ 2012.
- Mohammad
0 comentarios
Comunidades de usuarios
Más respuestas en ThingSpeak Community
Ver también
Categorías
Más información sobre Image Processing and Computer Vision en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!