31 #include <Calibration/StereoCalibration.h>
32 #include <Image/ImageProcessor.h>
43 StereoImagePointCloudProvider::onInitComponent()
45 ImageProcessor::onInitComponent();
46 CapturingPointCloudProvider::onInitComponent();
47 ImageProvider::onInitComponent();
48 downsamplingRate = getProperty<int>(
"DownsamplingRate").getValue();
49 smoothDisparity = getProperty<bool>(
"SmoothDisparity").getValue();
53 StereoImagePointCloudProvider::onConnectComponent()
55 ImageProcessor::onConnectComponent();
56 CapturingPointCloudProvider::onConnectComponent();
57 ImageProvider::onConnectComponent();
61 StereoImagePointCloudProvider::onDisconnectComponent()
63 ImageProcessor::onDisconnectComponent();
64 CapturingPointCloudProvider::onDisconnectComponent();
65 ImageProvider::onDisconnectComponent();
69 StereoImagePointCloudProvider::onExitComponent()
71 ImageProvider::onExitComponent();
72 CapturingPointCloudProvider::onExitComponent();
73 ImageProcessor::onExitComponent();
77 StereoImagePointCloudProvider::onInitCapturingPointCloudProvider()
82 StereoImagePointCloudProvider::onStartCapture(
float frameRate)
87 StereoImagePointCloudProvider::onStopCapture()
92 StereoImagePointCloudProvider::onExitCapturingPointCloudProvider()
96 MetaPointCloudFormatPtr
97 StereoImagePointCloudProvider::getDefaultPointCloudFormat()
99 MetaPointCloudFormatPtr info =
new MetaPointCloudFormat();
101 info->type = PointContentType::eColoredPoints;
102 info->capacity = 1600 * 1200 *
sizeof(ColoredPoint3D);
103 info->size = info->capacity;
108 StereoImagePointCloudProvider::onInitImageProcessor()
111 providerName = getProperty<std::string>(
"ImageProviderAdapterName").getValue();
112 usingImageProvider(providerName);
116 StereoImagePointCloudProvider::onConnectImageProcessor()
119 ARMARX_INFO << getName() <<
" connecting to " << providerName;
121 imageProviderPrx = getProxy<ImageProviderInterfacePrx>(providerName);
122 setImageFormat(imageProviderInfo.
imageFormat.dimension,
126 StereoCalibrationProviderInterfacePrx calibrationProviderPrx1 =
127 StereoCalibrationProviderInterfacePrx::checkedCast(imageProviderPrx);
128 CapturingPointCloudAndImageAndStereoCalibrationProviderInterfacePrx
129 calibrationProviderPrx2 =
130 CapturingPointCloudAndImageAndStereoCalibrationProviderInterfacePrx::checkedCast(
133 if (calibrationProviderPrx1)
137 imagesAreUndistorted = calibrationProviderPrx1->getImagesAreUndistorted();
139 else if (calibrationProviderPrx2)
143 imagesAreUndistorted = calibrationProviderPrx2->getImagesAreUndistorted();
148 <<
" is not a StereoCalibrationProvider";
149 imagesAreUndistorted =
true;
152 cameraImages =
new CByteImage*[2];
155 width = imageProviderInfo.
imageFormat.dimension.width;
156 height = imageProviderInfo.
imageFormat.dimension.height;
157 cameraImagesGrey =
new CByteImage*[2];
158 cameraImagesGrey[0] =
new CByteImage(width, height, CByteImage::eGrayScale);
159 cameraImagesGrey[1] =
new CByteImage(width, height, CByteImage::eGrayScale);
160 disparityImage =
new CByteImage(width, height, CByteImage::eGrayScale);
161 disparityImageRGB =
new CByteImage(cameraImages[0]);
162 resultImages =
new CByteImage*[2];
163 resultImages[0] = cameraImages[0];
164 resultImages[1] = disparityImageRGB;
168 StereoImagePointCloudProvider::onExitImageProcessor()
170 delete cameraImages[0];
171 delete cameraImages[1];
172 delete[] cameraImages;
173 delete cameraImagesGrey[0];
174 delete cameraImagesGrey[1];
175 delete[] cameraImagesGrey;
176 delete disparityImage;
177 delete disparityImageRGB;
178 delete[] resultImages;
182 StereoImagePointCloudProvider::onInitImageProvider()
184 setImageFormat(visionx::ImageDimension(width, height), visionx::eRgb);
189 StereoImagePointCloudProvider::getMonocularCalibration(
const Ice::Current&
c)
195 StereoImagePointCloudProvider::doCapture()
197 std::unique_lock lock(captureLock);
199 if (!waitForImages(8000))
207 int nNumberImages = ImageProcessor::getImages(cameraImages);
208 ARMARX_DEBUG << getName() <<
" got " << nNumberImages <<
" images";
210 pcl::PointCloud<PointXYZRGBA>::Ptr pointcloud(
new pcl::PointCloud<PointXYZRGBA>());
211 ::ImageProcessor::ConvertImage(cameraImages[0], cameraImagesGrey[0]);
212 ::ImageProcessor::ConvertImage(cameraImages[1], cameraImagesGrey[1]);
214 ARMARX_DEBUG << getName() <<
"depthfromstereo::GetPointsFromDisparity";
225 imagesAreUndistorted,
230 providePointCloud(pointcloud);
232 for (
size_t j = 0; j < pointcloud->height; j++)
234 for (
size_t i = 0; i < pointcloud->width; i++)
236 int idx = (j * pointcloud->width + i);
237 int value = pointcloud->points[idx].z;
240 disparityImageRGB->pixels[3 * idx + 0] =
value & 0xFF;
241 disparityImageRGB->pixels[3 * idx + 1] = (
value >> 8) & 0xFF;
245 provideImages(resultImages);
254 StereoImagePointCloudProvider::createPropertyDefinitions()