How to add a trained deep neural network into a MATLAB function for C++ code generation using MATLAB Coder?
Mostrar comentarios más antiguos
As part of my project, I have to include a trained deep neural network into a MATLAB function in order to classify different types of arrows using a webcam. The code is given below. And when i try to convert the MATLAB code using MATLAB Coder it shows an error of Maximum recursion limit of 500 reached. What is the reason this error occuring and how can i avoid this error.
function [Vx,Vy,Omega] = Landmarkerkennung(Image)
net = coder.loadDeepLearningNetwork('convnetwork1'); %Is this how to include a trained network?
%convnetwork1 is the name of my trained Network which is saved in MATLAB
% Vx, Vy,Omega are the linear and angular velocities which has to be fed to the robot. And input is the image from the camera of a robot.
%Workspace.
%UNTITLED Summary of this function goes here
% Detailed explanation goes here
% Continous loop for live video from thr Robotino Camera
while true
img = Image; % Capturing new Image in 'img'
picture = imresize(img,[227,227]); % Resizing the picture (227 227). Pixel required for Alexnet Algorithm
label = classify(net, picture); % Classify the picture. Labels of the pictures are stored in 'label'
% Calling the respective function according to the label that appears on
% the camera frame
if label == 'straight'
Omega = 0;
Vx = 75;
Vy = 0;
% [Vx,Vy,Omega] = gostraight();
elseif label == 'left'
disp('Left');
Omega = 50;
Vx = 0;
Vy = 0;
pause(2); % Pause the execution of the Programm for 2 second
% [Vx,Vy,Omega] = gosharpleft();
elseif label == 'right'
disp('Right');
Omega = -50;
Vx = 0;
Vy = 0;
pause(2); % Pause the execution of the Programm for 2 second
% [Vx,Vy,Omega] = gosharpright();
elseif label == 'right'
disp('Right');
Omega = -50;
Vx = 0;
Vy = 0;
pause(2); % Pause the execution of the Programm for 2 second
end
end
end
When i convert the MATLAB function i get this error.

Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Deep Learning Toolbox en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
