From 488cd4d92f8cf3921c70b78b87d4d6007785f7bf Mon Sep 17 00:00:00 2001 From: Tadas Baltrusaitis Date: Sun, 19 Nov 2017 20:04:00 +0000 Subject: [PATCH] Bug fixes with image readers. --- exe/FaceLandmarkImg/FaceLandmarkImg.cpp | 6 ++---- lib/local/Utilities/src/ImageCapture.cpp | 13 ++++++++----- .../Feature Point Experiments/Run_OF_on_images.m | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/exe/FaceLandmarkImg/FaceLandmarkImg.cpp b/exe/FaceLandmarkImg/FaceLandmarkImg.cpp index c103d74..e03e0a5 100644 --- a/exe/FaceLandmarkImg/FaceLandmarkImg.cpp +++ b/exe/FaceLandmarkImg/FaceLandmarkImg.cpp @@ -160,8 +160,6 @@ int main (int argc, char **argv) // Load the models if images found LandmarkDetector::FaceModelParameters det_parameters(arguments); - // No need to validate detections, as we're not doing tracking - det_parameters.validate_detections = false; // The modules that are being used for tracking cout << "Loading the model" << endl; @@ -256,8 +254,8 @@ int main (int argc, char **argv) // Displaying the tracking visualizations visualizer.SetObservationFaceAlign(sim_warped_img); visualizer.SetObservationHOG(hog_descriptor, num_hog_rows, num_hog_cols); - visualizer.SetObservationLandmarks(face_model.detected_landmarks, face_model.detection_certainty, face_model.detection_success); - visualizer.SetObservationPose(pose_estimate, face_model.detection_certainty); + visualizer.SetObservationLandmarks(face_model.detected_landmarks, 1.0, face_model.detection_success); // Set confidence to high to make sure we always visualize + visualizer.SetObservationPose(pose_estimate, 1.0); visualizer.SetObservationGaze(gaze_direction0, gaze_direction1, LandmarkDetector::CalculateAllEyeLandmarks(face_model), LandmarkDetector::Calculate3DEyeLandmarks(face_model, image_reader.fx, image_reader.fy, image_reader.cx, image_reader.cy), face_model.detection_certainty); // Setting up the recorder output diff --git a/lib/local/Utilities/src/ImageCapture.cpp b/lib/local/Utilities/src/ImageCapture.cpp index ff17de6..550af6b 100644 --- a/lib/local/Utilities/src/ImageCapture.cpp +++ b/lib/local/Utilities/src/ImageCapture.cpp @@ -369,18 +369,19 @@ void ImageCapture::SetCameraIntrinsics(float fx, float fy, float cx, float cy) cv::Mat ImageCapture::GetNextImage() { - frame_num++; - if (image_files.empty() || frame_num - 1 > image_files.size()) + if (image_files.empty() || frame_num >= image_files.size()) { // Indicate lack of success by returning an empty image latest_frame = cv::Mat(); + return latest_frame; } - - latest_frame = cv::imread(image_files[frame_num - 1], -1); + + latest_frame = cv::imread(image_files[frame_num], -1); if (latest_frame.empty()) { ERROR_STREAM("Could not open the image: " + image_files[frame_num - 1]); + exit(1); } image_height = latest_frame.size().height; @@ -395,7 +396,9 @@ cv::Mat ImageCapture::GetNextImage() // Set the grayscale frame convertToGrayscale(latest_frame, latest_gray_frame); - this->name = boost::filesystem::path(image_files[frame_num - 1]).filename().replace_extension("").string(); + this->name = boost::filesystem::path(image_files[frame_num]).filename().replace_extension("").string(); + + frame_num++; return latest_frame; } diff --git a/matlab_runners/Feature Point Experiments/Run_OF_on_images.m b/matlab_runners/Feature Point Experiments/Run_OF_on_images.m index 54000c5..c86904b 100644 --- a/matlab_runners/Feature Point Experiments/Run_OF_on_images.m +++ b/matlab_runners/Feature Point Experiments/Run_OF_on_images.m @@ -44,7 +44,7 @@ else multi_view = 0; end -command = sprintf("%s -mloc %s -multiview %s -2Dfp -tracked ", executable, model, num2str(multi_view)); +command = sprintf("%s -mloc %s -multi_view %s -2Dfp -tracked ", executable, model, num2str(multi_view)); % TODO just landmarks + BBoxes