std::vector<ParametricLine> LineHoughTransform::detectLines()
{
  std::vector<ParametricLine> lines;

  // Populate the accumulator.
  for(int i = 0; i < rows_; ++i)
  {
    for(int j = 0; j < cols_; ++j)
    {
      if(edges_[i * cols_ + j] >= getGradientThreshold())
      {
        pointToCurve(j, i - (rows_-1)/2);
      }
    }
  }

  // Determine the intersection of curves in Hough space
  // corresponding to lines in the image.
  for(int d = 0; d < maxDistance_; ++d)
  {
    for(int t = 0; t < 91; ++t)
    {
      if(accumulator_[d*91+t] >= getVoteThreshold())
      {
        lines.push_back(ParametricLine(d, static_cast<float>(t)*(M_PI/90.0f) - M_PI_2));
      }
    }
  }

  return lines;
}
Exemple #2
0
ParametricLine LineFuncs::ToParametricLine(const Line& line) {
	TIMETHISFUNCTION;
	const RPolynomial t = RPolynomial::MakeT();
	// TODO: Clean this shit up
	return ParametricLine(
		t * line.Direction().X() + line.Start().X(),
		t * line.Direction().Y() + line.Start().Y(),
		t * line.Direction().Z() + line.Start().Z() 
	);
}