使用Hough变换(OpenCV)检测通道
//do Hough transform to find lanes
Imgproc.HoughLinesP(thresholdImage, lines, rho, theta, threshold, VActivity.HOUGH_MIN_LINE_LENGTH, VActivity.HOUGH_MAX_LINE_GAP);
for (int x = 0; x < lines.cols(); x++)
{
double[] vec = lines.get(0, x);
double x1 = vec[0],
y1 = vec[1],
x2 = vec[2],
y2 = vec[3];
Point start = new Point(x1, y1);
Point end = new Point(x2, y2);
double dx = x2 - x1;
double dy = y2 - y1;
double angle = Math.atan2(dy, dx) * 180 / Math.PI;
Log.i(VActivity.TAG, Double.toString(angle));
if (Math.abs(angle) <= VActivity.LINE_REJECT_DEGREES)
{
Log.i(VActivity.TAG, "Reject: " + Double.toString(angle));
// reject near horizontal lines
continue;
}
Core.line(mRgba, start, end, new Scalar(255, 0, 0), 3);
}
在代码结果我有4行x1,x2,y1,y2,但有时算法不检测通道并需要保存在一些哈希表中检测到的通道或其他东西?
Point start = new Point(x1, y1);
Point end = new Point(x2, y2);
你怎么看? 我需要找到从第一道到第二道的距离,以提醒用户将一条线穿过另一条线......