Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/356.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/264.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java OpenCV for Unity-HoughLines不返回任何行_Java_C#_Opencv_Unity3d - Fatal编程技术网

Java OpenCV for Unity-HoughLines不返回任何行

Java OpenCV for Unity-HoughLines不返回任何行,java,c#,opencv,unity3d,Java,C#,Opencv,Unity3d,我目前正在使用OpenCV for Unity3d(带有C#包装器的OpenCV for Java)。我尝试使用HoughLines获取行,但它总是空的 Mat originalToPlaywith = Room.OriginalRGB; Mat dst = new Mat(); Mat cdst = new Mat(); Imgproc.Canny(originalToPlaywith, dst, 50.0, 200); Imgproc.cvtColor(dst, cdst, Imgproc

我目前正在使用OpenCV for Unity3d(带有C#包装器的OpenCV for Java)。我尝试使用HoughLines获取行,但它总是空的

Mat originalToPlaywith = Room.OriginalRGB;
Mat dst = new Mat();
Mat cdst = new Mat();

Imgproc.Canny(originalToPlaywith, dst, 50.0, 200);
Imgproc.cvtColor(dst, cdst, Imgproc.COLOR_GRAY2BGRA);

Mat lines = new Mat();
Imgproc.HoughLines(dst, lines, Mathf.PI / 180, 150, 0);

Debug.Log(lines.rows());

double[] data;
double rho;
double theta;
Point pt1 = new Point();
Point pt2 = new Point();
double a;
double b;
double x0;
double y0;

for(int i = 0; i < lines.cols(); i++)
{
    data = lines.get(0, i);
    rho = data[0];
    theta = data[1];
    a = Math.Cos(theta);
    b = Math.Sin(theta);
    x0 = a * rho;
    y0 = b * rho;
    pt1.x = Math.Round(x0 + 1000 * (-b));
    pt1.y = Math.Round(y0 + 1000 * a);
    pt2.x = Math.Round(x0 - 1000 * (-b));
    pt2.y = Math.Round(y0 - 1000 * a);
    Scalar color = new Scalar(10, 10, 10, 10);
    Core.line(dst, pt1, pt2, color, 3);
    Debug.LogWarning("Line");
}
Mat originalToPlaywith=Room.OriginalRGB;
Mat dst=新Mat();
Mat cdst=新的Mat();
Imgproc.Canny(原始支付,dst,50.0200);
Imgproc.CVT颜色(dst、cdst、Imgproc.COLOR_GRAY2BGRA);
垫线=新垫();
Imgproc.HoughLines(dst,lines,Mathf.PI/180、150、0);
Debug.Log(lines.rows());
双[]数据;
双rho;
双θ;
点pt1=新点();
点pt2=新点();
双a;
双b;
双x0;
双y0;
对于(int i=0;i
不会让我发布图片,所以链接包括在内

原始图像

精明的形象


非常感谢您的帮助

输入参数150似乎有点太多了。尝试将其设置为默认值(0)。同时显示canny'd图像,并检查是否有线条。谢谢,我会尝试一下,看看会发生什么!输入参数150似乎有点太多了。尝试将其设置为默认值(0)。同时显示canny'd图像,并检查是否有线条。谢谢,我会尝试一下,看看会发生什么!