CLR does not agree with C++ threads, so moving back to tbb task_group

This commit is contained in:
Tadas Baltrusaitis
2018-05-31 08:15:23 +01:00
parent 0d758babf8
commit 6569601652
4 changed files with 12 additions and 21 deletions

6
.gitignore vendored
View File

@@ -49,6 +49,7 @@ exe/Recording/Release/
lib/local/GazeAnalyser/Release/
exe/FaceLandmarkImg/menpo_out/
/Release/
/Debug/
matlab_runners/Demos/demo_img/
matlab_runners/Demos/demo_vid/
matlab_runners/Demos/output_features_seq/
@@ -93,7 +94,6 @@ matlab_runners/Demos/processed/
exe/releases/OpenFace_*
*.suo
.vs/OpenFace/v15/
build/
/build/
matlab_runners/Action Unit Experiments/AU_predictions/
lib/local/Utilities/Debug/

View File

@@ -49,9 +49,6 @@
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
// Threading includes
#include <thread>
namespace Utilities
{
@@ -181,9 +178,10 @@ namespace Utilities
cv::Mat aligned_face;
tbb::concurrent_bounded_queue<std::pair<std::string, cv::Mat> > aligned_face_queue;
std::thread video_writing_thread;
std::thread aligned_writing_thread;
// For keeping track of tasks
tbb::task_group writing_threads;
// TODO rem
bool closed = false;
};

View File

@@ -48,7 +48,6 @@
// For threading
#include <chrono>
#include <thread>
using namespace boost::filesystem;
@@ -371,9 +370,8 @@ void RecorderOpenFace::WriteObservation()
int capacity = (1024 * 1024 * ALIGNED_QUEUE_CAPACITY) / (aligned_face.size().width *aligned_face.size().height * aligned_face.channels());
aligned_face_queue.set_capacity(capacity);
// Start the alignment output thread
aligned_writing_thread = std::thread(&AlignedImageWritingTask, &aligned_face_queue);
// Start the alignment output thread
writing_threads.run([&] {AlignedImageWritingTask(&aligned_face_queue); });
}
char name[100];
@@ -434,7 +432,7 @@ void RecorderOpenFace::WriteObservationTracked()
}
// Start the video and tracked image writing thread
video_writing_thread = std::thread(&VideoWritingTask, &vis_to_out_queue, params.isSequence(), &video_writer);
writing_threads.run([&] {VideoWritingTask(&vis_to_out_queue, params.isSequence(), &video_writer); });
}
@@ -530,11 +528,7 @@ void RecorderOpenFace::Close()
aligned_face_queue.push(std::pair<string, cv::Mat>("", cv::Mat()));
// Make sure the recording threads complete
if (video_writing_thread.joinable())
video_writing_thread.join();
if (aligned_writing_thread.joinable())
aligned_writing_thread.join();
writing_threads.wait();
hog_recorder.Close();
csv_recorder.Close();

View File

@@ -285,7 +285,7 @@ void SequenceCapture::Close()
capture_threads.wait();
// Empty the capture queue
// Empty the capture queue (in case a capture was cancelled and we still have frames in the queue)
capture_queue.clear();
// Release the capture objects
@@ -297,8 +297,7 @@ void SequenceCapture::Close()
// Destructor that releases the capture
SequenceCapture::~SequenceCapture()
{
if (capture.isOpened())
capture.release();
Close();
}
bool SequenceCapture::OpenVideoFile(std::string video_file, float fx, float fy, float cx, float cy)