I'm writing an app that detects a face and frames it. For better recognition, I increase the photo 2 times and when I display it, it turns out 2 times more than initially, how to reduce it 2 times? The window has the resize () method, but to use it you need to know the initial size of the photo, but I do not know how.
#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;
}
How do I know the size of a photo or reduce it 2 times before displaying?