diff --git a/gui/OpenFaceOffline/MainWindow.xaml.cs b/gui/OpenFaceOffline/MainWindow.xaml.cs index e63d6a8..04ffb30 100644 --- a/gui/OpenFaceOffline/MainWindow.xaml.cs +++ b/gui/OpenFaceOffline/MainWindow.xaml.cs @@ -458,10 +458,12 @@ namespace OpenFaceOffline recorder.SetObservationFaceAlign(face_analyser.GetLatestAlignedFace()); + var hog_feature = face_analyser.GetLatestHOGFeature(); + //open_face_rec.SetObservationHOG(face_model.detection_success, hog_descriptor, num_hog_rows, num_hog_cols, 31); // The number of channels in HOG is fixed at the moment, as using FHOG + recorder.WriteObservation(); // TODO - //open_face_rec.SetObservationHOG(face_model.detection_success, hog_descriptor, num_hog_rows, num_hog_cols, 31); // The number of channels in HOG is fixed at the moment, as using FHOG //open_face_rec.SetObservationVisualization(visualizer.GetVisImage()); } diff --git a/lib/local/CppInerop/FaceAnalyserInterop.h b/lib/local/CppInerop/FaceAnalyserInterop.h index f7aa0d8..efd74f2 100644 --- a/lib/local/CppInerop/FaceAnalyserInterop.h +++ b/lib/local/CppInerop/FaceAnalyserInterop.h @@ -85,7 +85,7 @@ private: FaceAnalysis::FaceAnalyser* face_analyser; // The actual descriptors (for visualisation and output) - cv::Mat_* hog_features; + cv::Mat_* hog_features; cv::Mat* aligned_face; cv::Mat* visualisation; @@ -111,7 +111,7 @@ public: params.setAlignedOutput(output_width); face_analyser = new FaceAnalysis::FaceAnalyser(params); - hog_features = new cv::Mat_(); + hog_features = new cv::Mat_(); aligned_face = new cv::Mat(); visualisation = new cv::Mat(); @@ -172,7 +172,7 @@ public: hog_output_file->write((char*)(&good_frame_float), 4); - cv::MatConstIterator_ descriptor_it = hog_features->begin(); + cv::MatConstIterator_ descriptor_it = hog_features->begin(); for(int y = 0; y < *num_cols; ++y) { @@ -181,7 +181,7 @@ public: for(unsigned int o = 0; o < 31; ++o) { - float hog_data = (float)(*descriptor_it++); + float hog_data = (*descriptor_it++); hog_output_file->write((char*)&hog_data, 4); } } @@ -208,7 +208,9 @@ public: face_analyser->AddNextFrame(frame->Mat, landmarks_mat, success, 0, online); - face_analyser->GetLatestHOG(*hog_features, *num_rows, *num_cols); + cv::Mat_ hog_d; + face_analyser->GetLatestHOG(hog_d, *num_rows, *num_cols); + hog_d.convertTo(*hog_features, CV_64F); face_analyser->GetLatestAlignedFace(*aligned_face); @@ -237,7 +239,10 @@ public: face_analyser->PredictStaticAUsAndComputeFeatures(frame->Mat, landmarks_mat); // Set the computed appearance features - face_analyser->GetLatestHOG(*hog_features, *num_rows, *num_cols); + cv::Mat_ hog_tmp; + face_analyser->GetLatestHOG(hog_tmp, *num_rows, *num_cols); + hog_tmp.convertTo(*hog_features, CV_32F); + face_analyser->GetLatestAlignedFace(*aligned_face); if (vis_hog) @@ -329,6 +334,11 @@ public: OpenCVWrappers::RawImage^ HOG_vis_image = gcnew OpenCVWrappers::RawImage(*visualisation); return HOG_vis_image; } + + OpenCVWrappers::RawImage^ GetLatestHOGFeature() { + OpenCVWrappers::RawImage^ HOG_feature = gcnew OpenCVWrappers::RawImage(*hog_features); + return HOG_feature; + } void Reset() { diff --git a/lib/local/CppInerop/RecorderInterop.h b/lib/local/CppInerop/RecorderInterop.h index 858f09c..9230685 100644 --- a/lib/local/CppInerop/RecorderInterop.h +++ b/lib/local/CppInerop/RecorderInterop.h @@ -176,6 +176,11 @@ namespace UtilitiesOF { m_recorder->SetObservationFaceAlign(aligned_face_image->Mat); } + void SetObservationHOG(bool success, OpenCVWrappers::RawImage^ aligned_face_image, int num_cols, int num_rows, int num_channels) + { + m_recorder->SetObservationHOG(success, aligned_face_image->Mat, num_cols, num_rows, num_channels); + } + void SetObservationLandmarks(List^>^ landmarks_2D, List^>^ landmarks_3D, List^ params_global, List^ params_local, double confidence, bool success) { // Construct an OpenCV matrix from the landmarks