digiKam
Digikam::OpenCVDNNFaceDetector Class Reference

Public Member Functions

std::vector< cv::Rect > cvDetectFaces (const cv::Mat &inputImage, const cv::Size &paddedSize)
 
QList< QRect > detectFaces (const cv::Mat &inputImage, const cv::Size &paddedSize)
 
 OpenCVDNNFaceDetector (DetectorNNModel model=DetectorNNModel::SSDMOBILENET)
 
cv::Mat prepareForDetection (const DImg &inputImage, cv::Size &paddedSize) const
 
cv::Mat prepareForDetection (const QImage &inputImage, cv::Size &paddedSize) const
 
cv::Mat prepareForDetection (const QString &inputImagePath, cv::Size &paddedSize) const
 
 ~OpenCVDNNFaceDetector ()
 

Static Public Member Functions

static int recommendedImageSizeForDetection ()
 

Constructor & Destructor Documentation

◆ OpenCVDNNFaceDetector()

Digikam::OpenCVDNNFaceDetector::OpenCVDNNFaceDetector ( DetectorNNModel  model = DetectorNNModel::SSDMOBILENET)
explicit

◆ ~OpenCVDNNFaceDetector()

Digikam::OpenCVDNNFaceDetector::~OpenCVDNNFaceDetector ( )

Member Function Documentation

◆ cvDetectFaces()

std::vector< cv::Rect > Digikam::OpenCVDNNFaceDetector::cvDetectFaces ( const cv::Mat &  inputImage,
const cv::Size &  paddedSize 
)

◆ detectFaces()

QList< QRect > Digikam::OpenCVDNNFaceDetector::detectFaces ( const cv::Mat &  inputImage,
const cv::Size &  paddedSize 
)

There is no proof that doing this will help, since face can be detected at various positions (even half, masked faces can be detected), not only frontal. Effort on doing this should be questioned. TODO: Restructure and improve Face Detection module.

void OpenCVDNNFaceDetector::resizeBboxToStandardHumanFace(int& width, int& height) { Human head sizes data https://en.wikipedia.org/wiki/Human_head#Average_head_sizes

float maxRatioFrontalFace    = 15.4 / 15.5;
float minRatioNonFrontalFace = 8.6  / 21.6;

float r = width*1.0/height, rReference;

if      ((r >= minRatioNonFrontalFace*0.9) && r <= (maxRatioFrontalFace * 1.1))
{
    rReference = r;
}
else if (r <= 0.25)
{
    rReference = r * 1.5;
}
else if (r >= 4)
{
    rReference = r / 1.5;
}
else if (r < minRatioNonFrontalFace * 0.9)
{
    rReference = minRatioNonFrontalFace;
}
else if (r > maxRatioFrontalFace * 1.1)
{
    rReference = maxRatioFrontalFace;
}

if (width > height)
{
    height = width / rReference;
}
else
{
    width = height * rReference;
}

}

References cvDetectFaces().

◆ prepareForDetection() [1/3]

cv::Mat Digikam::OpenCVDNNFaceDetector::prepareForDetection ( const DImg inputImage,
cv::Size &  paddedSize 
) const

◆ prepareForDetection() [2/3]

cv::Mat Digikam::OpenCVDNNFaceDetector::prepareForDetection ( const QImage &  inputImage,
cv::Size &  paddedSize 
) const

References prepareForDetection().

◆ prepareForDetection() [3/3]

cv::Mat Digikam::OpenCVDNNFaceDetector::prepareForDetection ( const QString &  inputImagePath,
cv::Size &  paddedSize 
) const

References prepareForDetection().

◆ recommendedImageSizeForDetection()

int Digikam::OpenCVDNNFaceDetector::recommendedImageSizeForDetection ( )
static

Returns the image size (one dimension) recommended for face detection. If the image is considerably larger, it will be rescaled automatically.

Referenced by Digikam::FaceDetector::recommendedImageSize().


The documentation for this class was generated from the following files: