4 #include <opencv2/opencv.hpp>
5 #include "VisageFeaturesDetector.h"
6 #include "visageVision.h"
8 #include "VisageDrawing.h"
9 #include "LicenseString.h"
12 #define MAX_IMAGE_SIZE 1000.0f
40 frame = imread(fileName);
44 printf(
"Cannot open %s\n",fileName);
47 cvtColor(frame, frame, COLOR_BGR2RGB);
49 Mat logo = imread(
"../Linux/data/images/logo.png", IMREAD_UNCHANGED);
52 if( frame.size().height > MAX_IMAGE_SIZE || frame.size().width > MAX_IMAGE_SIZE )
55 if( frame.size().height >= frame.size().width )
56 step = MAX_IMAGE_SIZE/
static_cast<float>(frame.size().height);
58 step = MAX_IMAGE_SIZE/
static_cast<float>(frame.size().width);
59 int w =
static_cast<int>(
static_cast<float>(frame.size().width)*step);
60 int h =
static_cast<int>(
static_cast<float>(frame.size().height)*step);
61 resize(frame, frame_resized, Size(w,h));
63 else frame_resized = frame;
70 VsImage* frame_resized_vs = vsCreateImageHeader(vsSize(frame_resized.size().width, frame_resized.size().height), VS_DEPTH_8U, frame_resized.channels());
71 vsSetImageData(frame_resized_vs, frame_resized.data, frame_resized.size().width * frame_resized.channels());
78 for(
int i = 0; i < value; i++)
80 char tmpFileName[200];
81 strcpy(tmpFileName,fileName);
82 if(strlen(tmpFileName)>4)
84 tmpFileName[strlen(tmpFileName)-4] = 0;
87 sprintf(idx,
"%d", i);
88 strcat(tmpFileName,
"_");
89 strcat(tmpFileName, idx);
90 strcat(tmpFileName,
".fdp");
93 VisageDrawing::drawResults(frame_resized, &data[i]);
94 cvtColor(frame_resized, imageBGRA, COLOR_BGR2BGRA);
96 VisageDrawing::drawLogo(imageBGRA, logo);
101 vsReleaseImageHeader(&frame_resized_vs);
107 const char help[500] = \
109 "./runDetector imageName.jpg\n" \
110 "*Working directory is being set to Samples/data folder*";
211 int main(
int argc,
const char* argv[] ){
213 initializeLicenseManager(licenseKey.c_str());
216 if (chdir(
"../Samples/data")!=0){
217 printf(
"Unable to change current directory.");
224 char imageName[200] =
"../Linux/data/images/faces1.jpg";
228 printf(
"Default image will be used - faces1.jpg\n");
231 printf(
"Detecting faces on %s ...\n",argv[1]);
232 strcpy(imageName,argv[1]);
236 printf(
"Could not load required data files.\n");
240 if (detected.empty())
242 namedWindow(
"FaceDetector");
243 imshow(
"FaceDetector", detected);
245 destroyWindow(
"FaceDetector");