How to import a trained object detector to Simulink?

1 view (last 30 days)
Hi. I have trained an object detector using trainYOLOv4ObjectDetector() function and now I want to add this detector to my Simulink model to detect the objects from the images I pass through in the Simulink model. Is there any way to import it? I tried using Deep learning object detector block but its not working. Could someone guide me through this?

Accepted Answer

Ashu
Ashu on 24 Jan 2023
Edited: Ashu on 25 Jan 2023
Hi Chandni,
You can use a MATLAB Function block in simulink to load the trained object detector .
To work with MATLAB Function block you can refer :
Inside the function you can have your custom code and make predictions like this
% Assuming trainedDetector.mat is the saved object detector
trainedDetector = load('trainedDetector.mat', 'trainedDetector')
I = imread('highway.png');
[bboxes, scores, labels] = detect(trainedDetector,I,Threshold=0.05);
detectedImg = insertObjectAnnotation(I,"Rectangle",bboxes,labels);
To read more about loading different types of variables, you can refer
To learn more about YoloV4ObjectDetector, you can refer

More Answers (0)

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!