我的mRgba对象的尺寸为0X0,因此它不会返回图片上的任何线条 在所有。我猜它是空的。代码中有什么问题?有没有办法显示线条 黑色背景?
这是代码
mat = new Mat();
edges = new Mat();
Mat mRgba = new Mat(612,816, CvType.CV_8UC1);
Mat lines = new Mat();
Utils.bitmapToMat(bitmap, mat);
Imgproc.Canny(mat, edges, 50, 90);
int threshold = 50;
int minLineSize = 20;
int lineGap = 20;
Imgproc.HoughLinesP(edges, lines, 1, Math.PI / 180,threshold,minLineSize,lineGap);
for (int x = 0; x < lines.cols(); x++) {
double[] vec = lines.get(0, x);
double x1 = vec[0],
y1 = vec[1],
x2 = vec[2],
y2 = vec[3];
Point start = new Point(x1, y1);
Point end = new Point(x2, y2);
Core.line(mRgba, start, end, new Scalar(255, 0, 0), 3);
}
Bitmap bmp = Bitmap.createBitmap(mRgba.cols(), mRgba.rows(), Bitmap.Config.ARGB_8888);
Utils.matToBitmap(mRgba, bmp);
bitmap=bmp;
编辑:通过删除GaussianBlur和阈值方法
解决了这个问题browser-sync start --server --files "*.html, css/*.css"
答案 0 :(得分:2)
mRgba
时没有指定大小,它应该与您尝试查找行的图像具有相同的大小。 lines
对象,看看您是否能够找到行或
不。您可以通过查看mRgba
。