33#include <Calibration/StereoCalibration.h>
34#include <Image/ImageProcessor.h>
98 MetaPointCloudFormatPtr
101 MetaPointCloudFormatPtr info =
new MetaPointCloudFormat();
103 info->type = PointContentType::eColoredPoints;
104 info->capacity = 1600 * 1200 *
sizeof(ColoredPoint3D);
105 info->size = info->capacity;
128 StereoCalibrationProviderInterfacePrx calibrationProviderPrx1 =
129 StereoCalibrationProviderInterfacePrx::checkedCast(imageProviderPrx);
130 CapturingPointCloudAndImageAndStereoCalibrationProviderInterfacePrx
131 calibrationProviderPrx2 =
132 CapturingPointCloudAndImageAndStereoCalibrationProviderInterfacePrx::checkedCast(
135 if (calibrationProviderPrx1)
139 imagesAreUndistorted = calibrationProviderPrx1->getImagesAreUndistorted();
141 else if (calibrationProviderPrx2)
145 imagesAreUndistorted = calibrationProviderPrx2->getImagesAreUndistorted();
150 <<
" is not a StereoCalibrationProvider";
151 imagesAreUndistorted =
true;
154 cameraImages =
new CByteImage*[2];
157 width = imageProviderInfo.
imageFormat.dimension.width;
158 height = imageProviderInfo.
imageFormat.dimension.height;
159 cameraImagesGrey =
new CByteImage*[2];
160 cameraImagesGrey[0] =
new CByteImage(width, height, CByteImage::eGrayScale);
161 cameraImagesGrey[1] =
new CByteImage(width, height, CByteImage::eGrayScale);
162 disparityImage =
new CByteImage(width, height, CByteImage::eGrayScale);
163 disparityImageRGB =
new CByteImage(cameraImages[0]);
164 resultImages =
new CByteImage*[2];
165 resultImages[0] = cameraImages[0];
166 resultImages[1] = disparityImageRGB;
172 delete cameraImages[0];
173 delete cameraImages[1];
174 delete[] cameraImages;
175 delete cameraImagesGrey[0];
176 delete cameraImagesGrey[1];
177 delete[] cameraImagesGrey;
178 delete disparityImage;
179 delete disparityImageRGB;
180 delete[] resultImages;
186 setImageFormat(visionx::ImageDimension(width, height), visionx::eRgb);
199 std::unique_lock lock(captureLock);
212 pcl::PointCloud<PointXYZRGBA>::Ptr pointcloud(
new pcl::PointCloud<PointXYZRGBA>());
213 ::ImageProcessor::ConvertImage(cameraImages[0], cameraImagesGrey[0]);
214 ::ImageProcessor::ConvertImage(cameraImages[1], cameraImagesGrey[1]);
227 imagesAreUndistorted,
234 for (
size_t j = 0; j < pointcloud->height; j++)
236 for (
size_t i = 0; i < pointcloud->width; i++)
238 int idx = (j * pointcloud->width + i);
239 int value = pointcloud->points[idx].z;
242 disparityImageRGB->pixels[3 * idx + 0] = value & 0xFF;
243 disparityImageRGB->pixels[3 * idx + 1] = (value >> 8) & 0xFF;
266 return "StereoImagePointCloudProvider";
#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)
virtual void onExitComponent()
Hook for subclass.
virtual void onDisconnectComponent()
Hook for subclass.
virtual void onConnectComponent()=0
Pure virtual hook for the subclass.
std::string getName() const
Retrieve name of object.
Ice::ObjectPrx getProxy(long timeoutMs=0, bool waitForScheduler=true) const
Returns the proxy of this object (optionally it waits for the proxy)
virtual void onInitComponent()=0
Pure virtual hook for the subclass.
void onInitComponent() override
void usingImageProvider(std::string name)
Registers a delayed topic subscription and a delayed provider proxy retrieval which all will be avail...
bool waitForImages(int milliseconds=1000)
Wait for new images.
ImageProviderInfo getImageProvider(std::string name, ImageType destinationImageType=eRgb, bool waitForProxy=false)
Select an ImageProvider.
void onDisconnectComponent() override
int getImages(CByteImage **ppImages)
Poll images from provider.
void onConnectComponent() override
void onExitComponent() override
ImageFormatInfo imageFormat
Image format struct that contains all necessary image information.
void onInitComponent() override
void onDisconnectComponent() override
Hook for subclass.
void setImageFormat(ImageDimension imageDimension, ImageType imageType, BayerPatternType bayerPatternType=visionx::eBayerPatternRg)
Sets the image basic format data.
void provideImages(void **inputBuffers, const IceUtil::Time &imageTimestamp=IceUtil::Time())
send images raw.
void onConnectComponent() override
void setNumberImages(int numberImages)
Sets the number of images on each capture.
void onExitComponent() override
void providePointCloud(PointCloudPtrT pointCloudPtr)
offer the new point cloud.
void onInitComponent() override
void onConnectImageProcessor() override
Implement this method in the ImageProcessor in order execute parts when the component is fully initia...
bool doCapture() override
void onExitCapturingPointCloudProvider() override
void onDisconnectComponent() override
Hook for subclass.
void onExitImageProcessor() override
Exit the ImapeProcessor component.
void onStartCapture(float frameRate) override
void onInitCapturingPointCloudProvider() override
MetaPointCloudFormatPtr getDefaultPointCloudFormat() override
default point cloud format used to initialize shared memory
void onInitImageProcessor() override
Setup the vision component.
void onConnectComponent() override
void onStopCapture() override
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
static std::string GetDefaultName()
void onInitImageProvider() override
void onExitComponent() override
visionx::MonocularCalibration getMonocularCalibration(const ::Ice::Current &c=Ice::emptyCurrent) override
std::string getDefaultName() const override
Retrieve default name of component.
#define ARMARX_INFO
The normal logging level.
#define ARMARX_IMPORTANT
The logging level for always important information, but expected behaviour (in contrast to ARMARX_WAR...
#define ARMARX_DEBUG
The logging level for output that is only interesting while debugging.
#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.
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
void GetPointsFromDisparity(const CByteImage *pImageLeftColor, const CByteImage *pImageRightColor, const CByteImage *pImageLeftGrey, const CByteImage *pImageRightGrey, const int nDisparityPointDistance, pcl::PointCloud< pcl::PointXYZRGBA > &aPointsFromDisparity, CByteImage *pDisparityImage, const int imageWidth, const int imageHeight, CStereoCalibration *pStereoCalibration, bool imagesAreUndistorted, const bool smoothDisparities)