OpenCV detectMultiScale() 参数的推荐值

时间:2023-02-28
本文介绍了OpenCV detectMultiScale() 参数的推荐值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

CascadeClassifier::的推荐参数是什么?detectMultiScale() 并根据哪些因素我应该更改默认参数?

What are the recommended parameters for CascadeClassifier::detectMultiScale() and depending on which factors I should change default parameters?

void CascadeClassifier::detectMultiScale(
    const Mat& image, 
    vector<Rect>& objects, 
    double scaleFactor=1.1,
    int minNeighbors=3, 
    int flags=0, 
    Size minSize=Size(),
    Size maxSize=Size() )

推荐答案

在这些参数中,有四个需要你多加注​​意:

Amongst these parameters, you need to pay more attention to four of them:

  • scaleFactor – 指定图像尺寸在每个图像比例下缩小多少的参数.

  • scaleFactor – Parameter specifying how much the image size is reduced at each image scale.

基本上,比例因子用于创建您的比例金字塔.更多解释可以在这里找到.简而言之,如 此处,您的模型在训练期间定义了固定大小,该大小在 xml 中可见.这意味着在图像中检测到此大小的人脸(如果存在).但是,通过重新缩放输入图像,您可以将较大的人脸调整为较小的人脸,使其可被算法检测到.

Basically the scale factor is used to create your scale pyramid. More explanation can be found here. In short, as described here, your model has a fixed size defined during training, which is visible in the xml. This means that this size of face is detected in the image if present. However, by rescaling the input image, you can resize a larger face to a smaller one, making it detectable by the algorithm.

1.05 是一个很好的可能值,这意味着您使用一小步调整大小,即减小 5% 的大小,增加匹配的机会大小与用于检测的模型被找到.这也意味着该算法的运行速度较慢,因为它更彻底.您可以将其增加到 1.4 以加快检测速度,但可能会丢失一些人脸.

1.05 is a good possible value for this, which means you use a small step for resizing, i.e. reduce size by 5%, you increase the chance of a matching size with the model for detection is found. This also means that the algorithm works slower since it is more thorough. You may increase it to as much as 1.4 for faster detection, with the risk of missing some faces altogether.

minNeighbors - 指定每个候选矩形应保留多少邻居的参数.

minNeighbors – Parameter specifying how many neighbors each candidate rectangle should have to retain it.

这个参数会影响检测到的人脸的质量.值越高,检测次数越少,但质量越高.3~6 物有所值.

This parameter will affect the quality of the detected faces. Higher value results in less detections but with higher quality. 3~6 is a good value for it.

minSize – 最小可能的对象大小.小于该值的对象将被忽略.

minSize – Minimum possible object size. Objects smaller than that are ignored.

这个参数决定了你想要检测的尺寸有多小.你来决定!通常,[30, 30] 是人脸检测的良好开端.

This parameter determine how small size you want to detect. You decide it! Usually, [30, 30] is a good start for face detection.

maxSize – 最大可能的对象大小.大于此值的对象将被忽略.

maxSize – Maximum possible object size. Objects bigger than this are ignored.

这个参数决定了你想检测多大的尺寸.再次,你决定!通常不需要手动设置,默认值假设您要检测的人脸大小没有上限.

This parameter determine how big size you want to detect. Again, you decide it! Usually, you don't need to set it manually, the default value assumes you want to detect without an upper limit on the size of the face.

这篇关于OpenCV detectMultiScale() 参数的推荐值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

上一篇:OpenCV 中的 Sobel 导数 下一篇:使用“const cv::Mat"、“cv::Mat"、“cv::Mat&

相关文章

最新文章