How can I deploy a face tracking algorithm to Raspberry Pi 4?

3 次查看(过去 30 天)
I've created an algorithm to perform face tracking and recognition using a deep neural network. I've adapted the code in order to perform the code generation and it works if i run it from matlab. If i try to deploy it on the raspberry pi i always get some compilers error (see the question https://it.mathworks.com/matlabcentral/answers/887539-can-t-deploy-the-executable-on-raspberry-pi-and-matlab-coder-doesn-t-generate-the-elf-file) . I tried to split the code in different sections and to deploy them singularly: the section on the use of the deep neural network had no issues, but the section about the face detection and tracking gave me a lot of problems.
I've also tried this example https://it.mathworks.com/help/vision/ug/track-face-raspberry-pi2.html but i always had some problems related to the compilation.
Searching on the MATLAB forum i found that the Cascade Object Detector can only be used in simulations and cannot be used for code generation and deploy. How can i work around this problem?

回答(2 个)

David Fink
David Fink 2021-10-19
The Cascade Object Detector supports code generation, with some limitations:
In particular, for deployment, see the information on using OpenCV libraries.
Regarding the face tracking example, please reach out to MathWorks Technical Support, who can assist with setup and configuration issues.
  4 个评论
David Fink
David Fink 2021-10-26
Hi Pietro,
If requesting assistance with an error, be sure to include the steps you followed to reach the error, and the text of the error message (and error stack, if displayed).
MathWorks Technical Support can work with you to determine the cause of the error.
Best,
David
Pietro Ventrella
Pietro Ventrella 2021-10-26
I've linked another question i've made some time ago and there are described all steps that brought me to those errors.
In the comments there is also the error stack.

请先登录,再进行评论。


Rilwan Shekoni
Rilwan Shekoni 2021-11-11
Hello @Pietro Ventrella, I am having a similar issue. Have you found a resolve?
Code.............
function rpiFace %#codegen
%Create raspi & webcam obj
raspiObj = raspi();
cam = webcam(raspiObj,2);
%Initialize DNN and the input size
net = coder.loadDeepLearningNetwork('FaceNet.mat');
inputSize = [227, 227, 1]; %net.Layers(1).InputSize(1:2);
%faceDetector = vision.CascadeObjectDetector;
%faceDetector.MergeThreshold = 8;
bboxes = [0,0,100,100];
text = 'No face detected';
start = tic;
fprintf('Initialing....\n');
while true
%Capture image from webcam
img = snapshot(cam);
imgSet = rgb2gray(img);
elapsedTime = toc(start);
%Process frames at 1 per second
if elapsedTime > 1
%Resize the image
imgSize = imresize(imgSet,inputSize(1:2));
%Classify the input image
[label,score] = classify(net,imgSize);
maxScore = max(score);
strlabel = cellstr(label);
text = sprintf('%s %f',strlabel{:},maxScore);
%bboxes = faceDetector(img);
start = tic;
end
%Display the predicted label
img = insertObjectAnnotation(img,'rectangle',bboxes,text,'TextBoxOpacity',0.9,'FontSize',8);
%img = insertShape(img,'rectangle',(bboxes));
%img = insertText(img,[0,0],text);
displayImage(raspiObj,img);
end
end
Error........
Error executing command "touch -c /home/pi/MATLAB_ws/R2020b/C/Users/RilSh/Documents/MATLAB/DL_Rpi/codegen/exe/piTestB/*.*;make -f piTestB_rtw.mk all MATLAB_WORKSPACE="/home/pi/MATLAB_ws/R2020b" -C /home/pi/MATLAB_ws/R2020b/C/Users/RilSh/Documents/MATLAB/DL_Rpi/codegen/exe/piTestB". Details:
........
??? Build error: C++ compiler produced errors. See the Build Log
for further details.
More information
Code generation failed: View Error Report

类别

Help CenterFile Exchange 中查找有关 Image Processing and Computer Vision 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by