36 #ifndef vpImageQueue_h
37 #define vpImageQueue_h
39 #include <visp3/core/vpConfig.h>
41 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
43 #include <condition_variable>
49 #include <visp3/core/vpDisplay.h>
50 #include <visp3/core/vpIoTools.h>
76 : m_cancelled(false), m_cond(), m_queue_image(), m_queue_data(), m_maxQueueSize(1024 * 8), m_mutex(),
77 m_seqname(seqname), m_recording_mode(record_mode), m_start_recording(false), m_directory_to_create(false),
78 m_recording_trigger(false)
81 if (!m_directory.empty()) {
83 m_directory_to_create =
true;
87 std::string(
"Record mode: ") + (m_recording_mode ? std::string(
"single") : std::string(
"continuous"));
95 std::lock_guard<std::mutex> lock(m_mutex);
96 std::cout <<
"Wait to finish saving images..." << std::endl;
125 std::unique_lock<std::mutex> lock(m_mutex);
127 while (m_queue_image.empty()) {
139 I = m_queue_image.front();
143 if (!m_queue_data.empty()) {
144 data = m_queue_data.front();
157 std::lock_guard<std::mutex> lock(m_mutex);
159 m_queue_image.push(I);
162 m_queue_data.push(*data);
166 while (m_queue_image.size() > m_maxQueueSize) {
171 while (m_queue_data.size() > m_maxQueueSize) {
189 bool disable_left_click =
false)
192 if (!m_seqname.empty()) {
193 if (!disable_left_click) {
194 if (!m_recording_mode) {
195 if (m_start_recording) {
216 if (!m_seqname.empty()) {
222 if (!m_seqname.empty()) {
224 m_start_recording = !m_start_recording;
232 }
else if (!m_seqname.empty()) {
233 m_start_recording =
true;
236 if (trigger_recording) {
237 m_start_recording =
true;
240 m_recording_trigger = m_start_recording;
242 if (m_start_recording) {
244 if (m_directory_to_create) {
245 std::cout <<
"Create directory \"" << m_directory <<
"\"" << std::endl;
247 m_directory_to_create =
false;
252 if (m_recording_mode == 1) {
253 m_start_recording =
false;
263 void setMaxQueueSize(
const size_t max_queue_size) { m_maxQueueSize = max_queue_size; }
267 std::condition_variable m_cond;
268 std::queue<vpImage<Type> > m_queue_image;
269 std::queue<std::string> m_queue_data;
270 size_t m_maxQueueSize;
272 std::string m_seqname;
273 std::string m_directory;
274 int m_recording_mode;
275 bool m_start_recording;
276 std::string m_text_record_mode;
277 bool m_directory_to_create;
278 bool m_recording_trigger;
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
unsigned int getDownScalingFactor()
static void displayText(const vpImage< unsigned char > &I, const vpImagePoint &ip, const std::string &s, const vpColor &color)
int getRecordingMode() const
void pop(vpImage< Type > &I, std::string &data)
bool getRecordingTrigger() const
vpImageQueue(const std::string &seqname, int record_mode)
bool record(const vpImage< Type > &I, std::string *data=NULL, bool trigger_recording=false, bool disable_left_click=false)
std::string getSeqName() const
void setMaxQueueSize(const size_t max_queue_size)
void push(const vpImage< Type > &I, std::string *data)
Definition of the vpImage class member functions.