您正在使用 HoughLines Method 来检测来自相机的线条,我已经过滤了我的图片" imgProcessed"使用 ROI 意味着只获取黑色对象以使跟踪变得简单,然后当我打算使用HoughLines方法时,它会给我一个错误,即我的" CannyEdges"有一些无效的参数,这是我的代码:
Image<Gray, Byte> gray = imgProcessed.Convert<Gray, Byte>().PyrDown().PyrUp();
Gray cannyThreshold = new Gray(180);
Gray cannyThresholdLinking = new Gray(120);
Gray circleAccumulatorThreshold = new Gray(120);
Image<Gray, Byte> cannyEdges = gray.Canny(cannyThreshold, cannyThresholdLinking);
LineSegment2D[] lines = imgProcessed.cannyEdges.HoughLines(
cannyThreshold,
cannyThresholdLinking,
1, //Distance resolution in pixel-related units
Math.PI / 45.0, //Angle resolution measured in radians.
50, //threshold
100, //min Line width
1 //gap between lines
)[0]; //Get the lines from the first channel
答案 0 :(得分:0)
我编辑了我的代码&amp;它有效,我已经设计了两个部分:第一部分,我已经检测到了canny边缘而不是使用 HoughLines方法来自动检测它,而第二部分我已经使用了 HoughLinesBinary方法而不是 HoughLines 参数较少,这里是代码:
Image<Gray, Byte> gray1 = imgProcessed.Convert<Gray, Byte>().PyrDown().PyrUp();
Image<Gray, Byte> cannyGray = gray1.Canny(120, 180);
imgProcessed = cannyGray;
LineSegment2D[] lines = imgProcessed.HoughLinesBinary(
1, //Distance resolution in pixel-related units
Math.PI / 45.0, //Angle resolution measured in radians.
50, //threshold
100, //min Line width
1 //gap between lines
)[0]; //Get the lines from the first channel