Use PhotoDetector for more stable processing

This commit is contained in:
Ruben 2017-11-23 23:43:56 +01:00
parent 7445907e56
commit ff4ccd7410

View file

@ -10,6 +10,7 @@
#include "Frame.h"
#include "Face.h"
#include "FrameDetector.h"
#include "PhotoDetector.h"
#include "AffdexException.h"
#include "AFaceListener.hpp"
@ -129,7 +130,7 @@ int main(int argsc, char ** argsv)
namespace po = boost::program_options; // abbreviate namespace
std::cerr << "Hit ESCAPE key to exit app.." << endl;
shared_ptr<FrameDetector> frameDetector;
shared_ptr<PhotoDetector> frameDetector;
try{
@ -208,7 +209,7 @@ int main(int argsc, char ** argsv)
shared_ptr<FaceListener> faceListenPtr(new AFaceListener());
shared_ptr<PlottingImageListener> listenPtr(new PlottingImageListener(csvFileStream, draw_display)); // Instanciate the ImageListener class
shared_ptr<StatusListener> videoListenPtr(new StatusListener());
frameDetector = make_shared<FrameDetector>(buffer_length, process_framerate, nFaces, (affdex::FaceDetectorMode) faceDetectorMode); // Init the FrameDetector Class
frameDetector = make_shared<PhotoDetector>(nFaces, (affdex::FaceDetectorMode) faceDetectorMode); // Init the FrameDetector Class
//Initialize detectors
frameDetector->setDetectAllEmotions(true);
@ -243,6 +244,7 @@ int main(int argsc, char ** argsv)
int frameNrIn = 1;
int frameNrOut = 1;
std::time_t lastImgUpdate(0);
int seconds = 1;
while(true){ //(cv::waitKey(20) != -1);
char buff[100];
snprintf(buff, sizeof(buff), "frame%06d.jpg", frameNrIn);
@ -264,10 +266,11 @@ int main(int argsc, char ** argsv)
//Calculate the Image timestamp and the capture frame rate;
const auto milliseconds = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - start_time);
const double seconds = milliseconds.count() / 1000.f;
//~ const double seconds = milliseconds.count() / 1000.f;
// Create a frame
Frame f(img.size().width, img.size().height, img.data, Frame::COLOR_FORMAT::BGR, seconds);
seconds++;
capture_fps = 1.0f / (seconds - last_timestamp);
last_timestamp = seconds;
frameDetector->process(f); //Pass the frame to detector