Avoid detecting very small quadrilaterals
This commit is contained in:
@@ -27,7 +27,7 @@ import kotlin.math.abs
|
||||
import kotlin.math.max
|
||||
import kotlin.math.sqrt
|
||||
|
||||
fun detectDocumentQuad(mask: Bitmap): Quad? {
|
||||
fun detectDocumentQuad(mask: Bitmap, minQuadAreaRatio: Double = 0.02): Quad? {
|
||||
val mat = Mat()
|
||||
Utils.bitmapToMat(mask, mat)
|
||||
|
||||
@@ -62,6 +62,10 @@ fun detectDocumentQuad(mask: Bitmap): Quad? {
|
||||
}
|
||||
}
|
||||
|
||||
if (maxArea < mask.width * mask.height * minQuadAreaRatio) {
|
||||
return null
|
||||
}
|
||||
|
||||
val vertices = biggest?.toList()?.map { Point(it.x.toInt(), it.y.toInt()) }
|
||||
return createQuad(vertices)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user