Go to the documentation of this file.
32 #include <ArmarXCore/interface/core/SharedMemory.h>
35 #include <Image/ByteImage.h>
36 #include <Image/FloatImage.h>
39 #include <VisionX/interface/core/DataTypes.h>
40 #include <VisionX/interface/core/ImageProcessorInterface.h>
46 #include <condition_variable>
47 #include <shared_mutex>
53 class ImageTransferStats;
54 class ImageProviderInfo;
55 class ResultImageProvider;
70 .setCaseInsensitive(
false)
71 .map(
"None", eNoCompression)
76 defineOptionalProperty<bool>(
"ForceIceTransfer",
false,
"If set to true, this image processor will always use the Ice transfer for images instead of shared memory.");
89 virtual public ImageProcessorInterface
118 ImageType destinationImageType = eRgb,
123 ImageType destinationImageType = eRgb);
136 ImageDimension imageDimension,
138 const std::string& name =
"");
147 void provideResultImages(
const std::vector<CByteImageUPtr>& images, armarx::MetaInfoSizeBasePtr info =
nullptr);
174 bool waitForImages(std::string providerName,
int milliseconds = 1000);
227 int getImages(std::string providerName, CByteImage** ppImages, armarx::MetaInfoSizeBasePtr& info);
228 int getImages(std::string providerName,
const std::vector<CByteImageUPtr>& ppImages, armarx::MetaInfoSizeBasePtr& info);
238 int getImages(std::string providerName, CFloatImage** ppImages, armarx::MetaInfoSizeBasePtr& info);
249 bool resetStats =
false);
257 armarx::MetaInfoSizeBasePtr
getImageMetaInfo(
const std::string& imageProviderName =
"")
const;
358 std::string
getHardwareId(
const Ice::Current&
c = Ice::emptyCurrent);
371 const Ice::Current&
c = Ice::emptyCurrent)
override;
384 int getImages(std::string providerName,
void** ppBuffer, armarx::MetaInfoSizeBasePtr& info);
400 using ImageProviderMap = std::map<std::string, armarx::IceSharedMemoryConsumer<unsigned char>::pointer_type>;
482 armarx::MetaInfoSizeBasePtr
info;
537 : resultImageProviderName(
"ResultImageProvider")
549 this->resultImageDimension = resultImageDimension;
550 this->resultImageType = resultImageType;
556 provideImages(images, IceUtil::Time::microSeconds(timestamp));
561 provideImages(images, IceUtil::Time::microSeconds(timestamp));
568 this->resultImageProviderName = name;
573 return resultImageProviderName;
586 std::string resultImageProviderName;
588 visionx::ImageDimension resultImageDimension;
589 visionx::ImageType resultImageType;
void waitForProxy(std::string const &name, bool addToDependencies)
virtual void runProcessor()
int numberImages
Number of images.
void onInitComponent() override
The ImageProcessor class provides an interface for access to ImageProviders via Ice and shared memory...
void onExitComponent() override
The ImageTransferStats class provides information on the connection between ImageProvider and ImagePr...
float getFramerate() const
ImageProviderInfo getImageProvider(std::string name, ImageType destinationImageType=eRgb, bool waitForProxy=false)
Select an ImageProvider.
FPSCounter pollingFPS
Statistics for the images polled by the ImageProcessor.
FPSCounter imageProviderFPS
Statistics for the images announced by the ImageProvider.
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
void onExitImageProvider() override
This is called when the Component::onExitComponent() setup is called.
ImageFormatInfo imageFormat
Image format struct that contains all necessary image information.
void setCompressionType(CompressionType compressionType=ePNG, int compressionQuality=9)
Sets the compression type and compression quality.
void setImageFormat(ImageDimension imageDimension, ImageType imageType, BayerPatternType bayerPatternType=visionx::eBayerPatternRg)
Sets the image basic format data.
ImageProcessorPropertyDefinitions(std::string prefix)
void provideResultImages(CByteImage **images, Ice::Long timestamp)
static std::string ListenerSuffix
void updateTimestamp(Ice::Long timestamp, bool threadSafe=true)
Updates the timestamp of the currently captured image.
virtual void onConnectImageProcessor()=0
Implement this method in the ImageProcessor in order execute parts when the component is fully initia...
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
armarx::MetaInfoSizeBasePtr getImageMetaInfo(const std::string &imageProviderName="") const
Get meta information from the image provider.
void onConnectComponent() override
void reset()
Resets the FPS counter to its initial state.
std::shared_mutex imageProviderInfoMutex
void onInitImageProvider() override
This is called when the Component::onInitComponent() is called.
bool imageAvailable
Indicates whether an image is available.
virtual void onInitImageProcessor()=0
Setup the vision component.
CompressionType compressionType
void cleanup()
clean up memory
bool isNewImageAvailable()
ImageTransferStats getImageTransferStats(std::string provideNname, bool resetStats=false)
Retrieve statistics for a connection to an ImageProvider.
void usingImageProvider(std::string name)
Registers a delayed topic subscription and a delayed provider proxy retrieval which all will be avail...
std::shared_ptr< std::condition_variable > imageAvailableEvent
Conditional variable used internally for synchronization purposes.
std::map< std::string, ImageProviderInfo > imageProviderInfoMap
int getImages(CByteImage **ppImages)
Poll images from provider.
std::map< std::string, armarx::IceSharedMemoryConsumer< unsigned char >::pointer_type > ImageProviderMap
void setFramerate(float fps)
void provideImages(void **inputBuffers, const IceUtil::Time &imageTimestamp=IceUtil::Time())
send images raw.
armarx::core::time::DateTime Time
void setResultImageProviderName(const std::string &name)
Baseclass for all ArmarX ManagedIceObjects requiring properties.
void setNumberImages(int numberImages)
Sets the number of images on each capture.
CompressionType getCompressionType() const
void setResultImageFormat(ImageDimension resultImageDimension, ImageType resultImageType)
void setNumberResultImages(int numberResultImages)
ImageProvider abstract class defines a component which provide images via ice or shared memory.
std::string getDefaultName() const override
Retrieve default name of component.
virtual void onExitImageProcessor()=0
Exit the ImapeProcessor component.
ImageType destinationImageType
Required image destination type.
ImageProviderInterfacePrx proxy
proxy to image provider
Default component property definition container.
void provideResultImages(const std::vector< CByteImageUPtr > &images, Ice::Long timestamp)
void enableResultImages(int numberImages, ImageDimension imageDimension, ImageType imageType, const std::string &name="")
Enables visualization.
int getNumberOfImages(const std::string &providerName="")
Returns the number of images provided by the specified image provider If no provider is specified,...
armarx::PeriodicTask< ImageProcessor >::pointer_type processorTask
ComponentPropertyDefinitions(std::string prefix, bool hasObjectNameParameter=true)
void provideResultImages(CByteImage **images, armarx::MetaInfoSizeBasePtr info=nullptr)
sends result images for visualization
armarx::MetaInfoSizeBasePtr info
meta info
The ResultImageProvider is used by the ImageProcessor to stream result images to any other processor ...
std::string getImageListenerTopicName(std::string providerName) const
ImageProviderMap usedImageProviders
virtual void onDisconnectImageProcessor()
Implement this method in the ImageProcessor in order execute parts when the component looses network ...
std::vector< unsigned char > buffer
memory block
void releaseImageProvider(std::string providerName)
std::map< std::string, ImageTransferStats > statistics
void reportImageAvailable(const std::string &providerName, const Ice::Current &c=Ice::emptyCurrent) override
Listener callback function.
ImageTransferMode imageTransferMode
Transfer mode of images.
int getCompressionQuality() const
void componentPropertiesUpdated(const std::set< std::string > &changedProperties) override
Implement this function if you would like to react to changes in the properties.
std::string getHardwareId(const Ice::Current &c=Ice::emptyCurrent)
Returns machines hardware Id string.
IceInternal::Handle< ResultImageProvider > resultImageProvider
void onDisconnectComponent() override
std::mutex statisticsMutex
This file offers overloads of toIce() and fromIce() functions for STL container types.
The FPSCounter class provides methods for calculating the frames per second (FPS) count in periodic t...
virtual void process()=0
Process the vision component.
bool waitForImages(int milliseconds=1000)
Wait for new images.