Deep_Segmenter.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5  *
6  * ArmarX is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  * ArmarX is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * @package VisionX
19  * @author Eren Aksoy ( eren dot aksoy at kit dot edu )
20  * @date 2016
21  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22  * GNU General Public License
23  */
24 
25 #include "Deep_Segmenter.h"
26 
28 {
29  labeledCloud.reset(new pcl::PointCloud<pcl::PointXYZRGBL>());
30 }
31 
32 pcl::PointCloud<pcl::PointXYZRGBL>::Ptr&
33 DeepSegClass::GetLabeledPointCloud(pcl::PointCloud<pcl::PointXYZRGBA>::Ptr& CloudPtr,
34  armarx::Blob segmentImage)
35 {
36  std::cout << " Input point cloud size: " << CloudPtr->points.size()
37  << " width: " << CloudPtr->width << " height: " << CloudPtr->height << std::endl;
38  std::cout << " segment mask size: " << segmentImage.size() << std::endl;
39 
40  const int width = CloudPtr->width;
41  const int height = CloudPtr->height;
42 
43  labeledCloud->resize(CloudPtr->points.size());
44 
45 
46  for (int i = 0; i < height; i++)
47  {
48  for (int j = 0; j < width; j++)
49  {
50  labeledCloud->points[i * width + j].x = CloudPtr->points[i * width + j].x;
51  labeledCloud->points[i * width + j].y = CloudPtr->points[i * width + j].y;
52  labeledCloud->points[i * width + j].z = CloudPtr->points[i * width + j].z;
53  labeledCloud->points[i * width + j].r = CloudPtr->points[i * width + j].r;
54  labeledCloud->points[i * width + j].g = CloudPtr->points[i * width + j].g;
55  labeledCloud->points[i * width + j].b = CloudPtr->points[i * width + j].b;
56  labeledCloud->points[i * width + j].label = segmentImage.at(i * width + j);
57  }
58  }
59 
60  return labeledCloud;
61 }
62 
63 armarx::Blob
64 DeepSegClass::GetImageFromPointCloud(pcl::PointCloud<pcl::PointXYZRGBA>::Ptr& CloudPtr)
65 {
66  const int width = CloudPtr->width;
67  const int height = CloudPtr->height;
68  rgbImage.clear();
69 
70  for (int i = 0; i < height; i++)
71  {
72  for (int j = 0; j < width; j++)
73  {
74  pcl::PointXYZRGBA& point = CloudPtr->at(i * width + j);
75  rgbImage.push_back(point.r);
76  rgbImage.push_back(point.g);
77  rgbImage.push_back(point.b);
78  }
79  }
80 
81  return rgbImage;
82 }
DeepSegClass::GetImageFromPointCloud
armarx::Blob GetImageFromPointCloud(pcl::PointCloud< pcl::PointXYZRGBA >::Ptr &CloudPtr)
Definition: Deep_Segmenter.cpp:64
DeepSegClass::GetLabeledPointCloud
pcl::PointCloud< pcl::PointXYZRGBL >::Ptr & GetLabeledPointCloud(pcl::PointCloud< pcl::PointXYZRGBA >::Ptr &CloudPtr, armarx::Blob segmentImage)
Definition: Deep_Segmenter.cpp:33
Deep_Segmenter.h
DeepSegClass::DeepSegClass
DeepSegClass()
Definition: Deep_Segmenter.cpp:27