title: Wall detection using PCL and RANSAC
body: <p>I have been working on wall detection in PCD (Point Cloud Data) file using PCL (Point Cloud Library). The PCD file has been generated through a depth camera. I found that in many of the similar applications e.g. floor detection, RANSAC has been used. So, I thought of applying RANSAC here as well and I tried my best to understand RANSAC in-general but I still have certain questions pertaining to my application:</p>
  <ol>
  <li><p>In brief, RANSAC tries to remove the outliers in the given data and generalize the inliers through a model iteratively. So, in the case of floor detection, would it consider the rest of the point clouds corresponding to other objects as just outliers and the floor as inlier? The same is the case for the walls?</p>
  </li>
  <li><p>As per <a href="https://pcl.readthedocs.io/projects/tutorials/en/latest/planar_segmentation.html#planar-segmentation" rel="nofollow noreferrer">Plane model segmentation tutorial</a> by PCL, RANSAC is giving the coefficients of the model plane i.e. <code>a</code>, <code>b</code>, <code>c</code>, and <code>d</code> in the equation of plane: <code>a*x + b*y + c*z + d = 0</code> through <code>coefficients-&gt;values</code> vector. So, I assume that in the case of wall detection, it would try to give the equation of the plane corresponding to the wall. However, what if the depth camera is at the corner of a room and the top view of walls look like this:</p>
  </li>
  </ol>
  <p>             wall 1 <br>
         ______________ <br>
         | <br>
         | <br>
         | wall 2<br>
         | <br>
         | <br></p>
  <p>       So, in this case, what would be the resultant model plane look like? Would it be kind of a        hypotenuse (making a triangle)?</p>
  <p>             wall 1 <br>
         --------------------- <br>
                                  | <br>
                                  | wall 2 <br>
                                  | <br>
                                   ---------------------- <br>
                                  
           wall 3</p>
  <p>       Even in this case, how would it look like?</p>
  <ol start="3">
  <li><p>As per the <a href="https://pcl.readthedocs.io/projects/tutorials/en/latest/extract_indices.html#extract-indices" rel="nofollow noreferrer">Extracting indices from a PointCloud tutorial</a> by PCL, <code>ExtractIndices &lt;pcl::ExtractIndices&gt;</code> filter is used to extract a subset of points from a point cloud based on the indices output by a segmentation algorithm. But, what exactly this filter is doing? In fact, in the case of floor detection or wall detection (assuming there is only one straight wall), RANSAC is already giving an equation of one plane. So, is there any need of using that filter? If yes then why and how?</p>
  </li>
  <li><p>How can I detect multiple walls in the following case? <code>ExtractIndices &lt;pcl::ExtractIndices&gt;</code> filter can do this? If yes then how?</p>
  </li>
  </ol>
  <p>             wall 1 <br>
         --------------------- <br>
                                  | <br>
                                  | wall 2 <br>
                                  | <br>
                                   ---------------------- <br>
                                  
           wall 3 <br></p>
  <p>If you think that there are better ways than using RANSAC then also please let me know.</p>