Refactoring: move "norm" to Geometry.kt and add test
This commit is contained in:
@@ -25,7 +25,6 @@ import org.opencv.core.Size
|
||||
import org.opencv.imgproc.Imgproc
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.max
|
||||
import kotlin.math.sqrt
|
||||
|
||||
fun detectDocumentQuad(mask: Bitmap, minQuadAreaRatio: Double = 0.02): Quad? {
|
||||
val mat = Mat()
|
||||
@@ -143,8 +142,3 @@ fun Point.toCv(): org.opencv.core.Point {
|
||||
return org.opencv.core.Point(x.toDouble(), y.toDouble())
|
||||
}
|
||||
|
||||
private fun norm(p1: Point, p2: Point): Double {
|
||||
val dx = (p2.x - p1.x)
|
||||
val dy = (p2.y - p1.y)
|
||||
return sqrt(dx.toDouble() * dx + dy * dy)
|
||||
}
|
||||
|
||||
@@ -15,10 +15,21 @@
|
||||
package org.mydomain.myscan
|
||||
|
||||
import kotlin.math.atan2
|
||||
import kotlin.math.sqrt
|
||||
|
||||
data class Point(val x: Int, val y: Int)
|
||||
|
||||
data class Line(val from: Point, val to: Point)
|
||||
data class Line(val from: Point, val to: Point) {
|
||||
fun norm(): Double {
|
||||
return norm(from, to)
|
||||
}
|
||||
}
|
||||
|
||||
fun norm(p1: Point, p2: Point): Double {
|
||||
val dx = (p2.x - p1.x)
|
||||
val dy = (p2.y - p1.y)
|
||||
return sqrt(dx.toDouble() * dx + dy * dy)
|
||||
}
|
||||
|
||||
data class Quad(
|
||||
val topLeft: Point,
|
||||
|
||||
Reference in New Issue
Block a user