ImageProvider.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  * @date 2011
21  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22  * GNU General Public License
23  */
24 
25 
26 #include "ImageProvider.h"
27 
28 
29 // STD/STL
30 #include <iostream>
31 #include <string>
32 
33 // OpenCV
34 #include <opencv2/opencv.hpp>
35 
36 // Simox
37 #include <SimoxUtility/algorithm.h>
38 
39 // ArmarX
42 #include <ArmarXCore/util/time.h>
46 
47 
48 namespace visionx
49 {
50 
51  // ================================================================== //
52  // == ImageProvider ice interface =================================== //
53  // ================================================================== //
54  armarx::Blob ImageProvider::getImages(const Ice::Current&)
55  {
56  if (numberImages == 0)
57  {
58  return armarx::Blob();
59  }
60 
61  return sharedMemoryProvider->getData();
62  }
63 
64 
65  armarx::Blob ImageProvider::getImagesAndMetaInfo(armarx::MetaInfoSizeBasePtr& info, const Ice::Current&)
66  {
67  if (numberImages == 0)
68  {
69  return armarx::Blob();
70  }
71  return sharedMemoryProvider->getData(info);
72  }
73 
74 
75  ImageFormatInfo ImageProvider::getImageFormat(const Ice::Current&)
76  {
77  return imageFormat;
78  }
79 
80  int ImageProvider::getNumberImages(const Ice::Current&)
81  {
82  return numberImages;
83  }
84 
85  // ================================================================== //
86  // == Component implementation =============================== //
87  // ================================================================== //
89  {
91  // init members
92  exiting = false;
93 
94  // default image format (640x480, bayerpattern).
95  // call from within init to change!
96  setImageFormat(ImageDimension(640, 480), eBayerPattern, eBayerPatternRg);
97  setNumberImages(0);
98 
99  // call setup of image provider implementation to setup image size
101  }
102 
103 
105  {
106  ARMARX_INFO << "onConnectComponent " << getName();
107  ARMARX_TRACE;
108  // init shared memory
109  int imageSize = getImageFormat().dimension.width * getImageFormat().dimension.height * getImageFormat().bytesPerPixel;
110 
111  if (numberImages != 0)
112  {
113  armarx::MetaInfoSizeBasePtr info(new armarx::MetaInfoSizeBase(getNumberImages() * imageSize, getNumberImages() * imageSize, 0));
115  {
117  }
118  sharedMemoryProvider = new armarx::IceSharedMemoryProvider<unsigned char>(this, info, "ImageProvider");
119 
120  // reference to shared memory
121  imageBuffers = (void**) new unsigned char* [getNumberImages()];
122 
123  for (int i = 0 ; i < getNumberImages() ; i++)
124  {
125  imageBuffers[i] = sharedMemoryProvider->getBuffer() + i * imageSize;
126  }
127 
128  // offer topic for image events
129  offeringTopic(getName() + ".ImageListener");
130 
131  // retrieve storm topic proxy
132  imageProcessorProxy = getTopic<ImageProcessorInterfacePrx>(getName() + ".ImageListener");
133 
134  // start icesharedmemory provider
136  }
137 
139  }
140 
142  {
143  ARMARX_TRACE;
146  {
148  sharedMemoryProvider = nullptr;
149  }
150  }
151 
153  {
154  ARMARX_TRACE;
155  exiting = true;
156 
158 
159  if (numberImages != 0)
160  {
161  delete [] imageBuffers;
162  }
163  }
164 
165  void ImageProvider::updateTimestamp(Ice::Long timestamp, bool threadSafe)
166  {
167  ARMARX_TRACE;
168  auto sharedMemoryProvider = this->sharedMemoryProvider; // preserve from deleting
170  {
171  ARMARX_INFO << "Shared memory provider is null!"
172  << " Did you forget to set call setNumberImages and setImageFormat in onInitImageProvider?";
173  return;
174  }
175  armarx::MetaInfoSizeBasePtr info = this->sharedMemoryProvider->getMetaInfo(threadSafe);
176  if (info)
177  {
178  info->timeProvided = timestamp;
179  }
180  else
181  {
182  info = new armarx::MetaInfoSizeBase(imageFormat.dimension.width * imageFormat.dimension.height * imageFormat.bytesPerPixel,
183  imageFormat.dimension.width * imageFormat.dimension.height * imageFormat.bytesPerPixel,
184  timestamp);
185  }
186 
187  this->sharedMemoryProvider->setMetaInfo(info, threadSafe);
188  }
189 
190  void ImageProvider::updateTimestamp(IceUtil::Time timestamp, bool threadSafe)
191  {
192  ARMARX_TRACE;
193  updateTimestamp(timestamp.toMicroSeconds(), threadSafe);
194  }
195 
196  void ImageProvider::updateTimestamp(const armarx::core::time::DateTime& timestamp, bool threadSafe)
197  {
198  ARMARX_TRACE;
199  updateTimestamp(timestamp.toMicroSecondsSinceEpoch(), threadSafe);
200  }
201 
202  armarx::Blob ImageProvider::getCompressedImagesAndMetaInfo(CompressionType compressionType, Ice::Int compressionQuality, armarx::MetaInfoSizeBasePtr& info, const Ice::Current&)
203  {
204  int type;
205  switch (imageFormat.type)
206  {
207  case eRgb:
208  type = CV_8UC3;
209  break;
210  case eGrayScale:
211  type = CV_8UC1;
212  break;
213  default:
214  throw armarx::LocalException() << "unsupported image type " << (int)(imageFormat.type);
215  }
216 
218  return {};
220  if (!lock) // already shutdown
221  {
222  return {};
223  }
224  if (numberImages == 0)
225  {
226  return armarx::Blob();
227  }
228  info = new armarx::MetaInfoSizeBase(*sharedMemoryProvider->getMetaInfo());
229 
230  auto imageTimestamp = IceUtil::Time::microSeconds(info->timeProvided);
231  auto key = std::make_pair(compressionType, compressionQuality);
232 
233  std::unique_lock lock2(compressionDataMapMutex);
234  if (compressionDataMap.count(key) && compressionDataMap.at(key).imageTimestamp == imageTimestamp)
235  {
236  ARMARX_VERBOSE << deactivateSpam(1) << "using already compressed image";
237  return compressionDataMap.at(key).compressedImage;
238  }
239  cv::Mat mat(imageFormat.dimension.height * numberImages, imageFormat.dimension.width, type, imageBuffers[0]);
240 
241 
242  armarx::Blob encodedImg;
243 
244  std::vector<int> compression_params;
245  std::string extension;
246  switch (compressionType)
247  {
248  case ePNG:
249  extension = ".png";
250  compression_params = {cv::IMWRITE_PNG_COMPRESSION, compressionQuality,
251  cv::IMWRITE_PNG_STRATEGY, cv::IMWRITE_PNG_STRATEGY_RLE
252  };
253  break;
254  case eJPEG:
255  extension = ".jpg";
256  compression_params.push_back(cv::IMWRITE_JPEG_QUALITY);
257  compression_params.push_back(compressionQuality);
258  break;
259  default:
260  throw armarx::LocalException() << "unsupported image type " << (int)(imageFormat.type);
261  }
262  cv::imencode("*" + extension, mat, encodedImg, compression_params);
263 
264  compressionDataMap[key] = {encodedImg, imageTimestamp};
265 
266  // cv::imwrite("/tmp/compressed" + extension, mat, compression_params);
267  ARMARX_DEBUG << deactivateSpam(1) << "size before compression: " << imageFormat.dimension.height* numberImages* imageFormat.dimension.width* imageFormat.bytesPerPixel << " size after: " << encodedImg.size();
268  return encodedImg;
269  }
270 
271 
272  // ================================================================== //
273  // == Utility methods for ImageProviders ============================ //
274  // ================================================================== //
275  void ImageProvider::setImageFormat(ImageDimension imageDimension,
276  ImageType imageType,
277  BayerPatternType bayerPatternType)
278  {
279  ARMARX_TRACE;
280  imageFormat.dimension = imageDimension;
281  imageFormat.type = imageType;
282  imageFormat.bpType = bayerPatternType;
283 
284  switch (imageType)
285  {
286  case eGrayScale:
287  case eBayerPattern:
288  imageFormat.bytesPerPixel = 1;
289  break;
290 
291  case eRgb:
292  imageFormat.bytesPerPixel = 3;
293  break;
294 
295  case eFloat1Channel:
296  imageFormat.bytesPerPixel = 4;
297  break;
298 
299  case eFloat3Channels:
300  imageFormat.bytesPerPixel = 12;
301  break;
302 
303  case ePointsScan:
304  imageFormat.bytesPerPixel = 12;
305  break;
306 
307  case eColoredPointsScan:
308  imageFormat.bytesPerPixel = 16;
309  break;
310  }
311  }
312 
313  void ImageProvider::setNumberImages(int numberImages)
314  {
315  ARMARX_TRACE;
316  this->numberImages = numberImages;
317  }
318 
319  void ImageProvider::provideImages(void** inputBuffers, const IceUtil::Time& imageTimestamp)
320  {
321  ARMARX_TRACE;
322  if (numberImages == 0)
323  {
324  ARMARX_INFO << "Number of images is 0 - thus none can be provided";
325  return;
326  }
327 
328  int imageSize = imageFormat.dimension.width * imageFormat.dimension.height * imageFormat.bytesPerPixel;
329 
330  // copy
331  {
332  // lock memory access
334  if (!lock) // already shutdown
335  {
336  return;
337  }
338  if (imageTimestamp > IceUtil::Time())
339  {
340  updateTimestamp(imageTimestamp, false);
341  }
342  for (int i = 0 ; i < numberImages ; i++)
343  {
344  memcpy(imageBuffers[i], inputBuffers[i], imageSize);
345  }
346  }
347 
348  recordImages(imageTimestamp);
349 
350  // notify processors
352  {
353  ARMARX_DEBUG << "Notifying ImageProcessorProxy";
354  imageProcessorProxy->reportImageAvailable(getName());
355  }
356  else
357  {
358  ARMARX_ERROR << deactivateSpam(4) << "imageProcessorProxy is NULL - could not report Image available";
359  }
360  }
361 
362  void ImageProvider::provideImages(CByteImage** images, const IceUtil::Time& imageTimestamp)
363  {
364  ARMARX_TRACE;
365  if (numberImages == 0)
366  {
367  ARMARX_INFO << "Number of images is 0 - thus none can be provided";
368  return;
369  }
370 
371  //ISO C++ forbids variable length array [-Werror=vla] => use a vector (the array will be on the heap anyways)
372  std::vector<void*> imageBuffers(numberImages);
373 
374  for (int i = 0 ; i < numberImages ; i++)
375  {
376  //ARMARX_VERBOSE << i;
377  imageBuffers[i] = images[i]->pixels;
378  }
379 
380  provideImages(imageBuffers.data(), imageTimestamp);
381  }
382 
383  void ImageProvider::provideImages(const std::vector<CByteImageUPtr >& images, const IceUtil::Time& imageTimestamp)
384  {
385  ARMARX_TRACE;
386  if (numberImages == 0)
387  {
388  ARMARX_INFO << "Number of images is 0 - thus none can be provided";
389  return;
390  }
391 
392  //ISO C++ forbids variable length array [-Werror=vla] => use a vector (the array will be on the heap anyways)
393  std::vector<void*> imageBuffers(numberImages);
394 
395  for (int i = 0 ; i < numberImages ; i++)
396  {
397  //ARMARX_VERBOSE << i;
398  imageBuffers[i] = images[i]->pixels;
399  }
400 
401  provideImages(imageBuffers.data(), imageTimestamp);
402  }
403 
404  void ImageProvider::provideImages(CFloatImage** images, const IceUtil::Time& imageTimestamp)
405  {
406  ARMARX_TRACE;
407  if (numberImages == 0)
408  {
409  ARMARX_INFO << "Number of images is 0 - thus none can be provided";
410  return;
411  }
412 
413  //ISO C++ forbids variable length array [-Werror=vla] => use a vector (the array will be on the heap anyways)
414  std::vector<void*> imageBuffers(numberImages);
415 
416  for (int i = 0 ; i < numberImages ; i++)
417  {
418  imageBuffers[i] = images[i]->pixels;
419  }
420 
421  provideImages(imageBuffers.data(), imageTimestamp);
422  }
423 
424 
425  void ImageProvider::recordImages(const IceUtil::Time& image_timestamp)
426  {
427  ARMARX_TRACE;
428 
429  int imageSize = imageFormat.dimension.width * imageFormat.dimension.height * imageFormat.bytesPerPixel;
430 
431  const bool is_recording = [&]
432  {
433  ARMARX_TRACE;
434 
435  std::scoped_lock l{rec.statusMutex};
436 
437  if (rec.status.type == imrec::State::stopping)
438  {
439  rec.status.type = imrec::State::writing;
440  // Still record current frames to notify potentially waiting recording task.
441  return true;
442  }
443 
444  return rec.status.type == imrec::State::running;
445  }();
446 
447  if (is_recording)
448  {
449  ARMARX_TRACE;
450 
451  std::chrono::microseconds timestamp{image_timestamp.toMicroSeconds()};
452  std::unordered_map<int, CByteImage*> current_frames;
453  for (int i = 0; i < numberImages; ++i)
454  {
455  if (not rec.config.channelConfigs[i].disabled)
456  {
457  current_frames[i] = tools::createByteImage(imageFormat, imageFormat.type);
458  std::memcpy(current_frames[i]->pixels, imageBuffers[i], imageSize);
459  }
460  }
461 
462  ARMARX_DEBUG << "Pushing data to buffer.";
463  {
464  std::scoped_lock l{rec.bufferMutex};
465  rec.buffer.push_back({timestamp, current_frames});
466  }
467  ARMARX_DEBUG << "Signalling that buffer was filled...";
468  rec.cv.notify_all();
469  }
470  }
471 
472 
473  bool ImageProvider::startImageRecording(const imrec::Config& cfg, const Ice::Current&)
474  {
475  ARMARX_TRACE;
476 
477  ARMARX_DEBUG << "Starting recording...";
478 
479  ARMARX_CHECK_EQUAL(int(cfg.channelConfigs.size()), numberImages)
480  << "Must supply same number of channel configs as there are channels";
481 
482  std::scoped_lock l{rec.callMutex};
483 
484  {
485  std::scoped_lock l{rec.statusMutex};
486 
487  auto are_disabled = [](const auto & c)
488  {
489  return c.disabled;
490  };
491 
492  // A recording can only be started if the component is ready and if at least one channel
493  // is not disabled.
494  if (rec.status.type != imrec::State::ready
495  or std::all_of(cfg.channelConfigs.begin(), cfg.channelConfigs.end(), are_disabled))
496  {
497  return false;
498  }
499 
500  rec.status.framesWritten = 0;
501  rec.status.framesBuffered = 0;
502  rec.status.type = imrec::State::scheduled;
503  }
504 
505  rec.config = cfg;
506  rec.config.name =
507  simox::alg::replace_all(
508  rec.config.name,
509  "%TIMESTAMP%",
510  imrec::datetime_to_string(std::chrono::microseconds{rec.config.startTimestamp}));
511 
512  rec.runningTask =
514  rec.runningTask->start();
515 
516  ARMARX_DEBUG << "Scheduled recordings...";
517 
518  return true;
519  }
520 
521 
522  imrec::Status ImageProvider::getImageRecordingStatus(const Ice::Current&)
523  {
524  ARMARX_TRACE;
525 
526  std::scoped_lock l{rec.statusMutex};
527  return rec.status;
528  }
529 
530 
531  bool ImageProvider::stopImageRecording(const Ice::Current&)
532  {
533  ARMARX_TRACE;
534 
535  std::scoped_lock l{rec.callMutex};
536 
537  {
538  std::scoped_lock l{rec.statusMutex};
539 
540  // A recording can only be stopped if one is scheduled or one is running. Otherwise
541  // there is no recording which could be stopped, or a recording is still being written.
542  if (rec.status.type != imrec::State::scheduled
543  and rec.status.type != imrec::State::running)
544  {
545  return false;
546  }
547 
548  rec.status.type = imrec::State::stopping;
549  }
550 
551  ARMARX_CHECK(rec.runningTask);
552 
553  const bool join = true;
554  rec.runningTask->stop(join);
555 
556  return true;
557  }
558 
559 
561  {
562  ARMARX_TRACE;
563 
564  ARMARX_DEBUG << "Started recording task.";
565 
566  // Loop.
567  while (true)
568  {
569  ARMARX_TRACE;
570 
571  const imrec::State state = [&]
572  {
573  std::scoped_lock l{rec.statusMutex};
574  return rec.status.type;
575  }();
576 
577  // Component finished a recording and is ready again.
578  if (state == imrec::State::ready)
579  {
580  ARMARX_TRACE;
581 
582  ARMARX_DEBUG << "Recording image provider ready.";
583 
584  break; // Done. Exit loop, stop recordings now and terminate thread.
585  }
586  // Component is scheduled to start a recording.
587  else if (state == imrec::State::scheduled)
588  {
589  ARMARX_TRACE;
590 
591  const IceUtil::Time start_at = IceUtil::Time::microSeconds(rec.config.startTimestamp);
592  const IceUtil::Time now = IceUtil::Time::now();
593  if (start_at < now)
594  {
595  ARMARX_DEBUG << "Starting recordings...";
596 
597  const std::filesystem::path path =
598  armarx::PackagePath::toSystemPath(rec.config.location);
599  rec.channelRecordings.clear();
600  for (int i = 0; i < numberImages; ++i)
601  {
602  const imrec::ChannelConfig& channel_cfg = rec.config.channelConfigs[i];
603  if (not channel_cfg.disabled)
604  {
606  const std::string name = getName() + "_" + channel_cfg.name;
607  const imrec::Format format = imrec::str2format(channel_cfg.format);
608  r = visionx::imrec::newRecording(path / rec.config.name, name, format, channel_cfg.fps);
609  r->startRecording();
610  r->writeMetadataDatetime("recording_manager_time", std::chrono::microseconds{rec.config.startTimestamp});
611  r->writeMetadataLine("image_provider_name", "string", getName());
612  r->writeMetadataLine("channel_name", "string", channel_cfg.name);
613  rec.channelRecordings[i] = r;
614  }
615  }
616 
617  ARMARX_DEBUG << "Started recordings.";
618 
619  std::scoped_lock l{rec.statusMutex};
620  rec.status.type = imrec::State::running;
621  }
622 
623  ARMARX_TRACE;
624  }
625  // Component is running, stopping, or writing. Either way, try writing frames.
626  else
627  {
628  ARMARX_TRACE;
629 
630  bool write_frames = false;
631  std::chrono::microseconds timestamp;
632  std::unordered_map<int, CByteImage*> frames;
633 
634  {
635  ARMARX_DEBUG << "Fetching frames from buffer...";
636 
637  std::scoped_lock l{rec.bufferMutex, rec.statusMutex};
638  if (not rec.buffer.empty())
639  {
640  std::tie(timestamp, frames) = rec.buffer.front();
641  rec.buffer.pop_front();
642  write_frames = true;
643 
644  rec.status.framesBuffered = static_cast<long>(rec.buffer.size());
645  ++rec.status.framesWritten;
646 
647  ARMARX_DEBUG << "Fetched frames from buffer.";
648  }
649  else
650  {
651  ARMARX_DEBUG << "Buffer empty.";
652  if (state == imrec::State::writing)
653  {
654  ARMARX_DEBUG << "Buffer fully written to disk, exiting.";
655  rec.status.type = imrec::State::ready;
656  }
657  }
658  }
659 
660  if (write_frames)
661  {
662  ARMARX_DEBUG << "Writing frames...";
663 
664  for (auto& [i, frame] : frames)
665  {
666  imrec::Recording r = rec.channelRecordings.at(i);
667  r->recordFrame(*frame, timestamp);
668  delete frame;
669  }
670  frames.clear();
671 
672  ARMARX_DEBUG << "Wrote frames.";
673  }
674  else if (state == imrec::State::running)
675  {
676  std::unique_lock l{rec.bufferMutex};
677  ARMARX_DEBUG << "Waiting for new frames...";
678  rec.cv.wait(l, [&] { return not rec.buffer.empty(); });
679  ARMARX_DEBUG << "Received new frames, continuing.";
680  }
681 
682  ARMARX_TRACE;
683  }
684  }
685 
686  ARMARX_TRACE;
687 
688  ARMARX_DEBUG << "Stopping recordings...";
689 
690  // Stop.
691  for (auto& [i, r] : rec.channelRecordings)
692  {
693  r->stopRecording();
694  }
695  rec.channelRecordings.clear();
696 
697  ARMARX_DEBUG << "Done stopping recordings.";
698  ARMARX_DEBUG << "Stopping recording task...";
699 
700  ARMARX_TRACE;
701  }
702 
703 
704  std::vector<imrec::ChannelPreferences>
706  {
707  ARMARX_TRACE;
708 
709  std::vector<imrec::ChannelPreferences> default_names;
710  imrec::ChannelPreferences cp;
711  cp.requiresLossless = false;
712  for (int i = 0; i < numberImages; ++i)
713  {
714  cp.name = "c" + std::to_string(i);
715  default_names.push_back(cp);
716  }
717  return default_names;
718  }
719 }
armarx::IceSharedMemoryProvider::getBuffer
MemoryObject * getBuffer()
Retrieve pointer to buffer.
Definition: IceSharedMemoryProvider.h:144
ARMARX_VERBOSE
#define ARMARX_VERBOSE
Definition: Logging.h:180
time.h
visionx::ImageProvider::onExitImageProvider
virtual void onExitImageProvider()=0
This is called when the Component::onExitComponent() setup is called.
visionx
ArmarX headers.
Definition: OpenPoseStressTest.h:38
visionx::ImageProvider::stopImageRecording
bool stopImageRecording(const Ice::Current &) override
Definition: ImageProvider.cpp:531
visionx::ImageProvider::startImageRecording
bool startImageRecording(const imrec::Config &cfg, const Ice::Current &) override
Definition: ImageProvider.cpp:473
visionx::imrec::Format
Format
Supported recording Formats.
Definition: public_api.h:55
trace.h
visionx::ImageProvider::onExitComponent
void onExitComponent() override
Definition: ImageProvider.cpp:152
armarx::IceSharedMemoryProvider::setMetaInfo
void setMetaInfo(const typename MemoryObjectMetaInfo::PointerType &info, bool threadSafe=true)
Definition: IceSharedMemoryProvider.h:228
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:43
visionx::ImageProvider::getNumberImages
int getNumberImages(const Ice::Current &c=Ice::emptyCurrent) override
Retrieve number of images handled by this provider.
Definition: ImageProvider.cpp:80
armarx::SharedMemoryScopedWriteLockPtr
std::shared_ptr< SharedMemoryScopedWriteLock > SharedMemoryScopedWriteLockPtr
Definition: SharedMemoryProvider.h:46
visionx::ImageProvider::setImageFormat
void setImageFormat(ImageDimension imageDimension, ImageType imageType, BayerPatternType bayerPatternType=visionx::eBayerPatternRg)
Sets the image basic format data.
Definition: ImageProvider.cpp:275
visionx::ImageProvider::getImagesAndMetaInfo
armarx::Blob getImagesAndMetaInfo(armarx::MetaInfoSizeBasePtr &, const Ice::Current &) override
Definition: ImageProvider.cpp:65
visionx::ImageProvider::getCompressedImagesAndMetaInfo
armarx::Blob getCompressedImagesAndMetaInfo(CompressionType, Ice::Int compressionQuality, armarx::MetaInfoSizeBasePtr &info, const Ice::Current &) override
Definition: ImageProvider.cpp:202
visionx::ImageProvider::getImageFormat
ImageFormatInfo getImageFormat(const Ice::Current &c=Ice::emptyCurrent) override
Returns the entire image format info struct via Ice.
Definition: ImageProvider.cpp:75
armarx::IceSharedMemoryProvider::getMetaInfo
MemoryObjectMetaInfo::PointerType getMetaInfo(bool threadSafe=true) const
getMetaInfo returns a copy of the memory object information
Definition: IceSharedMemoryProvider.h:243
armarx::RunningTask
Definition: ArmarXMultipleObjectsScheduler.h:35
visionx::ImageProvider::updateTimestamp
void updateTimestamp(Ice::Long timestamp, bool threadSafe=true)
Updates the timestamp of the currently captured image.
Definition: ImageProvider.cpp:165
ARMARX_CHECK
#define ARMARX_CHECK(expression)
Shortcut for ARMARX_CHECK_EXPRESSION.
Definition: ExpressionException.h:82
visionx::tools::createByteImage
CByteImage * createByteImage(const ImageFormatInfo &imageFormat, const ImageType imageType)
Creates a ByteImage for the destination type specified in the given imageProviderInfo.
visionx::ImageProvider::sharedMemoryProvider
armarx::IceSharedMemoryProvider< unsigned char >::pointer_type sharedMemoryProvider
shared memory provider
Definition: ImageProvider.h:256
visionx::ImageProvider::onDisconnectComponent
void onDisconnectComponent() override
Hook for subclass.
Definition: ImageProvider.cpp:141
visionx::ImageProvider::imageBuffers
void ** imageBuffers
Image buffer memory.
Definition: ImageProvider.h:251
visionx::ImageProvider::getImageRecordingChannelPreferences
std::vector< imrec::ChannelPreferences > getImageRecordingChannelPreferences(const Ice::Current &) override
Definition: ImageProvider.cpp:705
ARMARX_TRACE
#define ARMARX_TRACE
Definition: trace.h:69
visionx::ImageProvider::imageRecordingRunningTask
void imageRecordingRunningTask()
Definition: ImageProvider.cpp:560
armarx::IceSharedMemoryProvider::getData
Blob getData(MetaInfoSizeBasePtr &info, const Ice::Current &c=Ice::emptyCurrent) override
return data via ice.
Definition: IceSharedMemoryProvider.h:201
armarx::IceSharedMemoryProvider::stop
void stop()
Removes this object from Ice.
Definition: IceSharedMemoryProvider.h:124
ARMARX_DEBUG
#define ARMARX_DEBUG
Definition: Logging.h:177
ImageUtil.cpp
KITProsthesis::ProsthesisState::State
State
Definition: KITProstheticHandInterface.ice:32
visionx::ImageProvider::onInitImageProvider
virtual void onInitImageProvider()=0
This is called when the Component::onInitComponent() is called.
visionx::ImageProvider::recordImages
void recordImages(const IceUtil::Time &image_timestamp)
Definition: ImageProvider.cpp:425
visionx::ImageProvider::onConnectImageProvider
virtual void onConnectImageProvider()
This is called when the Component::onConnectComponent() setup is called.
Definition: ImageProvider.h:113
armarx::VariantType::Long
const VariantTypeId Long
Definition: Variant.h:917
visionx::ImageProvider::getImageRecordingStatus
imrec::Status getImageRecordingStatus(const Ice::Current &) override
Definition: ImageProvider.cpp:522
ARMARX_ERROR
#define ARMARX_ERROR
Definition: Logging.h:189
armarx::core::time::DateTime::toMicroSecondsSinceEpoch
std::int64_t toMicroSecondsSinceEpoch() const
Definition: DateTime.cpp:95
visionx::ImageProvider::provideImages
void provideImages(void **inputBuffers, const IceUtil::Time &imageTimestamp=IceUtil::Time())
send images raw.
Definition: ImageProvider.cpp:319
armarx::armem::Time
armarx::core::time::DateTime Time
Definition: forward_declarations.h:13
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
armarx::IceSharedMemoryProvider::start
void start()
Starts the memory provider.
Definition: IceSharedMemoryProvider.h:112
visionx::ImageProvider::imageProcessorProxy
ImageProcessorInterfacePrx imageProcessorProxy
Ice proxy of the image processor interface.
Definition: ImageProvider.h:246
armarx::IceSharedMemoryProvider< unsigned char >
visionx::ImageProvider::setNumberImages
void setNumberImages(int numberImages)
Sets the number of images on each capture.
Definition: ImageProvider.cpp:313
visionx::imrec::Recording
std::shared_ptr< AbstractRecordingStrategy > Recording
Convenience alias for any recording strategy.
Definition: AbstractRecordingStrategy.h:181
armarx::core::time::DateTime
Represents a point in time.
Definition: DateTime.h:24
visionx::ImageProvider::getImages
armarx::Blob getImages(const Ice::Current &c=Ice::emptyCurrent) override
Retrieve images via Ice.
Definition: ImageProvider.cpp:54
visionx::ImageProvider::onConnectComponent
void onConnectComponent() override
Definition: ImageProvider.cpp:104
visionx::imrec::str2format
Format str2format(const std::string &format_str)
Definition: public_api.cpp:159
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:174
armarx::ManagedIceObject::offeringTopic
void offeringTopic(const std::string &name)
Registers a topic for retrival after initialization.
Definition: ManagedIceObject.cpp:290
visionx::ImageProvider::onInitComponent
void onInitComponent() override
Definition: ImageProvider.cpp:88
visionx::ImageProvider::getScopedWriteLock
armarx::SharedMemoryScopedWriteLockPtr getScopedWriteLock()
Retrieve scoped lock for writing to the memory.
Definition: ImageProvider.h:210
armarx::VariantType::Int
const VariantTypeId Int
Definition: Variant.h:916
armarx::IceSharedMemoryProvider::getScopedReadLock
SharedMemoryScopedReadLockPtr getScopedReadLock() const
Definition: IceSharedMemoryProvider.h:169
visionx::imrec::datetime_to_string
std::string datetime_to_string(std::chrono::microseconds ts)
Definition: helper.cpp:77
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
TypeMapping.h
ARMARX_CHECK_EQUAL
#define ARMARX_CHECK_EQUAL(lhs, rhs)
This macro evaluates whether lhs is equal (==) rhs and if it turns out to be false it will throw an E...
Definition: ExpressionException.h:130
helper.h
ImageProvider.h
visionx::ImageProvider::onDisconnectImageProvider
virtual void onDisconnectImageProvider()
Definition: ImageProvider.h:114
armarx::PackagePath::toSystemPath
std::filesystem::path toSystemPath() const
Definition: PackagePath.cpp:69
PackagePath.h