objectDetection (Report for single object detection) and YOLO.
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello everyone!
I need some help with using the Object Detection function in YOLO to obtain detection results based on frames. I've tried various codes, but the results are not what I expect. Any advice or guidance would be greatly appreciated.
for example
Video = VideoReader("tr.avi",CurrentTime=0);
player = vision.VideoPlayer;
detections = {};
measurementNoise = 10;
while hasFrame(Video)
frame = readFrame(Video);
frameIndex = round(Video.CurrentTime * Video.FrameRate);
[bbox, score, label] = detect(detector, frame);
if length(detections) < frameIndex
detections{frameIndex} = {};
end
for i = 1:length(score)
detections{frameIndex}{end+1} = objectDetection(frameIndex, bbox(i,:), ...
"MeasurementNoise", measurementNoise, "ObjectAttributes", struct("Score", score(i)));
end
Object = insertObjectAnnotation(frame, "rectangle", bbox, label, "Color", "green");
step(player, Object);
end
Thank you!
0 Kommentare
Antworten (1)
Samay Sagar
am 27 Aug. 2024
Hi Bashir,
When working with YOLO for object detection on video frames, it is important to ensure that your setup is correctly configured and optimized for the task at hand.
Ensure that your YOLO detector is properly loaded and compatible with your MATLAB version. If you have a pretrained detector saved in a MAT file, you can load it using:
pretrained = load('yolov2ResNet50VehicleExample_19b.mat');
detector = pretrained.detector;
If you do not have a pretrained network, you can train your own model by referring to the following documentations:
To create your own YOLO detection network, refer the following documentation:
Here is how you can use object detection with a pretrained network for vehicle detection:
Video = VideoReader("sampleVideo_640x480.mp4");
player = vision.VideoPlayer;
pretrained = load('yolov2ResNet50VehicleExample_19b.mat');
detector = pretrained.detector;
detections = {};
measurementNoise = 10;
while hasFrame(Video)
frame = readFrame(Video);
frameIndex = round(Video.CurrentTime * Video.FrameRate);
% Perform detection on the frame
[bbox, score, label] = detect(detector, frame);
% Store detections
if length(detections) < frameIndex
detections{frameIndex} = {};
end
for i = 1:length(score)
detections{frameIndex}{end+1} = objectDetection(frameIndex, bbox(i,:), ...
"MeasurementNoise", measurementNoise, "ObjectAttributes", struct("Score", score(i)));
end
% Annotate and display frame
Object = insertObjectAnnotation(frame, "rectangle", bbox, cellstr(label), "Color", "green");
step(player, Object);
end
0 Kommentare
Siehe auch
Kategorien
Mehr zu Tracking and Motion Estimation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!