【发布时间】:2019-07-28 03:13:35
【问题描述】:
我正在编写一个应用程序来检测人脸并对其进行构图。为了更好地识别,我将照片放大了 2 倍,当我显示它时,结果是最初的 2 倍,如何缩小 2 倍?窗口有resize()方法,但是要使用它需要知道照片的初始大小,但我不知道怎么做。
#include <iostream>
#include <clocale>
#include <dlib/image_processing/frontal_face_detector.h>
#include <dlib/gui_widgets.h>
#include <dlib/image_io.h>
using namespace dlib;
using namespace std;
int main(int argc, char* argv[])
{
try
{
setlocale(LC_ALL, "Rus");
if (argc < 2)
{
cout << "face_detector photo.jpg";
cin.get();
return 0;
}
array2d<unsigned char> img;
frontal_face_detector detector = get_frontal_face_detector();
image_window win;
load_image(img, argv[1]);
pyramid_up(img); //upsize photo x2
std::vector<rectangle> dets = detector(img);
cout << "Faces count: " << dets.size() << endl;
win.clear_overlay();
//win.set_size();
win.set_image(img);
win.add_overlay(dets, rgb_pixel(255, 0, 0));
cin.get();
}
catch (exception& ex)
{
cout << "Exception: " << ex.what() << endl;
cin.get();
}
return 0;
}
我如何知道照片的大小或在显示前将其缩小 2 倍?
【问题讨论】:
标签: c++ face-detection dlib