Some more bug fixes with visualization and recording. Creating a metafile for recorded data.
This commit is contained in:
parent
fd4d06166a
commit
bee6d185cb
6 changed files with 142 additions and 82 deletions
|
@ -206,7 +206,7 @@ int main (int argc, char **argv)
|
||||||
visualizer.SetObservationHOG(hog_descriptor, num_hog_rows, num_hog_cols);
|
visualizer.SetObservationHOG(hog_descriptor, num_hog_rows, num_hog_cols);
|
||||||
visualizer.SetObservationLandmarks(face_model.detected_landmarks, face_model.detection_certainty, detection_success);
|
visualizer.SetObservationLandmarks(face_model.detected_landmarks, face_model.detection_certainty, detection_success);
|
||||||
visualizer.SetObservationPose(pose_estimate, face_model.detection_certainty);
|
visualizer.SetObservationPose(pose_estimate, face_model.detection_certainty);
|
||||||
visualizer.SetObservationGaze(gazeDirection0, gazeDirection1, gazeAngle, LandmarkDetector::CalculateAllEyeLandmarks(face_model), LandmarkDetector::Calculate3DEyeLandmarks(face_model, sequence_reader.fx, sequence_reader.fy, sequence_reader.cx, sequence_reader.cy));
|
visualizer.SetObservationGaze(gazeDirection0, gazeDirection1, gazeAngle, LandmarkDetector::CalculateAllEyeLandmarks(face_model), LandmarkDetector::Calculate3DEyeLandmarks(face_model, sequence_reader.fx, sequence_reader.fy, sequence_reader.cx, sequence_reader.cy), face_model.detection_certainty);
|
||||||
visualizer.ShowObservation();
|
visualizer.ShowObservation();
|
||||||
|
|
||||||
// Setting up the recorder output
|
// Setting up the recorder output
|
||||||
|
|
|
@ -105,9 +105,11 @@ namespace Utilities
|
||||||
|
|
||||||
// Keep track of the file and output root location
|
// Keep track of the file and output root location
|
||||||
std::string record_root = "processed"; // By default we are writing in the processed directory in the working directory
|
std::string record_root = "processed"; // By default we are writing in the processed directory in the working directory
|
||||||
|
std::string of_filename;
|
||||||
std::string filename;
|
std::string filename;
|
||||||
std::string csv_filename;
|
std::string csv_filename;
|
||||||
std::string aligned_output_directory;
|
std::string aligned_output_directory;
|
||||||
|
std::ofstream metadata_file;
|
||||||
|
|
||||||
// The actual output file stream that will be written
|
// The actual output file stream that will be written
|
||||||
RecorderCSV csv_recorder;
|
RecorderCSV csv_recorder;
|
||||||
|
|
|
@ -72,7 +72,7 @@ namespace Utilities
|
||||||
void SetObservationPose(const cv::Vec6d& pose, double confidence);
|
void SetObservationPose(const cv::Vec6d& pose, double confidence);
|
||||||
|
|
||||||
// Gaze related observations
|
// Gaze related observations
|
||||||
void SetObservationGaze(const cv::Point3f& gazeDirection0, const cv::Point3f& gazeDirection1, const cv::Vec2d& gaze_angle, const std::vector<cv::Point2d>& eye_landmarks, const std::vector<cv::Point3d>& eye_landmarks3d);
|
void SetObservationGaze(const cv::Point3f& gazeDirection0, const cv::Point3f& gazeDirection1, const cv::Vec2d& gaze_angle, const std::vector<cv::Point2d>& eye_landmarks, const std::vector<cv::Point3d>& eye_landmarks3d, double confidence);
|
||||||
|
|
||||||
// Face alignment related observations
|
// Face alignment related observations
|
||||||
void SetObservationFaceAlign(const cv::Mat& aligned_face);
|
void SetObservationFaceAlign(const cv::Mat& aligned_face);
|
||||||
|
@ -89,6 +89,9 @@ namespace Utilities
|
||||||
bool vis_hog;
|
bool vis_hog;
|
||||||
bool vis_align;
|
bool vis_align;
|
||||||
|
|
||||||
|
// Can be adjusted to show less confident frames
|
||||||
|
double visualisation_boundary = 0.4;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
// Temporary variables for visualization
|
// Temporary variables for visualization
|
||||||
|
|
|
@ -77,32 +77,80 @@ RecorderOpenFace::RecorderOpenFace(const std::string in_filename, RecorderOpenFa
|
||||||
// From the filename, strip out the name without directory and extension
|
// From the filename, strip out the name without directory and extension
|
||||||
filename = path(in_filename).replace_extension("").filename().string();
|
filename = path(in_filename).replace_extension("").filename().string();
|
||||||
|
|
||||||
|
// Consuming the input arguments
|
||||||
|
bool* valid = new bool[arguments.size()];
|
||||||
|
|
||||||
|
for (size_t i = 0; i < arguments.size(); ++i)
|
||||||
|
{
|
||||||
|
valid[i] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
string record_root;
|
||||||
|
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;
|
||||||
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 = arguments[i + 1];
|
record_root = (boost::filesystem::path(record_root) / boost::filesystem::path(arguments[i + 1])).string();
|
||||||
|
}
|
||||||
|
else if (!output_found && arguments[i].compare("-of") == 0)
|
||||||
|
{
|
||||||
|
record_root = (boost::filesystem::path(record_root) / boost::filesystem::path(arguments[i + 1])).remove_filename().string();
|
||||||
|
filename = path(boost::filesystem::path(arguments[i + 1])).replace_extension("").filename().string();
|
||||||
|
valid[i] = false;
|
||||||
|
valid[i + 1] = false;
|
||||||
|
i++;
|
||||||
|
output_found = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = (int)arguments.size() - 1; i >= 0; --i)
|
||||||
|
{
|
||||||
|
if (!valid[i])
|
||||||
|
{
|
||||||
|
arguments.erase(arguments.begin() + i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Construct the directories required for the output
|
// Construct the directories required for the output
|
||||||
CreateDirectory(record_root);
|
CreateDirectory(record_root);
|
||||||
|
|
||||||
|
// Create the filename for the general output file that contains all of the meta information about the recording
|
||||||
|
path of_det_name(filename);
|
||||||
|
of_det_name = path(record_root) / of_det_name.concat("_of_details.txt");
|
||||||
|
|
||||||
|
// Write in the of file what we are outputing what is the input etc.
|
||||||
|
metadata_file.open(of_det_name.string(), std::ios_base::out);
|
||||||
|
|
||||||
|
// Populate the metadata file
|
||||||
|
metadata_file << "Input:" << in_filename << endl;
|
||||||
|
|
||||||
// Create the required individual recorders, CSV, HOG, aligned, video
|
// Create the required individual recorders, CSV, HOG, aligned, video
|
||||||
csv_filename = (path(record_root) / path(filename).replace_extension(".csv")).string();
|
csv_filename = (path(record_root) / path(filename).replace_extension(".csv")).string();
|
||||||
|
metadata_file << "Output csv:" << csv_filename << endl;
|
||||||
|
|
||||||
// Consruct HOG recorder here
|
// Consruct HOG recorder here
|
||||||
if(params.outputHOG())
|
if(params.outputHOG())
|
||||||
{
|
{
|
||||||
std::string hog_filename = (path(record_root) / path(filename).replace_extension(".hog")).string();
|
std::string hog_filename = (path(record_root) / path(filename).replace_extension(".hog")).string();
|
||||||
hog_recorder.Open(hog_filename);
|
hog_recorder.Open(hog_filename);
|
||||||
|
metadata_file << "Output HOG:" << csv_filename << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// saving the videos
|
// saving the videos
|
||||||
if (params.outputTrackedVideo())
|
if (params.outputTrackedVideo())
|
||||||
{
|
{
|
||||||
this->video_filename = (path(record_root) / path(filename).replace_extension(".avi")).string();
|
this->video_filename = (path(record_root) / path(filename).replace_extension(".avi")).string();
|
||||||
|
metadata_file << "Output video:" << this->video_filename << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prepare image recording
|
// Prepare image recording
|
||||||
|
@ -110,6 +158,7 @@ RecorderOpenFace::RecorderOpenFace(const std::string in_filename, RecorderOpenFa
|
||||||
{
|
{
|
||||||
aligned_output_directory = (path(record_root) / path(filename + "_aligned")).string();
|
aligned_output_directory = (path(record_root) / path(filename + "_aligned")).string();
|
||||||
CreateDirectory(aligned_output_directory);
|
CreateDirectory(aligned_output_directory);
|
||||||
|
metadata_file << "Output aligned directory:" << this->aligned_output_directory << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -279,6 +328,8 @@ void RecorderOpenFace::Close()
|
||||||
hog_recorder.Close();
|
hog_recorder.Close();
|
||||||
csv_recorder.Close();
|
csv_recorder.Close();
|
||||||
video_writer.release();
|
video_writer.release();
|
||||||
|
metadata_file.close();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -109,6 +109,8 @@ void Visualizer::SetObservationHOG(const cv::Mat_<double>& hog_descriptor, int n
|
||||||
void Visualizer::SetObservationLandmarks(const cv::Mat_<double>& landmarks_2D, double confidence, bool success, const cv::Mat_<int>& visibilities)
|
void Visualizer::SetObservationLandmarks(const cv::Mat_<double>& landmarks_2D, double confidence, bool success, const cv::Mat_<int>& visibilities)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if(confidence > visualisation_boundary)
|
||||||
|
{
|
||||||
// Draw 2D landmarks on the image
|
// Draw 2D landmarks on the image
|
||||||
int n = landmarks_2D.rows / 2;
|
int n = landmarks_2D.rows / 2;
|
||||||
|
|
||||||
|
@ -129,11 +131,12 @@ void Visualizer::SetObservationLandmarks(const cv::Mat_<double>& landmarks_2D, d
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Visualizer::SetObservationPose(const cv::Vec6d& pose, double confidence)
|
void Visualizer::SetObservationPose(const cv::Vec6d& pose, double confidence)
|
||||||
{
|
{
|
||||||
|
|
||||||
double visualisation_boundary = 0.4;
|
|
||||||
|
|
||||||
// Only draw if the reliability is reasonable, the value is slightly ad-hoc
|
// Only draw if the reliability is reasonable, the value is slightly ad-hoc
|
||||||
if (confidence > visualisation_boundary)
|
if (confidence > visualisation_boundary)
|
||||||
|
@ -154,9 +157,10 @@ void Visualizer::SetObservationPose(const cv::Vec6d& pose, double confidence)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Eye gaze infomration drawing, first of eye landmarks then of gaze
|
// Eye gaze infomration drawing, first of eye landmarks then of gaze
|
||||||
void Visualizer::SetObservationGaze(const cv::Point3f& gaze_direction0, const cv::Point3f& gaze_direction1, const cv::Vec2d& gaze_angle, const std::vector<cv::Point2d>& eye_landmarks2d, const std::vector<cv::Point3d>& eye_landmarks3d)
|
void Visualizer::SetObservationGaze(const cv::Point3f& gaze_direction0, const cv::Point3f& gaze_direction1, const cv::Vec2d& gaze_angle, const std::vector<cv::Point2d>& eye_landmarks2d, const std::vector<cv::Point3d>& eye_landmarks3d, double confidence)
|
||||||
|
{
|
||||||
|
if(confidence > visualisation_boundary)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (eye_landmarks2d.size() > 0)
|
if (eye_landmarks2d.size() > 0)
|
||||||
{
|
{
|
||||||
// First draw the eye region landmarks
|
// First draw the eye region landmarks
|
||||||
|
@ -225,7 +229,7 @@ void Visualizer::SetObservationGaze(const cv::Point3f& gaze_direction0, const cv
|
||||||
cv::Point(cvRound(proj_points.at<double>(1, 0) * (double)draw_multiplier), cvRound(proj_points.at<double>(1, 1) * (double)draw_multiplier)), cv::Scalar(110, 220, 0), 2, CV_AA, draw_shiftbits);
|
cv::Point(cvRound(proj_points.at<double>(1, 0) * (double)draw_multiplier), cvRound(proj_points.at<double>(1, 1) * (double)draw_multiplier)), cv::Scalar(110, 220, 0), 2, CV_AA, draw_shiftbits);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Visualizer::ShowObservation()
|
void Visualizer::ShowObservation()
|
||||||
|
|
|
@ -14,7 +14,7 @@ dbSeqDir = dbSeqDir(3:end);
|
||||||
|
|
||||||
output_dir = cat(2, output_dir, '/');
|
output_dir = cat(2, output_dir, '/');
|
||||||
|
|
||||||
command = sprintf('%s -inroot "%s" -out_dir "%s" -fx 505 -fy 505 -cx 320 -cy 240 -pose -vis-track ', executable, rootDir, output_dir);
|
command = sprintf('%s -inroot "%s" -outroot "%s" -fx 505 -fy 505 -cx 320 -cy 240 -pose -vis-track ', executable, rootDir, output_dir);
|
||||||
|
|
||||||
if(verbose)
|
if(verbose)
|
||||||
command = cat(2, command, [' -tracked ' outputVideo]);
|
command = cat(2, command, [' -tracked ' outputVideo]);
|
||||||
|
@ -26,7 +26,7 @@ end
|
||||||
|
|
||||||
for i=1:numel(dbSeqDir)
|
for i=1:numel(dbSeqDir)
|
||||||
inputFile = [biwiDir dbSeqDir(i).name '/colour.avi'];
|
inputFile = [biwiDir dbSeqDir(i).name '/colour.avi'];
|
||||||
command = cat(2, command, sprintf(' -f "%s" ', inputFile));
|
command = sprintf('%s -f "%s" -of "%s" ', command, inputFile, dbSeqDir(i).name);
|
||||||
end
|
end
|
||||||
|
|
||||||
if(isunix)
|
if(isunix)
|
||||||
|
|
Loading…
Reference in a new issue