31 #include <Image/ImageProcessor.h>
32 #include <Calibration/Calibration.h>
34 #include <pcl/io/pcd_io.h>
43 void KinectV1PointCloudProvider::onInitComponent()
48 ImageProvider::onInitComponent();
49 CapturingPointCloudProvider::onInitComponent();
52 void KinectV1PointCloudProvider::onConnectComponent()
57 ImageProvider::onConnectComponent();
58 CapturingPointCloudProvider::onConnectComponent();
61 void KinectV1PointCloudProvider::onDisconnectComponent()
65 captureEnabled =
false;
66 ImageProvider::onDisconnectComponent();
67 CapturingPointCloudProvider::onDisconnectComponent();
70 void KinectV1PointCloudProvider::onExitComponent()
75 ImageProvider::onExitComponent();
76 CapturingPointCloudProvider::onExitComponent();
80 void KinectV1PointCloudProvider::onInitCapturingPointCloudProvider()
95 void KinectV1PointCloudProvider::onStartCapture(
float frameRate)
97 device_->startVideo();
98 device_->startDepth();
102 void KinectV1PointCloudProvider::onStopCapture()
105 ARMARX_INFO <<
"Stopping KinectV1 Grabber Interface";
106 device_->stopVideo();
107 device_->stopDepth();
108 ARMARX_INFO <<
"Stopped KinectV1 Grabber Interface";
112 void KinectV1PointCloudProvider::onExitCapturingPointCloudProvider()
117 delete rgbImages_[0];
118 delete rgbImages_[1];
124 void KinectV1PointCloudProvider::onInitImageProvider()
130 rgbImages_ =
new CByteImage *[2];
131 size_ = width_ * height_;
132 rgbImages_[0] =
new CByteImage(width_, height_, CByteImage::eRGB24);
133 rgbImages_[1] =
new CByteImage(width_, height_, CByteImage::eRGB24);
134 ::ImageProcessor::Zero(rgbImages_[0]);
135 ::ImageProcessor::Zero(rgbImages_[1]);
136 Eigen::Vector2i dimensions = Eigen::Vector2i(width_, height_);
137 setImageFormat(visionx::ImageDimension(dimensions(0), dimensions(1)), visionx::eRgb);
142 bool KinectV1PointCloudProvider::doCapture()
144 static std::vector<uint8_t> rgb(size_ * 3);
145 static std::vector<uint16_t> depth(size_);
147 if (!device_->getRGB(rgb) || device_->getDepth(depth))
151 pcl::PointCloud<PointT>::Ptr outputCloud = pcl::PointCloud<PointT>::Ptr(
new pcl::PointCloud<PointT>());
152 outputCloud->resize(size_);
153 for (
int i = 0; i < size_; i++)
157 for (
int j = 0; j < 3; j++)
159 rgbImages_[0]->pixels[
index + j] = rgb[
index + j];
162 rgbImages_[1]->pixels[
index + 2],
false);
169 outputCloud->points[i].x = (i % width_ - cx_ + 0.5) * depth[i] / fx_;
170 outputCloud->points[i].y = (i / width_ - cy_ + 0.5) * depth[i] / fy_;
171 outputCloud->points[i].z = depth[i];
172 outputCloud->points[i].r = rgb[
index];
173 outputCloud->points[i].g = rgb[
index + 1];
174 outputCloud->points[i].b = rgb[
index + 2];
177 outputCloud->header.stamp = ts.toMicroSeconds();
178 providePointCloud<PointT>(outputCloud);
179 provideImages(rgbImages_, ts);
189 StereoCalibration KinectV1PointCloudProvider::getStereoCalibration(
const Ice::Current&
c)