Removing unneeded code

This commit is contained in:
Tadas Baltrusaitis 2018-01-24 08:11:44 +00:00
parent d210ccf157
commit 6dae14ac6b
2 changed files with 1 additions and 126 deletions

View file

@ -87,13 +87,8 @@ private:
// The actual descriptors (for visualisation and output)
cv::Mat_<float>* 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<std::string>(directory);
}
void SetupHOGRecording(System::String^ file)
{
// Create the file for recording
hog_output_file->open(msclr::interop::marshal_as<std::string>(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_<float> 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;
}

View file

@ -209,53 +209,6 @@ namespace CppInterop {
return ::LandmarkDetector::DetectLandmarksInImage(image->Mat, bbox, *clnf, *modelParams->getParams());
}
// TODO rem old
List<List<System::Tuple<double,double>^>^>^ DetectMultiFaceLandmarksInImage(OpenCVWrappers::RawImage^ image, FaceModelParameters^ modelParams) {
auto all_landmarks = gcnew List<List<System::Tuple<double,double>^>^>();
// Detect faces in an image
vector<cv::Rect_<double> > face_detections;
vector<double> 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<System::Tuple<double,double>^>();
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<double,double>(clnf->detected_landmarks.at<double>(i,0), clnf->detected_landmarks.at<double>(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<double,double>(clnf->detected_landmarks.at<double>(0,i), clnf->detected_landmarks.at<double>(0,i+1)));
}
}
all_landmarks->Add(landmarks_curr);
}
return all_landmarks;
}
void GetPoseWRTCamera(List<double>^ pose, double fx, double fy, double cx, double cy) {
auto pose_vec = ::LandmarkDetector::GetPoseWRTCamera(*clnf, fx, fy, cx, cy);
pose->Clear();