ImageMonitorWidgetController.cpp
Go to the documentation of this file.
1 /*
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * @package ObserverTest::
17 * @author ( at kit dot edu)
18 * @date
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22 
23 
25 
26 
27 // STD/STL
28 #include <cmath>
29 #include <iomanip>
30 #include <filesystem>
31 
32 // Qt
33 #include <QApplication>
34 
35 // IVT
36 #include <Image/ImageProcessor.h>
37 
38 // Somox
39 #include <SimoxUtility/algorithm/string.h>
40 
41 // ArmarXCore
44 
45 // RobotAPI
47 
48 // VisionX
51 
52 #include "ImageViewerArea.h"
53 using namespace armarx;
54 
55 
56 namespace
57 {
58  /**
59  * @brief Helper function to determine the correct camera ID
60  *
61  * For example, if there are two image sources and the depth index is not set, then the first
62  * camera is "left" and the second "right". If there are more than two cameras, they are just
63  * called "camX" where X is the ID. If the depth index is set, then that camera will be called
64  * "depth". For two image sources, the other one will then be called "rgb". Only one image
65  * source will yield in no ID at all.
66  *
67  * @param index Index of the camera
68  * @param index_count Number of cameras (or indices) in total
69  * @param depth_index Index of the depth camera
70  * @return Human readable string representation of the configuration
71  */
72  std::string getHumanReadableCameraID(unsigned int index, unsigned int index_count, int depth_index);
73 
74  /**
75  * @brief Helper function to create a date string
76  * @return
77  */
78  std::string getDateString();
79 }
80 
81 
82 namespace visionx
83 {
84  ImageMonitorProperties::ImageMonitorProperties()
85  {
86  providerName = "";
87  frameRate = -1.0f;
88 
89  // Qt Moc does not seem to accept outputDirectory being a std::filesystem::path().
90  {
91  if (const char* home = std::getenv("HOME"))
92  {
93  // ToDo: Replace with XDG_PICTURES_DIR standards when available.
94  outputDirectory = std::filesystem::path(home) / "Pictures";
95  }
96  else
97  {
98  outputDirectory = std::filesystem::absolute(".");
99  }
100  }
101 
102  imageBufferSize = 100;
103  bufferFps = 5;
104  controlsHidden = false;
105  depthImageIndex = -1;
106  maxDepthmm = 5000;
107  compressionType = eNoCompression;
108  compressionQuality = 9;
109  }
110 
111 
112  ImageMonitorWidgetController::ImageMonitorWidgetController() :
113  // displayDelayFilter(20)
114  displayDelayFilter(IceUtil::Time::seconds(3), 100)
115  {
116  }
117 
118  // *******************************************************
119  // Inherited from ArmarXWidgetController
120  // *******************************************************
122  {
123  if (!widget)
124  {
125  widget = new ImageMonitorWidget(this);
126  }
127 
128  return qobject_cast<QWidget*>(widget);
129  }
130 
131  // *******************************************************
132  // Inherited from ImageProcessorBase
133  // *******************************************************
135  {
136  getWidget()->show();
137  std::unique_lock lock(imageMutex);
138  images = nullptr;
139  connected = false;
140  playing = false;
141  writeImageBuffer = false;
142  lastBufferTime = IceUtil::Time::now();
143  imageBuffer.resize(10);
144 
145  // signals / slots
146  connect(this, SIGNAL(imageProviderConnected(bool)), widget, SLOT(setConnected(bool)));
147  connect(this, SIGNAL(statisticsUpdated(const QString&)), widget, SLOT(updateStatistics(const QString&)));
148  connect(this, SIGNAL(recordingBufferEmpty(bool)), widget, SLOT(updateRecordButton(bool)));
149  }
150 
152  {
153  if (properties.providerName != "" /*&& !connected*/)
154  {
155  applyProperties(properties);
156  }
157  }
158 
160  {
161  disconnectFromProvider();
162  }
163 
165  {
166  if (!connected)
167  {
168  usleep(10000);
169  return;
170  }
171 
172  updateStatistics();
173 
174  if (!playing)
175  {
176  usleep(10000);
177  return;
178  }
179 
180  std::unique_lock lock(imageMutex);
181  unsigned int retrievedImages = 0;
182  const bool sourceFps = this->properties.frameRate < 0.0f;
183 
184  // Fetch images and visualise
185  {
186  if (sourceFps && !this->waitForImages(this->properties.providerName))
187  {
188  ARMARX_VERBOSE << "Timeout or error in wait for images" << armarx::flush;
189  return;
190  }
191 
192  armarx::MetaInfoSizeBasePtr info;
193  retrievedImages = static_cast<unsigned int>(this->getImages(this->properties.providerName, this->images, info));
194  timeReceived = TimeUtil::GetTime();
195  if (sourceFps)
196  {
197  this->timeProvided = IceUtil::Time::microSeconds(info->timeProvided);
198  }
199 
200  std::vector<CByteImage*> deleteList;
201  std::vector<CByteImage*> selectedImages;
202 
203  for (unsigned int i = 0; i < static_cast<unsigned int>(retrievedImages) && i < this->numberImages; ++i)
204  {
205  CByteImage* currentImage;
206 
207  if (i == static_cast<unsigned int>(this->properties.depthImageIndex) && this->properties.recordDepthRaw)
208  {
209  currentImage = new CByteImage(this->images[i]);
210  ::ImageProcessor::CopyImage(this->images[i], currentImage);
211  deleteList.push_back(currentImage);
212  }
213  else
214  {
215  currentImage = this->images[i];
216  }
217 
218  if (this->properties.imagesToShow.size() == 0 or (this->properties.imagesToShow.size() > 0 and this->properties.imagesToShow.count(i) > 0))
219  {
220  if (i == static_cast<unsigned int>(this->properties.depthImageIndex))
221  {
222  this->convertToHeatMapDepthImage(currentImage);
223  }
224 
225  selectedImages.push_back(currentImage);
226  }
227  }
228 
229  if (selectedImages.size() > 0)
230  {
231  this->widget->drawImages(static_cast<int>(selectedImages.size()), &selectedImages[0], this->timeProvided, timeReceived);
232  }
233 
234  for (CByteImage* image : deleteList)
235  {
236  delete image;
237  }
238 
239  if (!sourceFps)
240  {
241  this->fpsCounter.assureFPS(this->properties.frameRate);
242  }
243  }
244 
245  if (writeImageBuffer && retrievedImages > 0)
246  {
247  if ((imageBuffer.size()) != static_cast<unsigned int>(properties.imageBufferSize) && properties.imageBufferSize > 0)
248  {
249  imageBuffer.resize(static_cast<unsigned int>(properties.imageBufferSize));
250  }
251 
252  IceUtil::Time timePassed = IceUtil::Time::now() - lastBufferTime;
253 
254  if (timePassed.toMilliSeconds() > 1000.f / properties.bufferFps)
255  {
256  ImageContainer newImages;
257 
258  for (unsigned int i = 0; i < retrievedImages; i++)
259  {
260  newImages.push_back(CByteImagePtr(new CByteImage(images[i])));
261  ::ImageProcessor::CopyImage(images[i], newImages[i].get());
262  }
263 
264  imageBuffer.push_front(newImages);
265  lastBufferTime = IceUtil::Time::now();
266  }
267  }
268 
269  if (this->recordingTask && this->writeRecordingBuffer)
270  {
271  std::vector<CByteImage*> tmpImages(this->numberImages);
272  for (unsigned int i = 0; i < this->numberImages; ++i)
273  {
274  tmpImages.at(i) = new CByteImage(this->images[i]);
275  ::ImageProcessor::CopyImage(this->images[i], tmpImages[i]);
276  }
277  lock.unlock();
278  std::unique_lock lock2(this->recordingBufferMutex);
279  this->recordingBuffer.push(tmpImages);
280  }
281  }
282 
284  {
285  properties.providerName = settings->value("providerName", "").toString().toStdString();
286  properties.frameRate = settings->value("frameRate", -1).toInt();
287  properties.outputDirectory = settings->value("outputPath", ".").toString().toStdString();
288  properties.imageBufferSize = settings->value("imageBufferSize", 99).toInt();
289  properties.bufferFps = settings->value("bufferFps", 5.0f).toFloat();
290  auto imagesToShowStringList = settings->value("imagesToShow", 0).toStringList();
291  properties.imagesToShow.clear();
292  for (QString& s : imagesToShowStringList)
293  {
294  properties.imagesToShow.insert(s.toULong());
295  }
296  properties.controlsHidden = settings->value("controlsHidden", false).toBool();
297  properties.depthImageIndex = settings->value("depthImageIndex", -1).toInt();
298  properties.maxDepthmm = settings->value("maxDepthmm", 5000).toInt();
299  properties.recordDepthRaw = settings->value("recordDepthRaw", true).toBool();
300  properties.recordingMethods = settings->value("recordingMethods", 0).toStringList();
301  properties.compressionType = static_cast<CompressionType>(settings->value("compressionType", 0).toInt());
302  properties.compressionQuality = settings->value("compressionQuality", 0).toInt();
303 
304  ARMARX_INFO << "bufferFps: " << properties.bufferFps;
305  }
306 
308  {
309  settings->setValue("providerName", QString(properties.providerName.c_str()));
310  settings->setValue("frameRate", properties.frameRate);
311  settings->setValue("outputPath", QString(properties.outputDirectory.c_str()));
312  settings->setValue("imageBufferSize", properties.imageBufferSize);
313  settings->setValue("bufferFps", QString::number(static_cast<double>(properties.bufferFps)));
314  QStringList l;
315  for (auto number : properties.imagesToShow)
316  {
317  l << QString::number(number);
318  }
319  settings->setValue("imagesToShow", l);
320  settings->setValue("controlsHidden", properties.controlsHidden);
321  settings->setValue("depthImageIndex", properties.depthImageIndex);
322  settings->setValue("maxDepthmm", properties.maxDepthmm);
323  settings->setValue("recordDepthRaw", properties.recordDepthRaw);
324  settings->setValue("recordingMethods", properties.recordingMethods);
325 
326  settings->setValue("compressionType", (int)properties.compressionType);
327  settings->setValue("compressionQuality", (int)properties.compressionQuality);
328 
329  }
330 
331  // *******************************************************
332  // properties handling
333  // *******************************************************
335  {
336  ARMARX_INFO << "Applying properties";
337  std::unique_lock lock(imageMutex);
338 
339  disconnectFromProvider();
340 
341  // update properties
342  this->properties = properties;
343 
344  // connect to provider
345  try
346  {
347  connectToProvider();
348  }
349  catch (...)
350  {
352  }
353  }
354 
356  {
357  return properties;
358  }
359 
361  {
362  return getImageTransferStats(properties.providerName);
363  }
364 
365  const ImageContainer& ImageMonitorWidgetController::getBufferedImage(unsigned int position, unsigned int& realPosition)
366  {
367  int posInBuffer = static_cast<int>(imageBuffer.size()) - 1 - static_cast<int>(position);
368 
369  if (posInBuffer < 0)
370  {
371  posInBuffer = 0;
372  }
373 
374  if (static_cast<unsigned int>(posInBuffer) >= imageBuffer.size())
375  {
376  posInBuffer = static_cast<int>(imageBuffer.size()) - 1;
377  }
378 
379  if (imageBuffer.size() == 0)
380  {
381  throw LocalException("ImageBuffer size is 0");
382  }
383 
384  realPosition = static_cast<unsigned int>(posInBuffer);
385  return imageBuffer[static_cast<unsigned int>(posInBuffer)];
386  }
387 
388  // *******************************************************
389  // private methods
390  // *******************************************************
391  void ImageMonitorWidgetController::connectToProvider()
392  {
393  if (connected)
394  {
395  return;
396  }
397 
398  // TODO: using image provider can be done only here???? Why???
399  usingImageProvider(properties.providerName);
400 
401  ARMARX_INFO << getName() << " connecting to " << properties.providerName;
402 
403  // connect to proxy
404  imageProviderInfo = getImageProvider(properties.providerName, visionx::tools::typeNameToImageType("rgb"));
405 
406  // update members
407  imageProviderPrx = imageProviderInfo.proxy;
408  numberImages = static_cast<unsigned int>(imageProviderInfo.numberImages);
409 
410  // create images
411  {
412  std::unique_lock lock(imageMutex);
413  images = new CByteImage*[numberImages];
414 
415  for (unsigned int i = 0 ; i < numberImages ; i++)
416  {
417  images[i] = tools::createByteImage(imageProviderInfo);
418  }
419  }
420 
421  timeProvided = IceUtil::Time::seconds(0);
423  connected = true;
424 
425 
426 
427  emit imageProviderConnected(true);
428  }
429 
430  void ImageMonitorWidgetController::disconnectFromProvider()
431  {
432  if (!connected)
433  {
434  return;
435  }
436  {
437  std::unique_lock lock(imageMutex);
438  // clear images
439  if (images)
440  {
441  for (unsigned int i = 0 ; i < numberImages ; i++)
442  {
443  delete images[i];
444  }
445 
446  delete [] images;
447  }
448  }
450  // release provider
451  imageProviderPrx = nullptr;
452 
453  connected = false;
454 
455  emit imageProviderConnected(false);
456  }
457 
459  {
460  namespace fs = std::filesystem;
461  fs::path absPath = fs::absolute(fs::path(properties.outputDirectory));
462  return absPath.string();
463  }
464 
466  {
467  std::unique_lock lock(this->imageMutex);
468 
469  std::filesystem::path path = this->getAbsoluteOutputPath();
470  std::string baseFilename = "snapshot_" + getDateString();
471 
472  for (unsigned int i = 0; i < this->numberImages; ++i)
473  {
474  std::filesystem::path filename = baseFilename + getHumanReadableCameraID(i, this->numberImages, this->properties.depthImageIndex);
475  visionx::imrec::takeSnapshot(*this->images[i], path / filename);
476  }
477  }
478 
480  {
481  if (this->recordingTask && this->recordingTask->isRunning())
482  {
483  return;
484  }
485 
486  // Initialise needed values
487  const std::string baseFilename = "recording_" + getDateString();
488  const std::filesystem::path path = this->getAbsoluteOutputPath();
489  const double fps = [this]() -> double
490  {
491  if (this->properties.frameRate <= 0)
492  {
493  visionx::ImageTransferStats stats = this->getImageTransferStats(this->properties.providerName);
494  const float source_fps = std::round(stats.imageProviderFPS.getFPS());
495  return static_cast<unsigned int>(source_fps);
496  }
497 
498  return static_cast<double>(this->properties.frameRate);
499  }();
500 
501  for (unsigned int i = 0; i < this->numberImages; ++i)
502  {
503  // Determine full filename and extension
504  const std::string ext = this->properties.recordingMethods.at(static_cast<int>(i)).toStdString();
505  const std::filesystem::path filename = baseFilename + getHumanReadableCameraID(i, this->numberImages, this->properties.depthImageIndex) + ext;
506  const std::filesystem::path fullFilePath = path / filename;
507 
508  // Create recorder and add to list
509  visionx::imrec::Recording rec = ext != "" ? visionx::imrec::newRecording(fullFilePath, fps) : nullptr;
510  this->recorders.push_back(rec);
511  }
512 
513  ARMARX_IMPORTANT << "Starting recording with " << fps << " fps to path: " << getAbsoluteOutputPath();
514 
515  this->recordingTask = new PeriodicTask<ImageMonitorWidgetController>(this, &ImageMonitorWidgetController::recordFrame, 1, true, "ImageRecorderTask");
516  this->writeRecordingBuffer = true;
517  this->recordingTask->start();
518  }
519 
521  {
522  emit this->recordingBufferEmpty(/* isEmpty = */ false);
523  // Disallow writing recording buffer and wait until it is empty
524  this->writeRecordingBuffer = false;
525  if (!this->recordingBuffer.empty())
526  {
527  ARMARX_IMPORTANT << "Stopping recording... Still " << this->recordingBuffer.size() << " images in the queue to write";
528  return;
529  }
530 
531  emit this->recordingBufferEmpty(/* isEmpty = */ true);
532 
533  if (this->recordingTask)
534  {
535  this->recordingTask->stop();
536  }
537 
538  ARMARX_INFO << "Closing recordings";
539 
540  for (const visionx::imrec::Recording& rec : this->recorders)
541  {
542  if (rec)
543  {
544  rec->stopRecording();
545  }
546  }
547  this->recorders.clear();
548  }
549 
550  void ImageMonitorWidgetController::recordFrame()
551  {
552  std::vector<CByteImage*> images;
553  {
554  std::unique_lock lock(this->recordingBufferMutex);
555 
556  // If the recording was stopped, keep running until the buffer was emptied completely
557  if (!this->writeRecordingBuffer)
558  {
559  if (this->recordingBuffer.empty())
560  {
561  ARMARX_IMPORTANT << "All images in queue were written";
562  this->stopRecording();
563  return;
564  }
565  else if (this->recordingBuffer.size() % 5 == 0)
566  {
567  ARMARX_INFO << "Stopping recording... Still " << this->recordingBuffer.size() << " images in the queue to write";
568  }
569  }
570  else if (this->recordingBuffer.size() > 0 and this->recordingBuffer.size() % 5 == 0)
571  {
572  ARMARX_INFO << deactivateSpam(1) << "Recording buffer queue size currently at " << this->recordingBuffer.size() << " images";
573  }
574 
575  // Early return (nop) if the buffer is initially empty etc.
576  if (!this->connected or this->recordingBuffer.empty())
577  {
578  return;
579  }
580 
581  images = this->recordingBuffer.front();
582  this->recordingBuffer.pop();
583  }
584 
585  TIMING_START(imageWriting);
586 
587  for (unsigned int i = 0; i < this->numberImages; ++i)
588  {
589  if (this->recorders[i])
590  {
591  this->recorders[i]->recordFrame(*images[i], std::chrono::microseconds{0});
592  }
593  delete images[i];
594  }
595 
596  TIMING_END(imageWriting);
597  }
598 
599  void ImageMonitorWidgetController::updateStatistics()
600  {
601  std::unique_lock lock(imageMutex);
603 
604  std::stringstream ss;
605 
606  ss << std::fixed << std::setprecision(1) << "source fps: " << stats.imageProviderFPS.getFPS();
607  ss << " - ";
608 
609  IceUtil::Time displayDelay = widget->getImageViewer()->getDisplayDelay();
610  displayDelayFilter.update(timeReceived, displayDelay.toMilliSecondsDouble());
611 
612  if (playing)
613  {
614  ss << "display fps: " << stats.pollingFPS.getFPS();
615  if (timeProvided.toMilliSeconds())
616  {
617  ss << " - image age: " << (timeReceived - timeProvided).toMilliSeconds() << " ms - display delay: " << IceUtil::Time::milliSecondsDouble(displayDelayFilter.getCurrentValue()).toMilliSecondsDouble() << " ms";
618  }
619  }
620  else
621  {
622  ss << "display paused";
623  }
624 
625  std::string statisticsStr = ss.str();
626  emit statisticsUpdated(QString(statisticsStr.c_str()));
627  }
628 
629  void ImageMonitorWidgetController::hideControls(bool hide)
630  {
631  widget->hideControlWidgets(hide);
632  properties.controlsHidden = hide;
633  }
634 
635  QPointer<QWidget> ImageMonitorWidgetController::getCustomTitlebarWidget(QWidget* parent)
636  {
637  if (customToolbar)
638  {
639  if (parent != customToolbar->parent())
640  {
641  customToolbar->setParent(parent);
642  }
643 
644  return customToolbar.data();
645  }
646 
647  customToolbar = new QToolBar(parent);
648  customToolbar->setIconSize(QSize(16, 16));
649 
650  viewingModeAction = customToolbar->addAction(QIcon(":icons/object-locked-2.ico"), "Hide controls");
651  viewingModeAction->setCheckable(true);
652  connect(viewingModeAction, SIGNAL(toggled(bool)), this, SLOT(hideControls(bool)));
653  viewingModeAction->setChecked(properties.controlsHidden);
654 
655  return customToolbar.data();
656  }
657 
659  {
660  float maxDistance = properties.maxDepthmm;
661  int pixelCount = depthImage->width * depthImage->height;
662  auto& depthToRgbLookUpTable = depthToRgbLookUpTables[maxDistance];
663  size_t depthValueCount = 256 * 256; // 16 bit depth images
664  if (depthToRgbLookUpTable.size() != depthValueCount)
665  {
666  ARMARX_VERBOSE << "Resizing lookup table for max distance " << maxDistance;
667  depthToRgbLookUpTable.resize(depthValueCount);
668  }
669  size_t pixelPos = 0;
670  for (int i = 0; i < pixelCount; ++i)
671  {
672  int z_value = visionx::tools::rgbToDepthValue(depthImage->pixels[pixelPos + 0], depthImage->pixels[pixelPos + 1], depthImage->pixels[pixelPos + 2], false);
673  if (z_value > 0)
674  {
675  DrawColor24Bit rgb;
676  if (z_value < static_cast<signed int>(depthToRgbLookUpTable.size())) // lookup only for 16 bit depth images
677  {
678  std::optional<armarx::DrawColor24Bit>& rgbOptional = depthToRgbLookUpTable.at(z_value);
679  if (rgbOptional)
680  {
681  rgb = *rgbOptional;
682  }
683  else
684  {
685  auto hsv = colorutils::HeatMapColor(1.0f - z_value / maxDistance);
686  rgb = colorutils::HsvToRgb(hsv);
687  rgbOptional = rgb;
688  }
689  }
690  else // fallback for 24 bit depth images
691  {
692  auto hsv = colorutils::HeatMapColor(1.0f - z_value / maxDistance);
693  rgb = colorutils::HsvToRgb(hsv);
694  }
695  depthImage->pixels[pixelPos] = rgb.r;
696  depthImage->pixels[pixelPos + 1] = rgb.g;
697  depthImage->pixels[pixelPos + 2] = rgb.b;
698  }
699  else
700  {
701  depthImage->pixels[pixelPos] = 0;
702  depthImage->pixels[pixelPos + 1] = 0;
703  depthImage->pixels[pixelPos + 2] = 0;
704  }
705  pixelPos += 3;
706  }
707  }
708 
709 
710 }
711 
712 
713 namespace
714 {
715  std::string getHumanReadableCameraID(unsigned int index, unsigned int index_count, int depth_index)
716  {
717  if (index_count >= 2)
718  {
719  if (depth_index >= 0)
720  {
721  if (index == static_cast<unsigned int>(depth_index))
722  {
723  return "_depth";
724  }
725  if (index_count == 2 and index != static_cast<unsigned int>(depth_index))
726  {
727  return "_rgb";
728  }
729  }
730  else if (index_count == 2)
731  {
732  if (index == 0)
733  {
734  return "_left";
735  }
736  if (index == 1)
737  {
738  return "_right";
739  }
740  }
741 
742  return "_cam" + std::to_string(index);
743  }
744 
745  return "";
746  }
747 
748  std::string getDateString()
749  {
750  IceUtil::Time recordStartTime = IceUtil::Time::now();
751  std::string date_str = recordStartTime.toDateTime();
752  // I checked that this is equal to using boost::replace_all()
753  date_str = simox::alg::replace_all(date_str, "/", "-");
754  date_str = simox::alg::replace_all(date_str, " ", "_");
755  date_str = simox::alg::replace_all(date_str, ":", "-");
756  return date_str;
757  }
758 }
visionx::ImageMonitorProperties::recordDepthRaw
bool recordDepthRaw
Definition: ImageMonitorWidgetController.h:101
visionx::ImageMonitorWidgetController::startRecording
void startRecording()
Start recording of the images to bmp-files.
Definition: ImageMonitorWidgetController.cpp:479
ARMARX_VERBOSE
#define ARMARX_VERBOSE
Definition: Logging.h:180
TIMING_START
#define TIMING_START(name)
Definition: TimeUtil.h:280
visionx::ImageMonitorWidgetController::getStatistics
ImageTransferStats getStatistics()
Definition: ImageMonitorWidgetController.cpp:360
TIMING_END
#define TIMING_END(name)
Definition: TimeUtil.h:296
visionx::ImageMonitorWidgetController::applyProperties
void applyProperties(ImageMonitorProperties properties)
Definition: ImageMonitorWidgetController.cpp:334
ARMARX_IMPORTANT
#define ARMARX_IMPORTANT
Definition: Logging.h:183
visionx::ImageProviderInfo::numberImages
int numberImages
Number of images.
Definition: ImageProcessor.h:506
visionx
ArmarX headers.
Definition: OpenPoseStressTest.h:38
index
uint8_t index
Definition: EtherCATFrame.h:59
visionx::ImageTransferStats
The ImageTransferStats class provides information on the connection between ImageProvider and ImagePr...
Definition: ImageProcessor.h:441
visionx::ImageMonitorWidgetController::getProperties
ImageMonitorProperties getProperties()
Definition: ImageMonitorWidgetController.cpp:355
visionx::FPSCounter::getFPS
float getFPS()
Get frames per second.
Definition: FPSCounter.cpp:127
visionx::ImageMonitorProperties::maxDepthmm
int maxDepthmm
Definition: ImageMonitorWidgetController.h:104
visionx::ImageMonitorProperties::imageBufferSize
int imageBufferSize
Definition: ImageMonitorWidgetController.h:97
visionx::ImageMonitorWidgetController::recordingBufferEmpty
void recordingBufferEmpty(bool isEmpty)
visionx::ImageMonitorProperties::depthImageIndex
int depthImageIndex
Definition: ImageMonitorWidgetController.h:103
visionx::ImageMonitorWidgetController::saveSettings
void saveSettings(QSettings *settings) override
Implement to save the settings as part of the GUI configuration.
Definition: ImageMonitorWidgetController.cpp:307
visionx::ImageProcessor::getImageProvider
ImageProviderInfo getImageProvider(std::string name, ImageType destinationImageType=eRgb, bool waitForProxy=false)
Select an ImageProvider.
Definition: ImageProcessor.cpp:152
visionx::ImageTransferStats::pollingFPS
FPSCounter pollingFPS
Statistics for the images polled by the ImageProcessor.
Definition: ImageProcessor.h:458
visionx::ImageTransferStats::imageProviderFPS
FPSCounter imageProviderFPS
Statistics for the images announced by the ImageProvider.
Definition: ImageProcessor.h:453
visionx::ImageMonitorWidgetController::getWidget
QPointer< QWidget > getWidget() override
getWidget returns a pointer to the a widget of this controller.
Definition: ImageMonitorWidgetController.cpp:121
visionx::ImageProcessor::setCompressionType
void setCompressionType(CompressionType compressionType=ePNG, int compressionQuality=9)
Sets the compression type and compression quality.
Definition: ImageProcessor.cpp:696
ImageMonitorWidgetController.h
IceUtil
Definition: Instance.h:21
visionx::ImageMonitorProperties::imagesToShow
std::set< size_t > imagesToShow
Definition: ImageMonitorWidgetController.h:99
ColorUtils.h
visionx::ImageMonitorWidgetController::process
void process() override
Process the vision component.
Definition: ImageMonitorWidgetController.cpp:164
visionx::tools::createByteImage
CByteImage * createByteImage(const ImageFormatInfo &imageFormat, const ImageType imageType)
Creates a ByteImage for the destination type specified in the given imageProviderInfo.
visionx::ImageMonitorWidgetController::stopRecording
void stopRecording()
Definition: ImageMonitorWidgetController.cpp:520
armarx::rtfilters::RTFilterBase::update
virtual double update(IceUtil::Time const &timestamp, double newValue)
Definition: RTFilterBase.cpp:40
visionx::ImageMonitorWidgetController::onExitImageProcessor
void onExitImageProcessor() override
Exit the ImapeProcessor component.
Definition: ImageMonitorWidgetController.cpp:159
visionx::ImageMonitorWidgetController::createSnapshot
void createSnapshot()
Definition: ImageMonitorWidgetController.cpp:465
visionx::ImageMonitorProperties::frameRate
int frameRate
Definition: ImageMonitorWidgetController.h:95
visionx::ImageMonitorWidgetController::statisticsUpdated
void statisticsUpdated(const QString &statisticsString)
visionx::ImageMonitorWidgetController::loadSettings
void loadSettings(QSettings *settings) override
Implement to load the settings that are part of the GUI configuration.
Definition: ImageMonitorWidgetController.cpp:283
visionx::ImageMonitorProperties::recordingMethods
QStringList recordingMethods
Definition: ImageMonitorWidgetController.h:102
armarx::flush
const LogSender::manipulator flush
Definition: LogSender.h:251
visionx::ImageMonitorWidgetController::getCustomTitlebarWidget
QPointer< QWidget > getCustomTitlebarWidget(QWidget *parent) override
getTitleToolbar returns a pointer to the a toolbar widget of this controller.
Definition: ImageMonitorWidgetController.cpp:635
visionx::ImageProcessor::getImageTransferStats
ImageTransferStats getImageTransferStats(std::string provideNname, bool resetStats=false)
Retrieve statistics for a connection to an ImageProvider.
Definition: ImageProcessor.cpp:625
ImageViewerArea.h
visionx::ImageProcessor::usingImageProvider
void usingImageProvider(std::string name)
Registers a delayed topic subscription and a delayed provider proxy retrieval which all will be avail...
Definition: ImageProcessor.cpp:117
visionx::imrec::takeSnapshot
void takeSnapshot(const CByteImage &image, const std::filesystem::path &filePath)
Takes a snapshot using the default recording method for snapshots.
Definition: public_api.cpp:307
filename
std::string filename
Definition: VisualizationRobot.cpp:83
visionx::ImageMonitorProperties::providerName
std::string providerName
Definition: ImageMonitorWidgetController.h:94
visionx::ImageContainer
std::vector< CByteImagePtr > ImageContainer
Definition: ImageMonitorWidgetController.h:110
visionx::ImageMonitorWidgetController::getBufferedImage
const ImageContainer & getBufferedImage(unsigned int position, unsigned int &realPosition)
Definition: ImageMonitorWidgetController.cpp:365
visionx::ImageMonitorWidgetController::getAbsoluteOutputPath
std::string getAbsoluteOutputPath()
Definition: ImageMonitorWidgetController.cpp:458
visionx::ImageProcessor::getImages
int getImages(CByteImage **ppImages)
Poll images from provider.
Definition: ImageProcessor.cpp:351
armarx::armem::Time
armarx::core::time::DateTime Time
Definition: forward_declarations.h:13
visionx::ImageMonitorProperties::controlsHidden
bool controlsHidden
Definition: ImageMonitorWidgetController.h:100
visionx::ImageMonitorWidgetController::imageProviderConnected
void imageProviderConnected(bool connected)
armarx::to_string
const std::string & to_string(const std::string &s)
Definition: StringHelpers.h:40
visionx::imrec::newRecording
visionx::imrec::Recording newRecording(const std::filesystem::path &path, const std::string &name, const Format format, double fps)
Definition: public_api.cpp:237
visionx::ImageMonitorWidgetController::onInitImageProcessor
void onInitImageProcessor() override
Setup the vision component.
Definition: ImageMonitorWidgetController.cpp:134
visionx::imrec::Recording
std::shared_ptr< AbstractRecordingStrategy > Recording
Convenience alias for any recording strategy.
Definition: AbstractRecordingStrategy.h:181
armarx::rtfilters::RTFilterBase::getCurrentValue
double getCurrentValue() const
Definition: RTFilterBase.cpp:47
visionx::ImageMonitorWidget
Definition: ImageMonitorWidget.h:36
visionx::ImageProviderInfo::proxy
ImageProviderInterfacePrx proxy
proxy to image provider
Definition: ImageProcessor.h:472
visionx::FPSCounter::assureFPS
void assureFPS(float fFrameRate)
Synchronize to FPS.
Definition: FPSCounter.cpp:82
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:174
visionx::ImageMonitorWidgetController::convertToHeatMapDepthImage
void convertToHeatMapDepthImage(CByteImage *image)
Definition: ImageMonitorWidgetController.cpp:658
visionx::tools::typeNameToImageType
ImageType typeNameToImageType(const std::string &imageTypeName)
Converts an image type name as string into an ImageType integer.
Definition: TypeMapping.cpp:42
ImageUtil.h
visionx::tools::rgbToDepthValue
float rgbToDepthValue(unsigned char r, unsigned char g, unsigned char b, bool noiseResistant=false)
Definition: ImageUtil.h:142
armarx::Logging::deactivateSpam
SpamFilterDataPtr deactivateSpam(float deactivationDurationSec=10.0f, const std::string &identifier="", bool deactivate=true) const
disables the logging for the current line for the given amount of seconds.
Definition: Logging.cpp:92
armarx::ManagedIceObject::getName
std::string getName() const
Retrieve name of object.
Definition: ManagedIceObject.cpp:107
visionx::ImageMonitorProperties::outputDirectory
std::filesystem::path outputDirectory
Definition: ImageMonitorWidgetController.h:96
visionx::ImageMonitorProperties
ImageMonitorProperties brief one line description.
Definition: ImageMonitorWidgetController.h:88
TypeMapping.h
visionx::ImageProcessor::releaseImageProvider
void releaseImageProvider(std::string providerName)
Definition: ImageProcessor.cpp:137
armarx::PeriodicTask
Definition: ArmarXManager.h:70
armarx::handleExceptions
void handleExceptions()
Definition: Exception.cpp:141
visionx::ImageMonitorWidgetController::onConnectImageProcessor
void onConnectImageProcessor() override
Implement this method in the ImageProcessor in order execute parts when the component is fully initia...
Definition: ImageMonitorWidgetController.cpp:151
ArmarXDataPath.h
visionx::ImageMonitorProperties::bufferFps
float bufferFps
Definition: ImageMonitorWidgetController.h:98
armarx::ctrlutil::s
double s(double t, double s0, double v0, double a0, double j)
Definition: CtrlUtil.h:33
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
Exception.h
visionx::CByteImagePtr
std::shared_ptr< CByteImage > CByteImagePtr
Definition: ImageMonitorWidgetController.h:109
armarx::colorutils::HeatMapColor
HsvColor HeatMapColor(float percentage)
HeatMapColor calculates the color of a value between 0 and 1 on a heat map.
Definition: ColorUtils.h:158
visionx::ImageMonitorProperties::compressionType
CompressionType compressionType
Definition: ImageMonitorWidgetController.h:105
armarx::colorutils::HsvToRgb
DrawColor24Bit HsvToRgb(const HsvColor &in)
Definition: ColorUtils.h:31
visionx::ImageMonitorProperties::compressionQuality
int compressionQuality
Definition: ImageMonitorWidgetController.h:106
visionx::ImageProcessor::waitForImages
bool waitForImages(int milliseconds=1000)
Wait for new images.
Definition: ImageProcessor.cpp:275