def _raw_face_locations(img, number_of_times_to_upsample=1, model="hog"):
"""
Returns an array of bounding boxes of human faces in a image
:param img: An image (as a numpy array)
:param number_of_times_to_upsample: How many times to upsample the image looking for faces. Higher numbers find smaller faces.
:param model: Which face detection model to use. "hog" is less accurate but faster on CPUs. "cnn" is a more accurate
deep-learning model which is GPU/CUDA accelerated (if available). The default is "hog".
:return: A list of dlib 'rect' objects of found face locations
"""
if model == "cnn":
return cnn_face_detector(img, number_of_times_to_upsample)
else:
return face_detector(img, number_of_times_to_upsample)
face_detector(img, number_of_times_to_upsample) should be changed to
private IEnumerable<MModRect> RawFaceLocations(Image faceImage, int numberOfTimesToUpsample = 1, Models model = Models.Hog)
{
switch (model)
{
case Models.Cnn:
return CnnFaceDetectionodelV1.Detect(this._CnnFaceDetector, faceImage.Matrix, numberOfTimesToUpsample);
default:
{
using (var pyr = new PyramidDown(2))
{
var rects = new List<MModRect>();
var image = faceImage.Matrix;
var levels = numberOfTimesToUpsample;
while (levels > 0)
{
levels--;
DlibDotNet.Dlib.PyramidUp<PyramidDown>(image, 2);
}
var dets = this._CnnFaceDetector.Operator(image);
foreach (var d in dets.First())
{
var drect = pyr.RectDown(new DRectangle(d.Rect), (uint)numberOfTimesToUpsample);
d.Rect = new Rectangle((int)drect.Left, (int)drect.Top, (int)drect.Right, (int)drect.Bottom);
rects.Add(d);
}
return rects;
}
}
}
}
(Sorry to use C# rather than python.)
The 2nd argument 'number_of_times_to_upsample' does not suit to face_detector operator.
On original dlib, the 2nd argument face_detector operator takes double threshold.
This value is threshold for searching saliency image rather than indicating number of times to upsampling.
Was this done intentionally?
Description
I am porting your library to C# on https://github.com/takuya-takeuchi/FaceRecognitionDotNet. Then, contributor points
face_detector(img, number_of_times_to_upsample) should be changed to
(Sorry to use C# rather than python.)
The 2nd argument 'number_of_times_to_upsample' does not suit to face_detector operator. On original dlib, the 2nd argument face_detector operator takes double threshold. This value is threshold for searching saliency image rather than indicating number of times to upsampling. Was this done intentionally?
What I Did
N/A