From eb5a2ed01f9dd18e8dc01dc202870fa1857236bc Mon Sep 17 00:00:00 2001 From: Tadas Baltrusaitis Date: Sat, 27 Jan 2018 11:12:00 +0000 Subject: [PATCH] Adding mirror image support. --- gui/HeadPose-live/MainWindow.xaml.cs | 11 ++++++----- lib/local/CppInerop/OpenCVWrappers.h | 5 +++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/gui/HeadPose-live/MainWindow.xaml.cs b/gui/HeadPose-live/MainWindow.xaml.cs index 4632f50..da63b89 100644 --- a/gui/HeadPose-live/MainWindow.xaml.cs +++ b/gui/HeadPose-live/MainWindow.xaml.cs @@ -384,22 +384,23 @@ namespace HeadPoseLive // CAPTURE FRAME AND DETECT LANDMARKS FOLLOWED BY THE REQUIRED IMAGE PROCESSING ////////////////////////////////////////////// - RawImage frame = null; - frame = reader.GetNextImage(); + RawImage frame = reader.GetNextImage(); lastFrameTime = CurrentTime; processing_fps.AddFrame(); var grayFrame = reader.GetCurrentFrameGray(); - if (grayFrame == null) - continue; + if (mirror_image) + { + frame.Mirror(); + grayFrame.Mirror(); + } bool detectionSucceeding = ProcessFrame(face_model, gaze_analyser, model_params, frame, grayFrame, reader.GetFx(), reader.GetFy(), reader.GetCx(), reader.GetCy()); lock (recording_lock) { - if (recording) { // Add objects to recording queues diff --git a/lib/local/CppInerop/OpenCVWrappers.h b/lib/local/CppInerop/OpenCVWrappers.h index 27c3e9a..d645897 100644 --- a/lib/local/CppInerop/OpenCVWrappers.h +++ b/lib/local/CppInerop/OpenCVWrappers.h @@ -136,6 +136,11 @@ namespace OpenCVWrappers { refCount++; } + void Mirror() + { + cv::flip(*mat, *mat, 1); + } + // Finalizer. Definitely called before Garbage Collection, // but not automatically called on explicit Dispose(). // May be called multiple times.