【发布时间】:2020-02-23 13:35:03
【问题描述】:
我想从这个过程中得到多行。
override fun onCameraFrame(inputFrame: CvCameraViewFrame): Mat? {
mRgba = inputFrame.rgba()
// generate gray scale and blur
Imgproc.cvtColor(mRgba, mRgbaFiltered, Imgproc.COLOR_BGR2GRAY)
Imgproc.blur(mRgbaFiltered, mRgbaFiltered, Size(3.0, 3.0))
// detect the edges
val mMat = Mat()
val ratio = 4
// Find Canny Edges
Imgproc.Canny(mRgbaFiltered, mMat, threshold, threshold * ratio.toDouble())
// Find horizontal lines
val lines = Mat()
Imgproc.HoughLinesP(mMat, lines, 1.0, Math.PI / 180, 80, 100.0, 10.0)
// Change Color to RGB
Imgproc.cvtColor(mMat, mMat, Imgproc.COLOR_GRAY2BGR)
// draw lines
for (i in 0 until lines.cols()) {
val `val` = lines[0, i]
Imgproc.line(
mMat,
Point(`val`[0], `val`[1]),
Point(`val`[2], `val`[3]),
Scalar(0.0, 255.0, 0.0),
1
)
}
num_lines = lines.cols()
updateHandler.postDelayed(updateRunnable, 500)
return mMat
}
但是,如下所示,我只得到一行。我需要画出所有的线。我该怎么做?
【问题讨论】:
-
你能分享纯图像而不是结果吗?
-
只是一堆卡片。 @尤纳斯
-
我用
Canny(img, dst, 80, 240, 3)和HoughLinesP(dst, lines, 1.0, CV_PI/180, 50, 100.0, 10.0 )这两个参数试了一下。它能够找到所有的行。我认为它与您使用的参数有关。你能在你的代码中分享阈值来测试你的吗? -
Canny 中的第三个参数是什么?我的是 Canny(img, dst, 80, 320), HoughLinesP(dst, lines, 1.0, CV_PI/180, 80, 100.0, 10.0) @YunusTemurlenk
-
Canny(input,output,threshold1,threshold2,apertureSize)当我使用你的时,我仍然得到所有的行。我找不到区别
标签: android opencv kotlin hough-transform