32 bool PlaneInferredInfo::searchTheFloor(Eigen::Matrix4f &poseSensor,
Plane &plane)
38 double cosGravityDir = poseSensor.col(1).head(3).dot(plane.
v3normal);
39 if( cosGravityDir < -0.94 )
41 double sensorHeight = ( plane.
v3normal.dot( poseSensor.col(3).head(3) - plane.
v3center) );
43 if( sensorHeight < 0.7 || sensorHeight > 2.0 )
46 mPbMap.FloorPlane = plane.
id;
49 else if( cosGravityDir > 0.94 )
51 else if( fabs(cosGravityDir) < 0.34 )
57 for(
unsigned i=0; i < mPbMap.vPlanes.size(); i++)
59 if(plane.
id == mPbMap.vPlanes[i].id)
77 bool PlaneInferredInfo::isPlaneCutbyImage(vector<int> &planeIndices,
unsigned &widthSampledImage,
unsigned &heightSampledImage,
unsigned threshold)
79 unsigned upperLimWidth = widthSampledImage - threshold;
80 unsigned upperLimHeight = heightSampledImage - threshold;
83 for(
unsigned i=0; i < planeIndices.size(); i++)
85 u = planeIndices[i] % widthSampledImage;
86 v = planeIndices[i] / widthSampledImage;
98 bool PlaneInferredInfo::isSurroundingBackground(
Plane &plane, pcl::PointCloud<pcl::PointXYZRGBA>::Ptr &frame, vector<int> &planeIndices,
unsigned threshold)
102 vector< pair<unsigned, unsigned> > polyImg;
104 for(
unsigned j=0; j < planeIndices.size(); j++)
109 polyImg.push_back(pair<unsigned, unsigned>(planeIndices[j] % frame->width, planeIndices[j] / frame->width) );
116 unsigned left = polyImg[0].first, right = polyImg[0].first, up = polyImg[0].second, down = polyImg[0].second;
117 for(
unsigned i=1; i < polyImg.size(); i++)
119 if(polyImg[i].
first < left) left = polyImg[i].first;
120 else if(polyImg[i].
first > right) right = polyImg[i].first;
121 if(polyImg[i].second < down) down = polyImg[i].second;
122 else if(polyImg[i].second > up) up = polyImg[i].second;
124 pair<int, int> center((left+right)/2,(up+down)/2);
128 vector<Eigen::Vector2i> outerPolygon;
129 unsigned Threshold = threshold * frame->width / 640;
130 for(
unsigned i=1; i < polyImg.size(); i++)
133 double normDir = sqrt(
double( (polyImg[i].
first - center.first)*(polyImg[i].first - center.first) + (polyImg[i].second - center.second)*(polyImg[i].second - center.second) ) );
134 dir[0] = (polyImg[i].first - center.first) / normDir;
135 dir[1] = (polyImg[i].second - center.second) / normDir;
139 Eigen::Vector2i outVertex;
140 outVertex[0] = dir[0]*Threshold + polyImg[i].first;
141 outVertex[1] = dir[1]*Threshold + polyImg[i].second;
142 if(outVertex[0] < 0) outVertex[0] = 0;
143 else if(outVertex[0] >= static_cast<int>(frame->width)) outVertex[0] = frame->width-1;
144 if(outVertex[1] < 0) outVertex[1] = 0;
145 else if(outVertex[1] >= static_cast<int>(frame->height)) outVertex[1] = frame->height-1;
147 outerPolygon.push_back(outVertex);
152 for(
unsigned i=1; i < outerPolygon.size(); i++)
154 double edgeLenght = std::sqrt(static_cast<double>( (outerPolygon[i][0] - outerPolygon[i-1][0])*(outerPolygon[i][0] - outerPolygon[i-1][0]) + (outerPolygon[i][1] - outerPolygon[i-1][1])*(outerPolygon[i][1] - outerPolygon[i-1][1])) );
155 Eigen::Vector2f direction;
156 direction[0] = (outerPolygon[i][0] - outerPolygon[i-1][0]) / edgeLenght;
157 direction[1] = (outerPolygon[i][1] - outerPolygon[i-1][1]) / edgeLenght;
162 Eigen::Vector2i outContour;
163 for(
unsigned j=0; j < edgeLenght; j++)
165 outContour[0] = outerPolygon[i-1][0] + int(direction[0] * j);
166 outContour[1] = outerPolygon[i-1][1] + int(direction[1] * j);
168 pcl::PointXYZRGBA &outerPt = frame->points[outContour[0] + outContour[1]*frame->width];
169 if(!pcl_isfinite(outerPt.x))
188 void PlaneInferredInfo::isFullExtent(
Plane &plane,
double newArea)
pcl::PointCloud< pcl::PointXYZRGBA >::Ptr polygonContourPtr
A class used to store a planar feature (Plane for short).
std::string BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
pcl::PointCloud< pcl::PointXYZRGBA >::Ptr outerPolygonPtr
unsigned id
! Parameters to allow the plane-based representation of the map by a graph
Eigen::Vector3f v3center
! Geometric description
unsigned nFramesAreaIsStable
Eigen::Vector3f getVector3fromPointXYZ(pointPCL &pt)