Outputing images properly and out_dir should be the main way to specify output directory
This commit is contained in:
parent
dcb9d90eca
commit
fc187498e8
3 changed files with 28 additions and 20 deletions
|
@ -144,7 +144,7 @@ namespace Utilities
|
||||||
|
|
||||||
// For video writing
|
// For video writing
|
||||||
cv::VideoWriter video_writer;
|
cv::VideoWriter video_writer;
|
||||||
std::string video_filename;
|
std::string media_filename;
|
||||||
cv::Mat vis_to_out;
|
cv::Mat vis_to_out;
|
||||||
|
|
||||||
// For aligned face writing
|
// For aligned face writing
|
||||||
|
|
|
@ -63,7 +63,7 @@ namespace Utilities
|
||||||
bool outputAUs() const { return output_AUs; }
|
bool outputAUs() const { return output_AUs; }
|
||||||
bool outputGaze() const { return output_gaze; }
|
bool outputGaze() const { return output_gaze; }
|
||||||
bool outputHOG() const { return output_hog; }
|
bool outputHOG() const { return output_hog; }
|
||||||
bool outputTrackedVideo() const { return output_tracked_video; }
|
bool outputTracked() const { return output_tracked; }
|
||||||
bool outputAlignedFaces() const { return output_aligned_faces; }
|
bool outputAlignedFaces() const { return output_aligned_faces; }
|
||||||
std::string outputCodec() const { return output_codec; }
|
std::string outputCodec() const { return output_codec; }
|
||||||
double outputFps() const { return fps_vid_out; }
|
double outputFps() const { return fps_vid_out; }
|
||||||
|
@ -81,7 +81,7 @@ namespace Utilities
|
||||||
bool output_AUs;
|
bool output_AUs;
|
||||||
bool output_gaze;
|
bool output_gaze;
|
||||||
bool output_hog;
|
bool output_hog;
|
||||||
bool output_tracked_video;
|
bool output_tracked;
|
||||||
bool output_aligned_faces;
|
bool output_aligned_faces;
|
||||||
|
|
||||||
// Some video recording parameters
|
// Some video recording parameters
|
||||||
|
|
|
@ -86,21 +86,13 @@ RecorderOpenFace::RecorderOpenFace(const std::string in_filename, RecorderOpenFa
|
||||||
valid[i] = true;
|
valid[i] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < arguments.size(); ++i)
|
|
||||||
{
|
|
||||||
if (arguments[i].compare("-outroot") == 0)
|
|
||||||
{
|
|
||||||
record_root = arguments[i + 1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Determine output directory
|
// Determine output directory
|
||||||
bool output_found = false;
|
bool output_found = false;
|
||||||
for (size_t i = 0; i < arguments.size(); ++i)
|
for (size_t i = 0; i < arguments.size(); ++i)
|
||||||
{
|
{
|
||||||
if (arguments[i].compare("-out_dir") == 0)
|
if (arguments[i].compare("-out_dir") == 0)
|
||||||
{
|
{
|
||||||
record_root = (boost::filesystem::path(record_root) / boost::filesystem::path(arguments[i + 1])).string();
|
record_root = arguments[i + 1];
|
||||||
}
|
}
|
||||||
else if (!output_found && arguments[i].compare("-of") == 0)
|
else if (!output_found && arguments[i].compare("-of") == 0)
|
||||||
{
|
{
|
||||||
|
@ -152,16 +144,17 @@ RecorderOpenFace::RecorderOpenFace(const std::string in_filename, RecorderOpenFa
|
||||||
}
|
}
|
||||||
|
|
||||||
// saving the videos
|
// saving the videos
|
||||||
if (params.outputTrackedVideo())
|
if (params.outputTracked())
|
||||||
{
|
{
|
||||||
this->video_filename = (path(record_root) / path(filename).replace_extension(".avi")).string();
|
|
||||||
if(parameters.isSequence())
|
if(parameters.isSequence())
|
||||||
{
|
{
|
||||||
metadata_file << "Output video:" << this->video_filename << endl;
|
this->media_filename = (path(record_root) / path(filename).replace_extension(".avi")).string();
|
||||||
|
metadata_file << "Output video:" << this->media_filename << endl;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
metadata_file << "Output image:" << this->video_filename << endl;
|
this->media_filename = (path(record_root) / path(filename).replace_extension(".bmp")).string();
|
||||||
|
metadata_file << "Output image:" << this->media_filename << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,7 +178,7 @@ void RecorderOpenFace::SetObservationFaceAlign(const cv::Mat& aligned_face)
|
||||||
|
|
||||||
void RecorderOpenFace::SetObservationVisualization(const cv::Mat &vis_track)
|
void RecorderOpenFace::SetObservationVisualization(const cv::Mat &vis_track)
|
||||||
{
|
{
|
||||||
if (params.outputTrackedVideo())
|
if (params.outputTracked())
|
||||||
{
|
{
|
||||||
// Initialize the video writer if it has not been opened yet
|
// Initialize the video writer if it has not been opened yet
|
||||||
if(!video_writer.isOpened())
|
if(!video_writer.isOpened())
|
||||||
|
@ -256,7 +249,10 @@ void RecorderOpenFace::WriteObservation()
|
||||||
char name[100];
|
char name[100];
|
||||||
|
|
||||||
// Filename is based on frame number
|
// Filename is based on frame number
|
||||||
std::sprintf(name, "frame_det_%06d.bmp", observation_count);
|
if(params.isSequence())
|
||||||
|
std::sprintf(name, "frame_det_%06d.bmp", observation_count);
|
||||||
|
else
|
||||||
|
std::sprintf(name, "face_det_%06d.bmp", observation_count);
|
||||||
|
|
||||||
// Construct the output filename
|
// Construct the output filename
|
||||||
boost::filesystem::path slash("/");
|
boost::filesystem::path slash("/");
|
||||||
|
@ -272,13 +268,25 @@ void RecorderOpenFace::WriteObservation()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(params.outputTrackedVideo())
|
if(params.outputTracked())
|
||||||
{
|
{
|
||||||
if (vis_to_out.empty())
|
if (vis_to_out.empty())
|
||||||
{
|
{
|
||||||
WARN_STREAM("Output tracked video frame is not set");
|
WARN_STREAM("Output tracked video frame is not set");
|
||||||
}
|
}
|
||||||
video_writer.write(vis_to_out);
|
|
||||||
|
if(video_writer.isOpened())
|
||||||
|
{
|
||||||
|
video_writer.write(vis_to_out);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bool out_success = cv::imwrite(media_filename, vis_to_out);
|
||||||
|
if (!out_success)
|
||||||
|
{
|
||||||
|
WARN_STREAM("Could not output tracked image");
|
||||||
|
}
|
||||||
|
}
|
||||||
// Clear the output
|
// Clear the output
|
||||||
vis_to_out = cv::Mat();
|
vis_to_out = cv::Mat();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue