How can I deploy a face tracking algorithm to Raspberry Pi 4?
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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?
0 comentarios
Respuestas (2)
David Fink
el 19 de Oct. de 2021
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 comentarios
David Fink
el 26 de Oct. de 2021
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
Rilwan Shekoni
el 11 de Nov. de 2021
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
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!