Skip to content

Commit

Permalink
Ability to not save bad aligned frames (saving space). FaceLandmarkVi…
Browse files Browse the repository at this point in the history
…dMulti not copying the CEN patch experts to save space, allowing it to run on Win32.
  • Loading branch information
TadasBaltrusaitis committed May 22, 2018
1 parent b99a537 commit 881c10d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
6 changes: 3 additions & 3 deletions lib/local/LandmarkDetector/src/CEN_patch_expert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,15 @@

using namespace LandmarkDetector;

// Copy constructor
// Copy constructor (do not perform a deep copy of data as it is very large, also there is no real need to stor the copies
CEN_patch_expert::CEN_patch_expert(const CEN_patch_expert& other) : confidence(other.confidence), width_support(other.width_support), height_support(other.height_support)
{

// Copy the layer weights in a deep way
for (size_t i = 0; i < other.weights.size(); ++i)
{
this->weights.push_back(other.weights[i].clone());
this->biases.push_back(other.biases[i].clone());
this->weights.push_back(other.weights[i]);
this->biases.push_back(other.biases[i]);
this->activation_function.push_back(other.activation_function[i]);
}

Expand Down
7 changes: 6 additions & 1 deletion lib/local/Utilities/include/RecorderOpenFaceParameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ namespace Utilities
RecorderOpenFaceParameters(std::vector<std::string> &arguments, bool sequence, bool is_from_webcam, float fx = -1, float fy = -1, float cx = -1, float cy = -1, double fps_vid_out = 30);
RecorderOpenFaceParameters(bool sequence, bool is_from_webcam, bool output_2D_landmarks, bool output_3D_landmarks,
bool output_model_params, bool output_pose, bool output_AUs, bool output_gaze, bool output_hog, bool output_tracked,
bool output_aligned_faces, float fx = -1, float fy = -1, float cx = -1, float cy = -1, double fps_vid_out = 30);
bool output_aligned_faces, bool record_bad = true, float fx = -1, float fy = -1, float cx = -1, float cy = -1, double fps_vid_out = 30);

bool isSequence() const { return is_sequence; }
bool isFromWebcam() const { return is_from_webcam; }
Expand All @@ -72,6 +72,8 @@ namespace Utilities
std::string outputCodec() const { return output_codec; }
double outputFps() const { return fps_vid_out; }

bool outputBadAligned() const { return record_aligned_bad; }

float getFx() const { return fx; }
float getFy() const { return fy; }
float getCx() const { return cx; }
Expand All @@ -98,6 +100,9 @@ namespace Utilities
bool output_tracked;
bool output_aligned_faces;

// Should the algined faces be recorded even if the detection failed (blank images)
bool record_aligned_bad;

// Some video recording parameters
std::string output_codec;
double fps_vid_out;
Expand Down
7 changes: 5 additions & 2 deletions lib/local/Utilities/src/RecorderOpenFace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,11 @@ void RecorderOpenFace::WriteObservation()

string out_file = aligned_output_directory + preferredSlash + string(name);

aligned_face_queue.push(std::pair<std::string, cv::Mat>(out_file, aligned_face));

if(params.outputBadAligned() || landmark_detection_success)
{
aligned_face_queue.push(std::pair<std::string, cv::Mat>(out_file, aligned_face));
}

// Clear the image
aligned_face = cv::Mat();

Expand Down
8 changes: 7 additions & 1 deletion lib/local/Utilities/src/RecorderOpenFaceParameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,14 @@ RecorderOpenFaceParameters::RecorderOpenFaceParameters(std::vector<std::string>
this->output_tracked = false;
this->output_aligned_faces = false;

this->record_aligned_bad = true;

for (size_t i = 0; i < arguments.size(); ++i)
{
if (arguments[i].compare("-nobadaligned") == 0)
{
this->record_aligned_bad = false;
}
if (arguments[i].compare("-simalign") == 0)
{
this->output_aligned_faces = true;
Expand Down Expand Up @@ -138,7 +144,7 @@ RecorderOpenFaceParameters::RecorderOpenFaceParameters(std::vector<std::string>

RecorderOpenFaceParameters::RecorderOpenFaceParameters(bool sequence, bool is_from_webcam, bool output_2D_landmarks, bool output_3D_landmarks,
bool output_model_params, bool output_pose, bool output_AUs, bool output_gaze, bool output_hog, bool output_tracked,
bool output_aligned_faces, float fx, float fy, float cx, float cy, double fps_vid_out)
bool output_aligned_faces, bool record_bad, float fx, float fy, float cx, float cy, double fps_vid_out)
{
this->is_sequence = sequence;
this->is_from_webcam = is_from_webcam;
Expand Down

0 comments on commit 881c10d

Please sign in to comment.