CascadeClassifier faceDetector = new CascadeClassifier("/haarcascade_frontalface_default.xml");
Mat image = Highgui.imread(originalFile.getAbsolutePath());
MatOfRect faceDetections = new MatOfRect();
double w = ((double)originalCrop.getWidth());
double h = ((double)originalCrop.getHeight());
faceDetector.detectMultiScale(image, faceDetections, 3, 1,
Objdetect.CASCADE_DO_CANNY_PRUNING , new Size(w/16, h/16), new Size(w/2, h/2));
来自 API: scaleFactor – 指定在每个图像比例下图像尺寸减小多少的参数。
更改 scaleFactor 会更改检测到的内容。例如,对于以下图像: http: //graphics8.nytimes.com/images/2013/04/02/world/MOSCOW/MOSCOW-articleLarge-v2.jpg
scaleFactor of 3 --> Gorbachev 的脸未被检测到
scaleFactor of 2 --> Gorbachev 的脸被检测到两次(一个较大的矩形包含一个较小的矩形)
scaleFactor of 1.01 ---> Gorbachev 的脸被检测到一次
这究竟是如何工作的?