36 #ifndef vpImageQueue_h 37 #define vpImageQueue_h 39 #include <visp3/core/vpConfig.h> 41 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) 47 #include <condition_variable> 49 #include <visp3/core/vpIoTools.h> 50 #include <visp3/core/vpDisplay.h> 75 : m_cancelled(false), m_cond(), m_queue_image(), m_queue_data(), m_maxQueueSize(1024*8), m_mutex(),
76 m_seqname(seqname), m_recording_mode(record_mode), m_start_recording(false), m_directory_to_create(false),
77 m_recording_trigger(false)
80 if (! m_directory.empty()) {
82 m_directory_to_create =
true;
85 m_text_record_mode = std::string(
"Record mode: ") + (m_recording_mode ? std::string(
"single") : std::string(
"continuous"));
92 std::lock_guard<std::mutex> lock(m_mutex);
93 std::cout <<
"Wait to finish saving images..." << std::endl;
103 return m_recording_mode;
111 return m_recording_trigger;
130 std::unique_lock<std::mutex> lock(m_mutex);
132 while (m_queue_image.empty()) {
144 I = m_queue_image.front();
148 if (! m_queue_data.empty()) {
149 data = m_queue_data.front();
161 std::lock_guard<std::mutex> lock(m_mutex);
163 m_queue_image.push(I);
166 m_queue_data.push(*data);
170 while (m_queue_image.size() > m_maxQueueSize) {
175 while(m_queue_data.size() > m_maxQueueSize) {
191 bool record(
const vpImage<Type> &I, std::string *data = NULL,
bool trigger_recording =
false,
bool disable_left_click =
false)
193 if (! m_seqname.empty()) {
194 if (! disable_left_click) {
195 if (! m_recording_mode) {
196 if (m_start_recording) {
213 if (! m_seqname.empty()) {
218 if (! m_seqname.empty()) {
220 m_start_recording = !m_start_recording;
231 if (trigger_recording) {
232 m_start_recording =
true;
235 m_recording_trigger = m_start_recording;
237 if (m_start_recording) {
239 if (m_directory_to_create) {
240 std::cout <<
"Create directory \"" << m_directory <<
"\"" << std::endl;
242 m_directory_to_create =
false;
247 if (m_recording_mode == 1) {
248 m_start_recording =
false;
259 m_maxQueueSize = max_queue_size;
264 std::condition_variable m_cond;
265 std::queue<vpImage<Type> > m_queue_image;
266 std::queue<std::string > m_queue_data;
267 size_t m_maxQueueSize;
269 std::string m_seqname;
270 std::string m_directory;
271 int m_recording_mode;
272 bool m_start_recording;
273 std::string m_text_record_mode;
274 bool m_directory_to_create;
275 bool m_recording_trigger;
void pop(vpImage< Type > &I, std::string &data)
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
void push(const vpImage< Type > &I, std::string *data)
bool record(const vpImage< Type > &I, std::string *data=NULL, bool trigger_recording=false, bool disable_left_click=false)
static void displayText(const vpImage< unsigned char > &I, const vpImagePoint &ip, const std::string &s, const vpColor &color)
void setMaxQueueSize(const size_t max_queue_size)
vpImageQueue(const std::string &seqname, int record_mode)
std::string getSeqName() const
int getRecordingMode() const
unsigned int getDownScalingFactor()
Definition of the vpImage class member functions.
bool getRecordingTrigger() const