문제

Hi am using HoughLines Method to detect lines from a camera, i've filtered my image "imgProcessed" using ROI it means getting just the black objects to make the tracking simple, then when i intend to use the HoughLines method it gives me an error that my "CannyEdges" has some invalid arguments, here's my code :

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
도움이 되었습니까?

해결책

I've edited my code & it works, i've devised it in two parts : the first part where i've detected the canny edges rather then use the HoughLines method to detect it automatically, and the 2nd where i've used the HoughLinesBinary method rather than HoughLines with less arguments, here is the code :

        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
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top