How to use MergeThreshold in vision.Cas​cadeObject​Detector

2 次查看(过去 30 天)
Can someone explain how to use MergeThreshold in vision.CascadeObjectDetector?
And also how it works.
Here's our testing code.
-----------------------------------------------------------------------------------------------------------------------------------
clear
close all
clc
FDetect=vision.CascadeObjectDetector;
I = imread('test5.jpg');
BB = step(FDetect, I);
figure
imshow(I);
for i=1:size(BB,1)
rectangle('Position',BB(i,:),'LineWidth',5,'LineStyle','-','EdgeColor','r');
end
title('Face Detection')
NoseDetect = vision.CascadeObjectDetector('Nose','MergeThreshold',24);
BB=step(NoseDetect,I);
figure
imshow(I)
for i=1:size(BB,1)
rectangle('Position',BB(i,:),'LineWidth',4,'LineStyle','-','EdgeColor','y');
end
title('Nose Detection')
MouthDetect = vision.CascadeObjectDetector('Mouth','MergeThreshold',128);
BB=step(MouthDetect,I);
figure
imshow(I)
for i=1:size(BB,1)
rectangle('Position',BB(i,:),'LineWidth',4,'LineStyle','-','EdgeColor','g');
end
title('Mouth Detection')
EyeDetect = vision.CascadeObjectDetector('EyePairBig','MergeThreshold',6);
BB=step(EyeDetect,I);
figure,
imshow(I);
for i = 1:size(BB,1)
rectangle('Position',BB(i,:),'LineWidth',4,'LineStyle','-','EdgeColor','b');
end
-----------------------------------------------------------------------------------------------------------------------------------
Why the value only can be 24, 128, 6, otherwise it can't work?

回答(1 个)

Shantanu Dixit
Shantanu Dixit 2024-9-6
Hi ShengJu,
The 'MergeThreshold' parameter defines the criteria needed to declare a final detection by requiring multiple overlapping detections in an area. Increasing this threshold can suppress false positives by ensuring the target object is detected multiple times during the detection phase. Setting threshold to 0 returns all detections without merging or thresholding.
The effectiveness of specific 'MergeThreshold' values, such as 24, 128, or 6, can vary based on image quality, object sizes as well as the pre-trained model's characteristics. Different objects and image conditions might require different thresholds to achieve the best balance between detection accuracy and false positive suppression. Since the property is tunable you can experiment with different threshold values to suit your use-case.
For more information regarding Cascade object detector refer to the below MathWorks documentation:

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by