Question

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
Was it helpful?

Solution

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top