Skip to content
Snippets Groups Projects
Commit 03df4baf authored by Michael Utama's avatar Michael Utama
Browse files

fix: weird cropping behavior and centralize pattern coordinate

parent a2387fd6
1 merge request!60merge: sprint 5 finalization
...@@ -111,7 +111,7 @@ object CropHelper { ...@@ -111,7 +111,7 @@ object CropHelper {
pointsList.forEach { pointsList.forEach {
if (needChange == 0) return@forEach if (needChange == 0) return@forEach
val corner = nearWhichCorner(it.x, it.y, resultMatrix.height(), resultMatrix.width(), limFrac = 0.6F) val corner = nearWhichCorner(it.x, it.y, resultMatrix.height(), resultMatrix.width(), limFrac = 0.4F)
if (corner == -1) return@forEach if (corner == -1) return@forEach
if (it.weight > 0.45) { if (it.weight > 0.45) {
...@@ -130,23 +130,19 @@ object CropHelper { ...@@ -130,23 +130,19 @@ object CropHelper {
if (needed[corner]) { if (needed[corner]) {
needed[corner] = false needed[corner] = false
needChange-- needChange--
val pointFromIt = Point(it.y.toDouble(), it.x.toDouble()) val pointFromIt = Point(it.y.toDouble() + pattern.width().toDouble() / 2, it.x.toDouble() + pattern.height().toDouble() / 2)
when (corner) { when (corner) {
UPPER_LEFT -> { UPPER_LEFT -> {
upperLeftPoint = pointFromIt upperLeftPoint = pointFromIt
} }
UPPER_RIGHT -> { UPPER_RIGHT -> {
upperRightPoint = pointFromIt upperRightPoint = pointFromIt
upperRightPoint.x += pattern.height().toDouble()
} }
LOWER_RIGHT -> { LOWER_RIGHT -> {
lowerRightPoint = pointFromIt lowerRightPoint = pointFromIt
lowerRightPoint.x += pattern.height().toDouble()
lowerRightPoint.y += pattern.width().toDouble()
} }
LOWER_LEFT -> { LOWER_LEFT -> {
lowerLeftPoint = pointFromIt lowerLeftPoint = pointFromIt
lowerLeftPoint.y += pattern.width().toDouble()
} }
} }
} }
...@@ -319,6 +315,6 @@ object CropHelper { ...@@ -319,6 +315,6 @@ object CropHelper {
* @return weight * @return weight
*/ */
private fun getWeight(normDistance: Double): Double { private fun getWeight(normDistance: Double): Double {
return 1 + 1 * normDistance.pow(1.5) return 1 + 1 * normDistance.pow(0.5)
} }
} }
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment