http://funvision.blogspot.com/2016/01/hough-lines-and-canny-edge-sobel.html
vector lines;
// Find hough lines
HoughLinesP(edges, lines, 1, CV_PI / 180, 100, 100, 10);
// Prepare blank mat with same sizes as image
Mat Blank(image.rows, image.cols, CV_8UC3, Scalar(0, 0, 0));
// Draw lines into image and Blank images
for (size_t i = 0; i < lines.size(); i++)
{
Vec4i l = lines[i];
line(image, Point(l[0], l[1]), Point(l[2], l[3]), Scalar(0, 0, 0), 2, CV_AA);
line(Blank, Point(l[0], l[1]), Point(l[2], l[3]), Scalar(255, 255, 255), 2, CV_AA);
}
I have translated these lines like the following:
Mat image = Cv2.ImRead("1.jpg", 0);
Cv2.Resize(image, image, new OpenCvSharp.CPlusPlus.Size(800, 600));
Mat edges = new Mat();
Cv2.Canny(image, edges, 95, 100);
Cv2.ImWrite("edges.jpg", edges);
Cv2.ImShow("Canny edges", edges);
Mat dx = new Mat();
Mat dy = new Mat();
Cv2.Sobel(edges, dx, MatType.CV_32F, 1, 0);
Cv2.Sobel(edges, dy, MatType.CV_32F, 0, 1);
Cv2.ImWrite("dx.jpg", dx);
Cv2.ImShow("Sobel in x dirrection", dx);
Cv2.ImWrite("dy.jpg", dy);
Cv2.ImShow("Sobel in y dirrection", dy);
List lines = new List();
//Cv.HoughLines2(lines, edges, HoughLinesMethod.Standard,1, Math.PI / 180, 100, 100, 10)
//Cv2.HoughLinesP(edges, lines, 1, Math.PI / 180, 100, 100, 10);
Mat Blank = new Mat(image.Rows, image.Cols, MatType.CV_8UC3, new Scalar(0, 0, 0));
for (int i = 0; i < lines.Count; i++)
{
Vec4i l = lines[i];
Cv2.Line(image, new OpenCvSharp.CPlusPlus.Point(l[0], l[1]), new OpenCvSharp.CPlusPlus.Point(l[2], l[3]), new Scalar(0, 0, 0), 2, Cv.AA);
Cv2.Line(Blank, new OpenCvSharp.CPlusPlus.Point(l[0], l[1]), new OpenCvSharp.CPlusPlus.Point(l[2], l[3]), new Scalar(255, 255, 255), 2, Cv.AA);
}
Cv2.ImWrite("houg.jpg", image);
Cv2.ImShow("Edges", image);
Cv2.ImWrite("houg2.jpg", Blank);
Cv2.ImShow("Edges Structure", Blank);
It seems to be not working:
[![enter image description here][1]][1]
Differs in the number of arguments. I have tried various combinations or arguments and data types. None of them actually works. The code I posted, is actually showing least error.
[![enter image description here][2]][2]
[1]: http://i.stack.imgur.com/U70hP.png
[2]: http://i.stack.imgur.com/lLlos.png
↧