Java OpenCV for Unity-HoughLines不返回任何行
我目前正在使用OpenCV for Unity3d(带有C#包装器的OpenCV for Java)。我尝试使用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
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图像,并检查是否有线条。谢谢,我会尝试一下,看看会发生什么!