コード例 #1
0
// Returns a vector of points that contains the four corners of a rectangle
// by finding the best features.
// Automatically refines the corners.
// Currently only tested with four points (rectangle)
// Returns empty vector when filter is not applied / successful.
std::vector<cv::Point2f> CornerExtractor::getCorners()
{
#if CALIB && !isStreaming
  // TODO: set this up with callbacks that somehow call update()
  startWindows();
#endif

  if (!(params_->applyFilter))
      return std::vector<cv::Point2f>();

  // if (params_->applyFilter)
  {
    findGoodCorners();

    // Refine the corners so that distances are absolute minima
    refineCorners();

    orderCorners();

    return corners_;
  }
}
コード例 #2
0
ファイル: harris_3d.hpp プロジェクト: hitsjt/StanfordPCL
template <typename PointInT, typename PointOutT, typename NormalT> void
pcl::HarrisKeypoint3D<PointInT, PointOutT, NormalT>::detectKeypoints (PointCloudOut &output)
{
  boost::shared_ptr<pcl::PointCloud<PointOutT> > response (new pcl::PointCloud<PointOutT> ());

  response->points.reserve (input_->points.size());

  switch (method_)
  {
    case HARRIS:
      responseHarris(*response);
      break;
    case NOBLE:
      responseNoble(*response);
      break;
    case LOWE:
      responseLowe(*response);
      break;
    case CURVATURE:
      responseCurvature(*response);
      break;
    case TOMASI:
      responseTomasi(*response);
      break;
  }

  if (!nonmax_)
    output = *response;
  else
  {
    output.points.clear ();
    output.points.reserve (response->points.size());

#ifdef _OPENMP
#pragma omp parallel for shared (output) num_threads(threads_)   
#endif
    for (int idx = 0; idx < static_cast<int> (response->points.size ()); ++idx)
    {
      if (!isFinite (response->points[idx]) || response->points[idx].intensity < threshold_)
        continue;
		  std::vector<int> nn_indices;
		  std::vector<float> nn_dists;
      tree_->radiusSearch (idx, search_radius_, nn_indices, nn_dists);
      bool is_maxima = true;
      for (std::vector<int>::const_iterator iIt = nn_indices.begin(); iIt != nn_indices.end(); ++iIt)
      {
        if (response->points[idx].intensity < response->points[*iIt].intensity)
        {
          is_maxima = false;
          break;
        }
      }
      if (is_maxima)
#ifdef _OPENMP
#pragma omp critical
#endif
        output.points.push_back (response->points[idx]);
    }

    if (refine_)
      refineCorners (output);

    output.height = 1;
    output.width = static_cast<uint32_t> (output.points.size());
  }

  // we don not change the denseness
  output.is_dense = input_->is_dense;
}