Output similarity aligned faces through recorder.
This commit is contained in:
parent
db1fef46eb
commit
1159caba75
3 changed files with 41 additions and 25 deletions
|
@ -415,30 +415,6 @@ int main (int argc, char **argv)
|
|||
// Work out the pose of the head from the tracked model
|
||||
cv::Vec6d pose_estimate = LandmarkDetector::GetPose(face_model, fx, fy, cx, cy);
|
||||
|
||||
// TODO move to recorder Write the similarity normalised output
|
||||
//if (!output_similarity_align.empty())
|
||||
//{
|
||||
|
||||
// char name[100];
|
||||
|
||||
// // Filename is based on frame number
|
||||
// std::sprintf(name, "frame_det_%06d.bmp", frame_count + 1);
|
||||
|
||||
// // Construct the output filename
|
||||
// boost::filesystem::path slash("/");
|
||||
|
||||
// std::string preferredSlash = slash.make_preferred().string();
|
||||
|
||||
// string out_file = output_similarity_align[f_n] + preferredSlash + string(name);
|
||||
// bool write_success = imwrite(out_file, sim_warped_img);
|
||||
|
||||
// if (!write_success)
|
||||
// {
|
||||
// cout << "Could not output similarity aligned image image" << endl;
|
||||
// return 1;
|
||||
// }
|
||||
//}
|
||||
|
||||
// Visualising the tracker, TODO this should be in utility
|
||||
if (recording_params.outputTrackedVideo() || (visualize_track && !det_parameters.quiet_mode))
|
||||
{
|
||||
|
|
|
@ -107,6 +107,7 @@ namespace Recorder
|
|||
std::string record_root;
|
||||
std::string filename;
|
||||
std::string csv_filename;
|
||||
std::string aligned_output_directory;
|
||||
|
||||
// The actual output file stream that will be written
|
||||
RecorderCSV csv_recorder;
|
||||
|
@ -143,6 +144,9 @@ namespace Recorder
|
|||
std::string video_filename;
|
||||
cv::Mat vis_to_out;
|
||||
|
||||
// For aligned face writing
|
||||
cv::Mat aligned_face;
|
||||
|
||||
};
|
||||
}
|
||||
#endif
|
|
@ -97,12 +97,26 @@ RecorderOpenFace::RecorderOpenFace(const std::string out_directory, const std::s
|
|||
this->video_filename = (path(record_root) / path(filename).replace_extension(".avi")).string();
|
||||
}
|
||||
|
||||
// TODO aligned Prepare image recording
|
||||
// Prepare image recording
|
||||
if (params.outputAlignedFaces())
|
||||
{
|
||||
aligned_output_directory = (path(record_root) / path(filename + "_aligned")).string();
|
||||
CreateDirectory(aligned_output_directory);
|
||||
}
|
||||
|
||||
|
||||
observation_count = 0;
|
||||
|
||||
}
|
||||
|
||||
// TODO move to actual write
|
||||
void RecorderOpenFace::SetObservationFaceAlign(const cv::Mat& aligned_face)
|
||||
{
|
||||
this->aligned_face = aligned_face;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void RecorderOpenFace::SetObservationVisualization(const cv::Mat &vis_track)
|
||||
{
|
||||
if (params.outputTrackedVideo())
|
||||
|
@ -171,6 +185,28 @@ void RecorderOpenFace::WriteObservation()
|
|||
this->hog_recorder.Write();
|
||||
}
|
||||
|
||||
// Write aligned faces
|
||||
if (params.outputAlignedFaces())
|
||||
{
|
||||
char name[100];
|
||||
|
||||
// Filename is based on frame number
|
||||
std::sprintf(name, "frame_det_%06d.bmp", observation_count);
|
||||
|
||||
// Construct the output filename
|
||||
boost::filesystem::path slash("/");
|
||||
|
||||
std::string preferredSlash = slash.make_preferred().string();
|
||||
|
||||
string out_file = aligned_output_directory + preferredSlash + string(name);
|
||||
bool write_success = cv::imwrite(out_file, aligned_face);
|
||||
|
||||
if (!write_success)
|
||||
{
|
||||
WARN_STREAM("Could not output similarity aligned image image");
|
||||
}
|
||||
}
|
||||
|
||||
if(params.outputTrackedVideo())
|
||||
{
|
||||
if (vis_to_out.empty())
|
||||
|
|
Loading…
Reference in a new issue