ImageProcessor.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5  *
6  * ArmarX is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  * ArmarX is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * @package VisionX::Core
19  * @author Kai Welke (kai dot welke at kit dot edu)
20  * @author Jan Issac (jan dot issac at gmail dot com)
21  * @date 2011
22  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
23  * GNU General Public License
24  */
25 
27 
28 #include <algorithm>
29 #include <opencv2/opencv.hpp>
30 
31 // IVT
32 #include <Image/ImageProcessor.h>
33 
34 // ArmarXCore
40 
41 // VisionXTools
46 
47 using namespace armarx;
48 
49 namespace visionx
50 {
51  std::string ImageProcessor::ListenerSuffix = ".ImageListener";
52  void ImageProcessor::onInitComponent()
53  {
54  if (hasProperty("CompressionType") && hasProperty("CompressionQuality"))
55  {
56  setCompressionType(getProperty<CompressionType>("CompressionType").getValue(), getProperty<int>("CompressionQuality").getValue());
57  }
58  // call setup of vision component
59  onInitImageProcessor();
60  float cycleTime = desiredFps == 0 ? 0 : 1000.f / desiredFps;
61  processorTask = new PeriodicTask<ImageProcessor>(this, &ImageProcessor::runProcessor, cycleTime, false, "ImageProcessingThread", false);
62  if (cycleTime == 0)
63  {
64  processorTask->setDelayWarningTolerance(1000);
65  }
66  else
67  {
68  processorTask->setDelayWarningTolerance(cycleTime * 5);
69  }
70  }
71 
72  void ImageProcessor::onConnectComponent()
73  {
74  onConnectImageProcessor();
75 
76  // create processor task
77  if (startProcessorTask)
78  {
79  processorTask->start();
80  }
81  }
82 
83  void ImageProcessor::onDisconnectComponent()
84  {
85  processorTask->stop();
86  onDisconnectImageProcessor();
87  }
88 
89  void ImageProcessor::onExitComponent()
90  {
91  ARMARX_VERBOSE << "ImageProcessor::onExitComponent()";
92  onExitImageProcessor();
93 
94  cleanup();
95  }
96 
97  PropertyDefinitionsPtr ImageProcessor::createPropertyDefinitions()
98  {
100  getConfigIdentifier()));
101  }
102 
103  void ImageProcessor::runProcessor()
104  {
105 
106 
107  // call process method of sub class
108  process();
109 
110  }
111 
112  std::string ImageProcessor::getImageListenerTopicName(std::string providerName) const
113  {
114  return providerName + ListenerSuffix;
115  }
116 
117  void ImageProcessor::usingImageProvider(std::string providerName)
118  {
119  // use image event topic
120  ARMARX_VERBOSE << "Using ImageProvider " << providerName;
121  usingTopic(getImageListenerTopicName(providerName));
122 
123  // create shared memory consumer
125  if (hasProperty("ForceIceTransfer") && getProperty<bool>("ForceIceTransfer").getValue())
126  {
127  consumer->setTransferMode(armarx::eIce);
128  }
129  // insert into map
130  std::pair<std::string, armarx::IceSharedMemoryConsumer<unsigned char>::pointer_type> consumer_info;
131  consumer_info.first = providerName;
132  consumer_info.second = consumer;
133 
134  usedImageProviders.insert(consumer_info);
135  }
136 
137  void ImageProcessor::releaseImageProvider(std::string providerName)
138  {
139 
140  auto it = usedImageProviders.find(providerName);
141  if (it != usedImageProviders.end())
142  {
143  removeProxyDependency(providerName);
145  removeProxyDependency(consumer->getMemoryName());
146  unsubscribeFromTopic(getImageListenerTopicName(providerName));
147  imageProviderInfoMap.erase(providerName);
148  usedImageProviders.erase(it);
149  }
150  }
151 
152  ImageProviderInfo ImageProcessor::getImageProvider(std::string providerName, ImageType destinationImageType, bool waitForProxy)
153  {
154  // create imageproviderinfo
155  ImageProviderInfo provider_info;
156 
157  std::unique_lock lock(imageProviderInfoMutex);
158 
159  //////////////////////////
160  // image format handling
161  //////////////////////////
162  // get proxy for image polling
163  provider_info.proxy = getProxy<ImageProviderInterfacePrx>(providerName, waitForProxy);
164 
165  provider_info.imageFormat = provider_info.proxy->getImageFormat();
166  provider_info.numberImages = provider_info.proxy->getNumberImages();
167  provider_info.destinationImageType = destinationImageType;
168  provider_info.buffer.resize(provider_info.numberImages * provider_info.imageFormat.dimension.width * provider_info.imageFormat.dimension.height * provider_info.imageFormat.bytesPerPixel);
169 
170  //////////////////////////
171  // synchronisation
172  //////////////////////////
173  provider_info.imageAvailableEvent.reset(new std::condition_variable);
174  provider_info.imageAvailable = false;
175 
176  // update image provider info (and lock mutex exclusively for writing)
177  std::pair<std::string, ImageProviderInfo> entry(providerName, provider_info);
178  imageProviderInfoMap.insert(entry);
179 
180  // find image provider by name
181  ImageProviderMap::iterator iter = usedImageProviders.find(providerName);
182 
183  if (iter == usedImageProviders.end())
184  {
185  usingImageProvider(providerName);
186  }
187 
188  if (!provider_info.proxy->hasSharedMemorySupport())
189  {
190  ARMARX_INFO << "shared memory not available for provider " << providerName;
191  usedImageProviders[providerName]->setTransferMode(eIce);
192  imageProviderInfoMap[providerName].imageTransferMode = eIceTransfer;
193  imageProviderInfoMap[providerName].info = new MetaInfoSizeBase(0, 0, TimeUtil::GetTime().toMicroSeconds());
194  removeProxyDependency(usedImageProviders[providerName]->getMemoryName());
195  }
196  else
197  {
198  //////////////////////////
199  // start communication
200  //////////////////////////
201  usedImageProviders[providerName]->start();
202 
203  auto transferMode = usedImageProviders[providerName]->getTransferMode();
204  switch (transferMode)
205  {
206  case eIce:
207  imageProviderInfoMap[providerName].imageTransferMode = eIceTransfer;
208  break;
209  case eSharedMem:
210  imageProviderInfoMap[providerName].imageTransferMode = eSharedMemoryTransfer;
211  break;
212  }
213  }
214 
215  std::unique_lock lock2(statisticsMutex);
216  statistics[providerName].pollingFPS.reset();
217  statistics[providerName].imageProviderFPS.reset();
218 
219  return provider_info;
220  }
221 
222  ImageProviderInfo ImageProcessor::getImageProvider(std::string name, bool waitForProxy, ImageType destinationImageType)
223  {
224  return getImageProvider(name, destinationImageType, waitForProxy);
225  }
226 
227  void ImageProcessor::enableResultImages(int numberImages, ImageDimension imageDimension, ImageType imageType, const std::string& name)
228  {
229  if (!resultImageProvider)
230  {
231  ARMARX_VERBOSE << "Enabling ResultImageProvider with " << numberImages << " result images.";
232  resultImageProvider = Component::create<ResultImageProvider>();
233  resultImageProvider->setName(name.empty() ? getName() + "Result" : name);
234 
235  getArmarXManager()->addObject(resultImageProvider);
236 
237  resultImageProvider->setNumberResultImages(numberImages);
238  resultImageProvider->setResultImageFormat(imageDimension, imageType);
239 
240  // wait for resultImageProvider
241  resultImageProvider->getObjectScheduler()->waitForObjectState(eManagedIceObjectStarted);
242  }
243  }
244 
245  void ImageProcessor::provideResultImages(CByteImage** images, armarx::MetaInfoSizeBasePtr info)
246  {
247  if (resultImageProvider)
248  {
249  if (info)
250  {
251  resultImageProvider->provideResultImages(images, info->timeProvided);
252  }
253  else
254  {
255  resultImageProvider->provideResultImages(images, armarx::TimeUtil::GetTime().toMicroSeconds());
256  }
257  }
258  }
259 
260  void ImageProcessor::provideResultImages(const std::vector<CByteImageUPtr >& images, MetaInfoSizeBasePtr info)
261  {
262  if (resultImageProvider)
263  {
264  if (info)
265  {
266  resultImageProvider->provideResultImages(images, info->timeProvided);
267  }
268  else
269  {
270  resultImageProvider->provideResultImages(images, armarx::TimeUtil::GetTime().toMicroSeconds());
271  }
272  }
273  }
274 
275  bool ImageProcessor::waitForImages(int milliseconds)
276  {
277  if (imageProviderInfoMap.size() == 0)
278  {
279  ARMARX_ERROR << "Calling getImages without ImageProvider name, and no ImageProvider is available - did you forget to call useImageProvider?";
280  return false;
281  }
282  else if (imageProviderInfoMap.size() > 1)
283  {
284  std::string outputText = "Several image providers are available - using the first one in the list:";
285  std::map<std::string, ImageProviderInfo>::iterator iter;
286 
287  for (iter = imageProviderInfoMap.begin(); iter != imageProviderInfoMap.end(); iter++)
288  {
289  outputText << " " << iter->first;
290  }
291 
292  ARMARX_VERBOSE << outputText;
293  }
294 
295  return waitForImages(imageProviderInfoMap.begin()->first, milliseconds);
296  }
297 
298  bool ImageProcessor::waitForImages(std::string providerName, int milliseconds)
299  {
300  std::shared_ptr<std::condition_variable> cond;
301  {
302  // lock image provider info mutex for reading
303  std::unique_lock lock(imageProviderInfoMutex);
304  // find image provider by name
305  std::map<std::string, ImageProviderInfo>::iterator iter = imageProviderInfoMap.find(providerName);
306 
307  if (iter == imageProviderInfoMap.end())
308  {
309  ARMARX_ERROR << "Trying to wait for images from unknown image provider. Call useImageProvider before";
310  return false;
311  }
312  cond = iter->second.imageAvailableEvent;
313  }
314 
315 
316  ARMARX_DEBUG << "Waiting for images from provider proxy " << providerName;
317 
318  // wait for conditionale
319  std::mutex mut;
320  std::unique_lock lock(mut);
321  auto td = std::chrono::milliseconds(milliseconds);
322 
323  return cond->wait_for(lock, td) != std::cv_status::timeout;
324  }
325 
326  bool ImageProcessor::waitForImages(std::string providerName, IceUtil::Time waitTime)
327  {
328  return waitForImages(providerName, static_cast<int>(waitTime.toMilliSeconds()));
329  }
330 
331  bool ImageProcessor::isNewImageAvailable()
332  {
333  return isNewImageAvailable(imageProviderInfoMap.begin()->first);
334  }
335 
336  bool ImageProcessor::isNewImageAvailable(const std::string& providerName)
337  {
338  std::unique_lock lock(imageProviderInfoMutex);
339  std::map<std::string, ImageProviderInfo>::iterator iter = imageProviderInfoMap.find(providerName);
340 
341  if (iter == imageProviderInfoMap.end())
342  {
343  ARMARX_ERROR << "Trying access unknown image provider. Call useImageProvider before";
344  return false;
345  }
346 
347  bool result = iter->second.imageAvailable;
348  return result;
349  }
350 
351  int ImageProcessor::getImages(CByteImage** ppImages)
352  {
353  int numberOfImages = getNumberOfImages();
354 
355  if (!ppImages)
356  {
357  ARMARX_ERROR << "ppImages must not be NULL!";
358  }
359  else for (int i = 0; i < numberOfImages; ++i)
360  {
361  if (!ppImages[i])
362  {
363  ARMARX_ERROR << "ppImages[i] must not be NULL!";
364  }
365  }
366 
367  void** ppBuffer = new void* [numberOfImages];
368 
369  for (int i = 0; i < numberOfImages; ++i)
370  {
371  ppBuffer[i] = (void*) ppImages[i]->pixels;
372  }
373 
374  numberOfImages = getImages(ppBuffer);
375  delete[] ppBuffer;
376 
377  return numberOfImages;
378  }
379 
380  int ImageProcessor::getImages(CFloatImage** ppImages)
381  {
382  int numberOfImages = getNumberOfImages();
383 
384  void** ppBuffer = new void* [numberOfImages];
385 
386  for (int i = 0; i < numberOfImages; ++i)
387  {
388  ppBuffer[i] = (void*) ppImages[i]->pixels;
389  }
390 
391  numberOfImages = getImages(ppBuffer);
392  delete[] ppBuffer;
393 
394  return numberOfImages;
395  }
396 
397  int ImageProcessor::getImages(void** ppBuffer)
398  {
399  if (imageProviderInfoMap.size() == 0)
400  {
401  ARMARX_ERROR << "Calling getImages without ImageProvider name, and no ImageProvider is available - did you forget to call useImageProvider?";
402  return false;
403  }
404  else if (imageProviderInfoMap.size() > 1)
405  {
406  std::string outputText = "Several image providers are available - using the first one in the list:";
407  std::map<std::string, ImageProviderInfo>::iterator iter;
408 
409  for (iter = imageProviderInfoMap.begin(); iter != imageProviderInfoMap.end(); iter++)
410  {
411  outputText << " " << iter->first;
412  }
413 
414  ARMARX_VERBOSE << outputText;
415  }
416  std::string providerName;
417  {
418  std::unique_lock lock(imageProviderInfoMutex);
419  providerName = imageProviderInfoMap.begin()->first;
420  }
421 
422 
423  armarx::MetaInfoSizeBasePtr info;
424  return getImages(providerName, ppBuffer, info);
425  }
426 
427  int ImageProcessor::getImages(std::string providerName, CByteImage** ppImages, armarx::MetaInfoSizeBasePtr& info)
428  {
429  int numberOfImages = getNumberOfImages(providerName);
430 
431  void** ppBuffer = new void* [numberOfImages];
432 
433  for (int i = 0; i < numberOfImages; ++i)
434  {
435  ppBuffer[i] = (void*) ppImages[i]->pixels;
436  }
437 
438  numberOfImages = getImages(providerName, ppBuffer, info);
439  delete[] ppBuffer;
440 
441  return numberOfImages;
442  }
443 
444  int ImageProcessor::getImages(std::string providerName, const std::vector<CByteImageUPtr >& ppImages, MetaInfoSizeBasePtr& info)
445  {
446  int numberOfImages = getNumberOfImages(providerName);
447 
448  void** ppBuffer = new void* [numberOfImages];
449 
450  for (int i = 0; i < numberOfImages; ++i)
451  {
452  ppBuffer[i] = (void*) ppImages.at(i)->pixels;
453  }
454 
455  numberOfImages = getImages(providerName, ppBuffer, info);
456  delete[] ppBuffer;
457 
458  return numberOfImages;
459  }
460 
461  int ImageProcessor::getImages(std::string providerName, CFloatImage** ppImages, armarx::MetaInfoSizeBasePtr& info)
462  {
463  int numberOfImages = getNumberOfImages(providerName);
464 
465  void** ppBuffer = new void* [numberOfImages];
466 
467  for (int i = 0; i < numberOfImages; ++i)
468  {
469  ppBuffer[i] = (void*) ppImages[i]->pixels;
470  }
471 
472  numberOfImages = getImages(providerName, ppBuffer, info);
473  delete[] ppBuffer;
474 
475  return numberOfImages;
476  }
477 
478  int ImageProcessor::getImages(std::string providerName, void** ppBuffer, armarx::MetaInfoSizeBasePtr& info)
479  {
480  int numberImages = -1;
481  {
482  // lock image provider info mutex for reading (and changing imageAvailable);
483 
484  std::unique_lock lock(imageProviderInfoMutex);
485 
486  // find image provider
487  std::map<std::string, ImageProviderInfo>::iterator iter = imageProviderInfoMap.find(providerName);
488 
489  if (iter == imageProviderInfoMap.end())
490  {
491  ARMARX_ERROR << "Trying to retrieve images from unknown image provider. Call useImageProvider before";
492  return 0;
493  }
494 
495  numberImages = iter->second.numberImages;
496 
497  // check if new images are available
498  if (!iter->second.imageAvailable)
499  {
500  ARMARX_IMPORTANT << "No image available";
501  return 0;
502  }
503 
504 
505  ImageProviderInfo& providerInfo = iter->second;
506  if (providerInfo.imageTransferMode == eIceTransfer)
507  {
508  CompressedImageProviderInterfacePrx compressedImageProvider;
509  if (compressionType != eNoCompression)
510  {
511  compressedImageProvider = CompressedImageProviderInterfacePrx::checkedCast(iter->second.proxy);
512  if (!compressedImageProvider)
513  {
514  ARMARX_WARNING << deactivateSpam(10000000, iter->first) << "Trying to use image provider as CompressedImageProviderInterfacePrx, but it is not of this type: " << iter->second.proxy->ice_id();
515  }
516  }
517  if (compressionType != eNoCompression && compressedImageProvider)
518  {
519  ARMARX_DEBUG << deactivateSpam(10) << "Using compressed images";
520  auto blob = compressedImageProvider->getCompressedImagesAndMetaInfo(compressionType, compressionQuality, providerInfo.info);
521  ARMARX_CHECK_GREATER(blob.size(), 0);
522  ARMARX_DEBUG << deactivateSpam(10) << "Got image blob of size " << blob.size();
523  cv::Mat mat = cv::imdecode(blob, cv::IMREAD_COLOR);
524  ARMARX_CHECK_GREATER(mat.size().area(), 0);
525  ARMARX_DEBUG << deactivateSpam(10) << "decoded image to size " << mat.size().width << "x" << mat.size().height << ", bpp: " << mat.channels();
526  providerInfo.buffer = Blob(mat.datastart, mat.dataend);
527  ARMARX_DEBUG << deactivateSpam(10) << "decoded blob size " << providerInfo.buffer.size();
528  }
529  else
530  {
531  Blob blob;
532  try
533  {
534  blob = iter->second.proxy->getImagesAndMetaInfo(providerInfo.info);
535  ARMARX_DEBUG << deactivateSpam(1) << "The image is " << (TimeUtil::GetTime() - IceUtil::Time::microSeconds(providerInfo.info->timeProvided)).toMilliSecondsDouble() << " ms old, timestamp: " << providerInfo.info->timeProvided;
536  }
537  catch (...)
538  {
539  ARMARX_INFO << deactivateSpam(10) << "using fall back remote procedure call without timestamp!";
540 
541  providerInfo.info->timeProvided = TimeUtil::GetTime().toMicroSeconds();
542  blob = iter->second.proxy->getImages();
543  }
544 
545  blob.swap(providerInfo.buffer);
546  }
547  }
548  else
549  {
550  usedImageProviders[providerName]->getData(providerInfo.buffer, providerInfo.info);
551  }
552  // poll images
553  int imageSize = providerInfo.imageFormat.dimension.width * providerInfo.imageFormat.dimension.height * providerInfo.imageFormat.bytesPerPixel;
554 
555  // copy images
556  for (int i = 0 ; i < numberImages ; i++)
557  {
558  visionx::tools::convertImage(iter->second, &iter->second.buffer[0] + i * imageSize, ppBuffer[i]);
559  }
560 
561  info = iter->second.info;
562 
563  // set image available to false
564  iter->second.imageAvailable = false;
565  }
566 
567 
568 
569  // update statistics
570  std::unique_lock lock(statisticsMutex);
571  statistics[providerName].pollingFPS.update();
572 
573  return numberImages;
574  }
575 
576 
577  int ImageProcessor::getNumberOfImages(const std::string& providerName)
578  {
579  if (imageProviderInfoMap.size() == 0 && providerName.empty())
580  {
581  ARMARX_ERROR << "Calling getNumberOfImages() without ImageProvider name, and no ImageProvider is available - did you forget to call useImageProvider?";
582  return 0;
583  }
584  else if (imageProviderInfoMap.size() > 1 && providerName.empty())
585  {
586  std::string outputText = "Several image providers are available and no name was specified when calling getNumberOfImages() - using the first one in the list:";
587  std::map<std::string, ImageProviderInfo>::iterator iter;
588 
589  for (iter = imageProviderInfoMap.begin(); iter != imageProviderInfoMap.end(); iter++)
590  {
591  outputText << " " << iter->first;
592  }
593 
594  ARMARX_VERBOSE << outputText;
595  }
596 
597  int numberOfImages = 0;
598 
599  if (providerName.empty())
600  {
601  std::unique_lock lock(imageProviderInfoMutex);
602 
603  numberOfImages = imageProviderInfoMap.begin()->second.numberImages;
604  }
605  else
606  {
607  std::unique_lock lock(imageProviderInfoMutex);
608 
609  // find image provider
610  std::map<std::string, ImageProviderInfo>::iterator iter = imageProviderInfoMap.find(providerName);
611 
612  if (iter == imageProviderInfoMap.end())
613  {
614  ARMARX_ERROR << "Trying to retrieve images from unknown image provider. Call useImageProvider before";
615  return 0;
616  }
617 
618  numberOfImages = iter->second.numberImages;
619  }
620 
621  return numberOfImages;
622  }
623 
624 
625  ImageTransferStats ImageProcessor::getImageTransferStats(std::string providerName, bool resetStats)
626  {
627  std::unique_lock lock(statisticsMutex);
628 
629  std::map<std::string, ImageTransferStats>::iterator iter = statistics.find(providerName);
630 
631  if (iter == statistics.end())
632  {
633  ARMARX_ERROR << "Requesting statistics for unknown image provider (" << providerName << ")";
634  return ImageTransferStats();
635  }
636 
637  ImageTransferStats stats = iter->second;
638 
639  if (resetStats)
640  {
641  iter->second.imageProviderFPS.reset();
642  iter->second.pollingFPS.reset();
643  }
644  else
645  {
646  iter->second.imageProviderFPS.recalculate();
647  iter->second.pollingFPS.recalculate();
648  }
649 
650  return stats;
651  }
652 
653  MetaInfoSizeBasePtr ImageProcessor::getImageMetaInfo(const std::string& imageProviderName) const
654  {
655 
656  ARMARX_WARNING << "deprecated. Use getImages() instead.";
657 
658  if (usedImageProviders.empty())
659  {
660  ARMARX_WARNING << "usedImageProviders is empty";
661  return NULL;
662  }
663  if (imageProviderName.empty())
664  {
665  return usedImageProviders.begin()->second->getMetaInfo();
666  }
667  else
668  {
669  auto it = usedImageProviders.find(imageProviderName);
670  if (it != usedImageProviders.end())
671  {
672  return it->second->getMetaInfo();
673  }
674  else
675  {
676  ARMARX_ERROR << "Requesting meta info for unknown image provider (" << imageProviderName << ")";
677  return NULL;
678  }
679  }
680  }
681 
682  void ImageProcessor::setFramerate(float fps)
683  {
684  this->desiredFps = fps;
685  if (processorTask)
686  {
687  processorTask->changeInterval(1000.f / fps);
688  }
689  }
690 
691  float ImageProcessor::getFramerate() const
692  {
693  return desiredFps;
694  }
695 
696  void ImageProcessor::setCompressionType(CompressionType compressionType, int compressionQuality)
697  {
698  ARMARX_VERBOSE << "Setting compression to " << (int)compressionType << " and quality " << compressionQuality;
699  this->compressionType = compressionType;
700  this->compressionQuality = compressionQuality;
701  }
702 
703  void ImageProcessor::reportImageAvailable(const std::string& providerName, const Ice::Current& c)
704  {
705  {
706  // lock mutex for reading
707  std::unique_lock lock(imageProviderInfoMutex);
708  // find provider
709  std::map<std::string, ImageProviderInfo>::iterator iter = imageProviderInfoMap.find(providerName);
710 
711  if (iter == imageProviderInfoMap.end())
712  {
713  ARMARX_ERROR << deactivateSpam(10, providerName) << "Received notification from unknown imageprovider (" << providerName << ")";
714 
715  return;
716  }
717 
718  iter->second.imageAvailable = true;
719  iter->second.imageAvailableEvent->notify_all();
720  ARMARX_DEBUG << "Got notification of image provider " << providerName;
721  }
722 
723  // update statistics
724  std::unique_lock lock(statisticsMutex);
725  statistics[providerName].imageProviderFPS.update();
726  }
727 
728  void ImageProcessor::cleanup()
729  {
730  std::map<std::string, ImageProviderInfo>::iterator iter = imageProviderInfoMap.begin();
731 
732  while (iter != imageProviderInfoMap.end())
733  {
734  iter++;
735  }
736 
737  if (resultImageProvider)
738  {
739  getArmarXManager()->removeObjectBlocking(resultImageProvider);
740  }
741  }
742 
743  void ImageProcessor::componentPropertiesUpdated(const std::set<std::string>& changedProperties)
744  {
745  // ARMARX_INFO << VAROUT(changedProperties);
746  if (changedProperties.count("CompressionType"))
747  {
748  setCompressionType(getProperty<CompressionType>("CompressionType").getValue());
749  }
750  if (changedProperties.count("CompressionQuality"))
751  {
752  setCompressionType(getProperty<CompressionType>("CompressionType").getValue(), getProperty<int>("CompressionQuality").getValue());
753  }
754  }
755 
756 
757 
758  int ImageProcessor::getCompressionQuality() const
759  {
760  return compressionQuality;
761  }
762 
763  CompressionType ImageProcessor::getCompressionType() const
764  {
765  return compressionType;
766  }
767 }
ARMARX_VERBOSE
#define ARMARX_VERBOSE
Definition: Logging.h:180
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
OnScopeExit.h
ArmarXManager.h
visionx::ImageTransferStats
The ImageTransferStats class provides information on the connection between ImageProvider and ImagePr...
Definition: ImageProcessor.h:441
ARMARX_CHECK_GREATER
#define ARMARX_CHECK_GREATER(lhs, rhs)
This macro evaluates whether lhs is greater (>) than rhs and if it turns out to be false it will thro...
Definition: ExpressionException.h:116
visionx::ImageTransferStats::imageProviderFPS
FPSCounter imageProviderFPS
Statistics for the images announced by the ImageProvider.
Definition: ImageProcessor.h:453
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:43
visionx::ImageProviderInfo::imageFormat
ImageFormatInfo imageFormat
Image format struct that contains all necessary image information.
Definition: ImageProcessor.h:496
UnsupportedImageConversionException.h
visionx::ImageProviderInfo
Definition: ImageProcessor.h:466
deactivateSpam
SpamFilterDataPtr deactivateSpam(SpamFilterDataPtr const &spamFilter, float deactivationDurationSec, const std::string &identifier, bool deactivate)
Definition: Logging.cpp:72
visionx::FPSCounter::reset
void reset()
Resets the FPS counter to its initial state.
Definition: FPSCounter.cpp:49
visionx::ImageProviderInfo::imageAvailable
bool imageAvailable
Indicates whether an image is available.
Definition: ImageProcessor.h:511
ImageProcessor.h
ARMARX_DEBUG
#define ARMARX_DEBUG
Definition: Logging.h:177
ArmarXObjectScheduler.h
visionx::ImageProviderInfo::imageAvailableEvent
std::shared_ptr< std::condition_variable > imageAvailableEvent
Conditional variable used internally for synchronization purposes.
Definition: ImageProcessor.h:516
ARMARX_ERROR
#define ARMARX_ERROR
Definition: Logging.h:189
HardwareId.h
armarx::armem::Time
armarx::core::time::DateTime Time
Definition: forward_declarations.h:13
visionx::tools::convertImage
void convertImage(const ImageFormatInfo &imageFormat, const ImageType destinationImageType, void *inputData, void *outputData)
This converts the input image data into a desired destination image data type specified in the given ...
armarx::TimeUtil::GetTime
static IceUtil::Time GetTime(TimeMode timeMode=TimeMode::VirtualTime)
Get the current time.
Definition: TimeUtil.cpp:42
ExpressionException.h
visionx::ImageProviderInfo::destinationImageType
ImageType destinationImageType
Required image destination type.
Definition: ImageProcessor.h:491
visionx::ImageProviderInfo::proxy
ImageProviderInterfacePrx proxy
proxy to image provider
Definition: ImageProcessor.h:472
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:174
IceUtil::Handle< class PropertyDefinitionContainer >
visionx::ImageProcessorPropertyDefinitions
Definition: ImageProcessor.h:61
ImageUtil.h
armarx::IceSharedMemoryConsumer
Definition: IceSharedMemoryConsumer.h:50
visionx::ImageProviderInfo::info
armarx::MetaInfoSizeBasePtr info
meta info
Definition: ImageProcessor.h:482
TypeMapping.h
visionx::ImageProviderInfo::buffer
std::vector< unsigned char > buffer
memory block
Definition: ImageProcessor.h:477
armarx::PeriodicTask
Definition: ArmarXManager.h:70
visionx::ImageProviderInfo::imageTransferMode
ImageTransferMode imageTransferMode
Transfer mode of images.
Definition: ImageProcessor.h:501
ARMARX_WARNING
#define ARMARX_WARNING
Definition: Logging.h:186
armarx::PropertyDefinitionsPtr
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
Definition: forward_declarations.h:34
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
Exception.h