MATLAB Answers

deep learning model deploy to raspberry pi using MATLAB

2 views (last 30 days)
Sungho Kang
Sungho Kang on 18 Mar 2021
Edited: Prasanth Sunkara on 26 Mar 2021
code
function PDR2()
%#codegen
raspiObj = raspi();
cam = cameraboard(raspiObj);
net = coder.loadDeepLearningNetwork('resnet50');
inputSize = [224, 224, 3];
textToDisplay = '......';
start = tic;
fprintf('Entering into while loop.\n');
while true
img = snapshot(cam);
elapsedTime = toc(start);
if elapsedTime > 1
imgSizeAdusted = imresize(img,inputSize(1:2));
[label,score] = net.classify(imgSizeAdusted);
maxScore = max(score);
labelStr = cellstr(label);
textToDisplay = sprintf('Label : %s \nScore : %f', labelStr{:}, maxScore);
start = tic;
end
img_label = insertText(img,[0,0],textToDisplay);
displayImage(raspiObj,img_label);
end
end
DEPLOY
board = targetHardware('Raspberry Pi');
board.CoderConfig.TargetLang = 'C++'
dlcfg = coder.DeepLearningConfig('arm-compute');
dlcfg.ArmArchitecture = 'armv7';
dlcfg.ArmComputeVersion = '19.05'
board.CoderConfig.DeepLearningConfig = dlcfg
deploy(board, 'PDR2')
error
Deploying code. This may take a few minutes.
------------------------------------------------------------------------
Error executing command "touch -c /home/pi/MATLAB_ws/R2020b/C/Users/lenovo/Desktop/Project/codegen/exe/PDR2/*.*;make -f PDR2_rtw.mk all MATLAB_WORKSPACE="/home/pi/MATLAB_ws/R2020b" -C /home/pi/MATLAB_ws/R2020b/C/Users/lenovo/Desktop/Project/codegen/exe/PDR2". Details:
STDERR: In file included from MWCNNLayerImpl.hpp:10,
from MWAdditionLayerImpl.hpp:8,
from MWAdditionLayer.cpp:4:
MWACLUtils.hpp:12:10: fatal error: arm_compute/runtime/NEON/NEFunctions.h: No such file or directory
#include "arm_compute/runtime/NEON/NEFunctions.h"
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [PDR2_rtw.mk:358: MWAdditionLayer.cpp.o] Error 1
STDOUT: make: Entering directory '/home/pi/MATLAB_ws/R2020b/C/Users/lenovo/Desktop/Project/codegen/exe/PDR2'
g++ -c -MMD -MP -MF"MWAdditionLayer.cpp.dep" -MT"MWAdditionLayer.cpp.o" -fpermissive -O2 -std=c++11 -mfpu=neon -fopenmp -D_POSIX_C_SOURCE=199309L -DDISABLE_JPEG_ENCODING -DUSE_19_05_LIBRARY -D__MW_TARGET_USE_HARDWARE_RESOURCES_H__ -DMW_MATLABTARGET -D__linux__ -DARM_PROJECT -D_USE_TARGET_UDP_ -D_RUNONTARGETHARDWARE_BUILD_ -DSTACK_SIZE=200000 -DMODEL=PDR2 -I/home/pi/MATLAB_ws/R2020b/C/Users/lenovo/Desktop/Project/codegen/exe/PDR2 -I/home/pi/MATLAB_ws/R2020b/C/Users/lenovo/Desktop/Project -I/home/pi/MATLAB_ws/R2020b/C/Program_Files/MATLAB/R2020b/toolbox/eml/externalDependency/timefun -I/home/pi/MATLAB_ws/R2020b/C/ProgramData/MATLAB/SupportPackages/R2020b/toolbox/realtime/targets/raspi/server -I/opt/userland/host_applications/linux/libs/bcm_host/include -I/opt/userland -I/opt/userland/host_applications/linux/apps/raspicam -I/opt/userland/interface/vcos -I/opt/userland/interface/vcos/pthreads -I/opt/userland/interface/vmcs_host/linux -I -I/include -I/home/pi/MATLAB_ws/R2020b/C/Users/lenovo/Desktop/Project/codegen/exe/PDR2/examples -I/home/pi/MATLAB_ws/R2020b/C/ProgramData/MATLAB/SupportPackages/R2020b/toolbox/realtime/targets/raspi/include -I/home/pi/MATLAB_ws/R2020b/C/Program_Files/MATLAB/R2020b/toolbox/coder/rtiostream/src/utils -I/home/pi/MATLAB_ws/R2020b/C/Program_Files/MATLAB/R2020b/extern/include -o "MWAdditionLayer.cpp.o" "MWAdditionLayer.cpp"
make: Leaving directory '/home/pi/MATLAB_ws/R2020b/C/Users/lenovo/Desktop/Project/codegen/exe/PDR2'
------------------------------------------------------------------------
??? Build error: C++ compiler produced errors. See the Build Log for further details.
More information
Code generation failed: View Error Report
what can I do?
please help me
Does it need GPU?
  1 Comment
Prasanth Sunkara
Prasanth Sunkara on 26 Mar 2021
Along with Jason's suggetion, please check that you have arm_compute library installed on your pi.

Sign in to comment.

Answers (1)

Community Treasure Hunt

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

Start Hunting!