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& DeepSegClass::GetLabeledPointCloud(pcl::PointCloud<pcl::PointXYZRGBA>::Ptr& CloudPtr, armarx::Blob segmentImage)
33 {
34  std::cout << " Input point cloud size: " << CloudPtr->points.size() << " width: " << CloudPtr->width << " height: " << CloudPtr->height << std::endl;
35  std::cout << " segment mask size: " << segmentImage.size() << std::endl;
36 
37  const int width = CloudPtr->width;
38  const int height = CloudPtr->height;
39 
40  labeledCloud->resize(CloudPtr->points.size());
41 
42 
43  for (int i = 0; i < height; i++)
44  {
45  for (int j = 0; j < width; j++)
46  {
47  labeledCloud->points[i * width + j].x = CloudPtr->points[i * width + j].x;
48  labeledCloud->points[i * width + j].y = CloudPtr->points[i * width + j].y;
49  labeledCloud->points[i * width + j].z = CloudPtr->points[i * width + j].z;
50  labeledCloud->points[i * width + j].r = CloudPtr->points[i * width + j].r;
51  labeledCloud->points[i * width + j].g = CloudPtr->points[i * width + j].g;
52  labeledCloud->points[i * width + j].b = CloudPtr->points[i * width + j].b;
53  labeledCloud->points[i * width + j].label = segmentImage.at(i * width + j);
54  }
55  }
56 
57  return labeledCloud;
58 }
59 
60 armarx::Blob DeepSegClass::GetImageFromPointCloud(pcl::PointCloud<pcl::PointXYZRGBA>::Ptr& CloudPtr)
61 {
62  const int width = CloudPtr->width;
63  const int height = CloudPtr->height;
64  rgbImage.clear();
65 
66  for (int i = 0; i < height; i++)
67  {
68  for (int j = 0; j < width; j++)
69  {
70  pcl::PointXYZRGBA& point = CloudPtr->at(i * width + j);
71  rgbImage.push_back(point.r);
72  rgbImage.push_back(point.g);
73  rgbImage.push_back(point.b);
74  }
75  }
76 
77  return rgbImage;
78 }
79 
80 
81 
DeepSegClass::GetImageFromPointCloud
armarx::Blob GetImageFromPointCloud(pcl::PointCloud< pcl::PointXYZRGBA >::Ptr &CloudPtr)
Definition: Deep_Segmenter.cpp:60
DeepSegClass::GetLabeledPointCloud
pcl::PointCloud< pcl::PointXYZRGBL >::Ptr & GetLabeledPointCloud(pcl::PointCloud< pcl::PointXYZRGBA >::Ptr &CloudPtr, armarx::Blob segmentImage)
Definition: Deep_Segmenter.cpp:32
Deep_Segmenter.h
DeepSegClass::DeepSegClass
DeepSegClass()
Definition: Deep_Segmenter.cpp:27