Skip to content

Commit

Permalink
Bug fix with output aligned faces and videos if no face is detected i…
Browse files Browse the repository at this point in the history
…n the first frame. Adding .webm file support
  • Loading branch information
TadasBaltrusaitis committed Jun 29, 2018
1 parent 3c9ee1c commit 79d7116
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion gui/OpenFaceOffline/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ private List<string> openMediaDialog(bool images)
}
else
{
d.Filter = "Video files|*.avi;*.wmv;*.mov;*.mpg;*.mpeg;*.mp4";
d.Filter = "Video files|*.avi;*.webm;*.wmv;*.mov;*.mpg;*.mpeg;*.mp4";
}
if (d.ShowDialog(this) == true)
{
Expand Down
2 changes: 2 additions & 0 deletions lib/local/Utilities/include/RecorderOpenFace.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,13 @@ namespace Utilities

// Do not exceed 100MB in the concurrent queue
const int TRACKED_QUEUE_CAPACITY = 100;
bool tracked_writing_thread_started;
cv::Mat vis_to_out;
tbb::concurrent_bounded_queue<std::pair<std::string, cv::Mat> > vis_to_out_queue;

// For aligned face writing
const int ALIGNED_QUEUE_CAPACITY = 100;
bool aligned_writing_thread_started;
cv::Mat aligned_face;
tbb::concurrent_bounded_queue<std::pair<std::string, cv::Mat> > aligned_face_queue;

Expand Down
15 changes: 10 additions & 5 deletions lib/local/Utilities/src/RecorderOpenFace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@ void RecorderOpenFace::PrepareRecording(const std::string& in_filename)
}

this->frame_number = 0;
this->tracked_writing_thread_started = false;
this->aligned_writing_thread_started = false;
}

RecorderOpenFace::RecorderOpenFace(const std::string in_filename, const RecorderOpenFaceParameters& parameters, std::vector<std::string>& arguments):video_writer(), params(parameters)
Expand Down Expand Up @@ -363,10 +365,10 @@ void RecorderOpenFace::WriteObservation()
// Write aligned faces
if (params.outputAlignedFaces())
{
// To support both video and image input
if ((face_id == 0 && frame_number == 0) || (face_id == 0 && frame_number == 1))
{

if (!aligned_writing_thread_started)
{
aligned_writing_thread_started = true;
int capacity = (1024 * 1024 * ALIGNED_QUEUE_CAPACITY) / (aligned_face.size().width *aligned_face.size().height * aligned_face.channels()) + 1;
aligned_face_queue.set_capacity(capacity);

Expand Down Expand Up @@ -412,9 +414,10 @@ void RecorderOpenFace::WriteObservationTracked()

if (params.outputTracked())
{
// To support both video and image input
if ((!params.isSequence() && frame_number == 0) || (params.isSequence() && frame_number == 1))

if (!tracked_writing_thread_started)
{
tracked_writing_thread_started = true;
// Set up the queue for video writing based on output size
int capacity = (1024 * 1024 * TRACKED_QUEUE_CAPACITY) / (vis_to_out.size().width * vis_to_out.size().height * vis_to_out.channels()) + 1;
vis_to_out_queue.set_capacity(capacity);
Expand Down Expand Up @@ -547,6 +550,8 @@ void RecorderOpenFace::Close()
aligned_writing_thread.join();
#endif

tracked_writing_thread_started = false;
aligned_writing_thread_started = false;

hog_recorder.Close();
csv_recorder.Close();
Expand Down

0 comments on commit 79d7116

Please sign in to comment.