42 ARMARX_INFO <<
"color mask is r:" << colorMask(0) <<
" g:" << colorMask(1)
43 <<
" b:" << colorMask(2);
45 setImageFormat(visionx::ImageDimension(width, height), visionx::eRgb);
62 pollImagesTask->start();
64 if (imageSources.size() == 0)
66 std::vector<std::string> imageProviders =
68 setResultImageProviders(imageProviders);
75 pollImagesTask->stop();
83 const size_t imageSize = width * height * bytesPerPixel;
86 bool imageCaptured =
false;
88 for (
auto& any : imageSources)
91 std::string proxyName = any.first;
93 if (!imageAvailable[proxyName])
99 imageAvailable[proxyName] =
false;
102 ImageProviderInterfacePrx providerPrx;
110 ARMARX_WARNING <<
"provider" << proxyName <<
" is no longer here.";
115 CByteImage** providerImages = any.second;
116 for (
int n = 0; n < numImages; n++)
118 CByteImage* image = providerImages[n];
120 for (
int j = 0; j < height; j++)
122 for (
int i = 0; i < width; i++)
125 int r = image->pixels[3 * (j * width + i) + 0];
126 int g = image->pixels[3 * (j * width + i) + 1];
127 int b = image->pixels[3 * (j * width + i) + 2];
129 if (!(r == colorMask(0) && g == colorMask(1) && b == colorMask(2)))
131 resultImage->pixels[3 * (j * width + i) + 0] = r;
132 resultImage->pixels[3 * (j * width + i) + 1] = g;
133 resultImage->pixels[3 * (j * width + i) + 2] = b;
139 imageCaptured =
true;
145 for (
int i = 0; i < numImages; i++)
147 memcpy(ppImages[i], resultImage->pixels, imageSize);
151 return imageCaptured;
155ResultImageFuser::setResultImageProviders(std::vector<std::string> imageProviders)
157 imageSources.clear();
160 for (std::string& proxyName : imageProviders)
163 ImageProviderInterfacePrx providerPrx;
171 ARMARX_WARNING <<
"provider" << proxyName <<
" is no longer here.";
175 const int providerNumImages = providerPrx->getNumberImages();
176 ImageFormatInfo imageFormat = providerPrx->getImageFormat();
178 assert(imageFormat.dimension.width == width);
179 assert(imageFormat.dimension.height == height);
180 assert(imageFormat.bytesPerPixel == bytesPerPixel);
181 assert(numImages <= providerNumImages);
183 CByteImage** images =
new CByteImage*[providerNumImages];
185 for (
int n = 0;
n < numImages;
n++)
191 imageSources[proxyName] = images;
192 imageAvailable[proxyName] =
false;
197ResultImageFuser::pollImageProviders()
199 std::unique_lock lock(imageMutex);
201 for (
auto& any : imageSources)
203 std::string proxyName = any.first;
205 ImageProviderInterfacePrx providerPrx;
213 ARMARX_WARNING <<
"provider" << proxyName <<
" is no longer here.";
217 CByteImage** bufferImages = any.second;
218 ImageFormatInfo imageFormat = providerPrx->getImageFormat();
220 armarx::Blob images = providerPrx->getImages();
222 size_t imageSize = width * height * imageFormat.bytesPerPixel;
224 for (
int i = 0; i < numImages; i++)
226 memcpy(bufferImages[i]->pixels, &images[imageSize * i], imageSize);
229 imageAvailable[proxyName] =
true;
242 return "ResultImageFuser";
#define ARMARX_REGISTER_COMPONENT_EXECUTABLE(ComponentT, applicationName)
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
static std::string GetDefaultName()
void onInitCapturingImageProvider() override
std::string getDefaultName() const override
Retrieve default name of component.
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