From 6dae14ac6b90afebf2c5e840ca6424fea80d6b7f Mon Sep 17 00:00:00 2001 From: Tadas Baltrusaitis Date: Wed, 24 Jan 2018 08:11:44 +0000 Subject: [PATCH] Removing unneeded code --- lib/local/CppInerop/FaceAnalyserInterop.h | 80 +------------------ lib/local/CppInerop/LandmarkDetectorInterop.h | 47 ----------- 2 files changed, 1 insertion(+), 126 deletions(-) diff --git a/lib/local/CppInerop/FaceAnalyserInterop.h b/lib/local/CppInerop/FaceAnalyserInterop.h index 4030f8a..a3a9026 100644 --- a/lib/local/CppInerop/FaceAnalyserInterop.h +++ b/lib/local/CppInerop/FaceAnalyserInterop.h @@ -87,13 +87,8 @@ private: // The actual descriptors (for visualisation and output) cv::Mat_* hog_features; cv::Mat* aligned_face; - - // Variables used for recording things - std::ofstream* hog_output_file; - std::string* align_output_dir; int* num_rows; int* num_cols; - bool* good_frame; public: @@ -117,74 +112,6 @@ public: num_rows = new int; num_cols = new int; - good_frame = new bool; - - align_output_dir = new string(); - - hog_output_file = new std::ofstream(); - - } - - void SetupAlignedImageRecording(System::String^ directory) - { - *align_output_dir = msclr::interop::marshal_as(directory); - } - - void SetupHOGRecording(System::String^ file) - { - // Create the file for recording - hog_output_file->open(msclr::interop::marshal_as(file), ios_base::out | ios_base::binary); - } - - void StopHOGRecording() - { - hog_output_file->close(); - } - - void RecordAlignedFrame(int frame_num) - { - char name[100]; - - // output the frame number - sprintf(name, "frame_det_%06d.bmp", frame_num); - - string out_file = (boost::filesystem::path(*align_output_dir) / boost::filesystem::path(name)).string(); - imwrite(out_file, *aligned_face); - } - - void RecordHOGFrame() - { - // Using FHOGs, hence 31 channels - int num_channels = 31; - - hog_output_file->write((char*)(num_cols), 4); - hog_output_file->write((char*)(num_rows), 4); - hog_output_file->write((char*)(&num_channels), 4); - - // Not the best way to store a bool, but will be much easier to read it - float good_frame_float; - if(good_frame) - good_frame_float = 1; - else - good_frame_float = -1; - - hog_output_file->write((char*)(&good_frame_float), 4); - - cv::MatConstIterator_ descriptor_it = hog_features->begin(); - - for(int y = 0; y < *num_cols; ++y) - { - for(int x = 0; x < *num_rows; ++x) - { - for(unsigned int o = 0; o < 31; ++o) - { - - float hog_data = (*descriptor_it++); - hog_output_file->write((char*)&hog_data, 4); - } - } - } - } void PostProcessOutputFile(System::String^ file) @@ -211,9 +138,7 @@ public: hog_d.convertTo(*hog_features, CV_64F); face_analyser->GetLatestAlignedFace(*aligned_face); - - *good_frame = success; - + } // Predicting AUs from a single image @@ -354,9 +279,6 @@ public: delete aligned_face; delete num_cols; delete num_rows; - delete hog_output_file; - delete good_frame; - delete align_output_dir; delete face_analyser; } diff --git a/lib/local/CppInerop/LandmarkDetectorInterop.h b/lib/local/CppInerop/LandmarkDetectorInterop.h index 474a670..8a65fec 100644 --- a/lib/local/CppInerop/LandmarkDetectorInterop.h +++ b/lib/local/CppInerop/LandmarkDetectorInterop.h @@ -209,53 +209,6 @@ namespace CppInterop { return ::LandmarkDetector::DetectLandmarksInImage(image->Mat, bbox, *clnf, *modelParams->getParams()); } - // TODO rem old - List^>^>^ DetectMultiFaceLandmarksInImage(OpenCVWrappers::RawImage^ image, FaceModelParameters^ modelParams) { - - auto all_landmarks = gcnew List^>^>(); - - // Detect faces in an image - vector > face_detections; - - vector confidences; - - // TODO this should be pre-allocated as now it might be a bit too slow - dlib::frontal_face_detector face_detector_hog = dlib::get_frontal_face_detector(); - - ::LandmarkDetector::DetectFacesHOG(face_detections, image->Mat, face_detector_hog, confidences); - - // Detect landmarks around detected faces - int face_det = 0; - // perform landmark detection for every face detected - for(size_t face=0; face < face_detections.size(); ++face) - { - // if there are multiple detections go through them - bool success = ::LandmarkDetector::DetectLandmarksInImage(image->Mat, face_detections[face], *clnf, *modelParams->getParams()); - - auto landmarks_curr = gcnew List^>(); - if(clnf->detected_landmarks.cols == 1) - { - int n = clnf->detected_landmarks.rows / 2; - for(int i = 0; i < n; ++i) - { - landmarks_curr->Add(gcnew System::Tuple(clnf->detected_landmarks.at(i,0), clnf->detected_landmarks.at(i+n,0))); - } - } - else - { - int n = clnf->detected_landmarks.cols / 2; - for(int i = 0; i < clnf->detected_landmarks.cols; ++i) - { - landmarks_curr->Add(gcnew System::Tuple(clnf->detected_landmarks.at(0,i), clnf->detected_landmarks.at(0,i+1))); - } - } - all_landmarks->Add(landmarks_curr); - - } - - return all_landmarks; - } - void GetPoseWRTCamera(List^ pose, double fx, double fy, double cx, double cy) { auto pose_vec = ::LandmarkDetector::GetPoseWRTCamera(*clnf, fx, fy, cx, cy); pose->Clear();