40 ARMARX_INFO <<
"color mask is r:" << colorMask(0) <<
" g:" << colorMask(1)
41 <<
" b:" << colorMask(2);
43 setImageFormat(visionx::ImageDimension(width, height), visionx::eRgb);
60 pollImagesTask->start();
62 if (imageSources.size() == 0)
64 std::vector<std::string> imageProviders =
66 setResultImageProviders(imageProviders);
73 pollImagesTask->stop();
81 const size_t imageSize = width * height * bytesPerPixel;
84 bool imageCaptured =
false;
86 for (
auto& any : imageSources)
89 std::string proxyName = any.first;
91 if (!imageAvailable[proxyName])
97 imageAvailable[proxyName] =
false;
100 ImageProviderInterfacePrx providerPrx;
108 ARMARX_WARNING <<
"provider" << proxyName <<
" is no longer here.";
113 CByteImage** providerImages = any.second;
114 for (
int n = 0; n < numImages; n++)
116 CByteImage* image = providerImages[n];
118 for (
int j = 0; j < height; j++)
120 for (
int i = 0; i < width; i++)
123 int r = image->pixels[3 * (j * width + i) + 0];
124 int g = image->pixels[3 * (j * width + i) + 1];
125 int b = image->pixels[3 * (j * width + i) + 2];
127 if (!(r == colorMask(0) && g == colorMask(1) && b == colorMask(2)))
129 resultImage->pixels[3 * (j * width + i) + 0] = r;
130 resultImage->pixels[3 * (j * width + i) + 1] = g;
131 resultImage->pixels[3 * (j * width + i) + 2] = b;
137 imageCaptured =
true;
143 for (
int i = 0; i < numImages; i++)
145 memcpy(ppImages[i], resultImage->pixels, imageSize);
149 return imageCaptured;
153ResultImageFuser::setResultImageProviders(std::vector<std::string> imageProviders)
155 imageSources.clear();
158 for (std::string& proxyName : imageProviders)
161 ImageProviderInterfacePrx providerPrx;
169 ARMARX_WARNING <<
"provider" << proxyName <<
" is no longer here.";
173 const int providerNumImages = providerPrx->getNumberImages();
174 ImageFormatInfo imageFormat = providerPrx->getImageFormat();
176 assert(imageFormat.dimension.width == width);
177 assert(imageFormat.dimension.height == height);
178 assert(imageFormat.bytesPerPixel == bytesPerPixel);
179 assert(numImages <= providerNumImages);
181 CByteImage** images =
new CByteImage*[providerNumImages];
183 for (
int n = 0;
n < numImages;
n++)
189 imageSources[proxyName] = images;
190 imageAvailable[proxyName] =
false;
195ResultImageFuser::pollImageProviders()
197 std::unique_lock lock(imageMutex);
199 for (
auto& any : imageSources)
201 std::string proxyName = any.first;
203 ImageProviderInterfacePrx providerPrx;
211 ARMARX_WARNING <<
"provider" << proxyName <<
" is no longer here.";
215 CByteImage** bufferImages = any.second;
216 ImageFormatInfo imageFormat = providerPrx->getImageFormat();
218 armarx::Blob images = providerPrx->getImages();
220 size_t imageSize = width * height * imageFormat.bytesPerPixel;
222 for (
int i = 0; i < numImages; i++)
224 memcpy(bufferImages[i]->pixels, &images[imageSize * i], imageSize);
227 imageAvailable[proxyName] =
true;
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
Property< PropertyType > getProperty(const std::string &name)
Ice::ObjectPrx getProxy(long timeoutMs=0, bool waitForScheduler=true) const
Returns the proxy of this object (optionally it waits for the proxy)
The periodic task executes one thread method repeatedly using the time period specified in the constr...
void onStartCapture(float frameRate) override
void onStopCapture() override
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
void onExitCapturingImageProvider() override
void onInitCapturingImageProvider() override
float frameRate
Required frame rate.
armarx::SharedMemoryScopedWriteLockPtr getScopedWriteLock()
Retrieve scoped lock for writing to the memory.
ImageFormatInfo getImageFormat(const Ice::Current &c=Ice::emptyCurrent) override
Returns the entire image format info struct via Ice.
void setImageFormat(ImageDimension imageDimension, ImageType imageType, BayerPatternType bayerPatternType=visionx::eBayerPatternRg)
Sets the image basic format data.
void setNumberImages(int numberImages)
Sets the number of images on each capture.
#define ARMARX_INFO
The normal logging level.
#define ARMARX_WARNING
The logging level for unexpected behaviour, but not a serious problem.
This file offers overloads of toIce() and fromIce() functions for STL container types.
std::shared_ptr< SharedMemoryScopedWriteLock > SharedMemoryScopedWriteLockPtr
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
constexpr auto n() noexcept