Reorg: new package for domain
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.fairscan.app
|
||||
package org.fairscan.app.domain
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Bitmap
|
||||
@@ -51,8 +51,8 @@ class DocumentDetectionTest {
|
||||
segmentationService.runSegmentationAndReturn(bitmap, 0)
|
||||
}
|
||||
if (segmentationResult != null) {
|
||||
val mask = segmentationResult.segmentation.toBinaryMask()
|
||||
val quad = detectDocumentQuad(mask)
|
||||
val mask = segmentationResult.segmentation
|
||||
val quad = detectDocumentQuad(mask, false)
|
||||
if (quad != null) {
|
||||
val resizedQuad =
|
||||
quad.scaledTo(mask.width, mask.height, bitmap.width, bitmap.height)
|
||||
@@ -16,6 +16,7 @@ package org.fairscan.app
|
||||
|
||||
import android.graphics.Bitmap
|
||||
import androidx.compose.runtime.Immutable
|
||||
import org.fairscan.app.domain.Quad
|
||||
|
||||
@Immutable
|
||||
data class LiveAnalysisState(
|
||||
|
||||
@@ -40,6 +40,10 @@ import kotlinx.coroutines.flow.update
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.fairscan.app.data.recentDocumentsDataStore
|
||||
import org.fairscan.app.domain.ImageSegmentationService
|
||||
import org.fairscan.app.domain.detectDocumentQuad
|
||||
import org.fairscan.app.domain.extractDocument
|
||||
import org.fairscan.app.domain.scaledTo
|
||||
import org.fairscan.app.ui.PdfGenerationUiState
|
||||
import org.fairscan.app.ui.RecentDocumentUiState
|
||||
import org.fairscan.app.view.DocumentUiModel
|
||||
|
||||
@@ -12,14 +12,14 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.fairscan.app
|
||||
package org.fairscan.app.domain
|
||||
|
||||
import android.graphics.Bitmap
|
||||
import androidx.core.graphics.createBitmap
|
||||
import org.fairscan.app.ImageSegmentationService.Segmentation
|
||||
import org.fairscan.app.quad.detectDocumentQuadFromProbmap
|
||||
import org.fairscan.app.quad.findQuadFromRightAngles
|
||||
import org.fairscan.app.quad.minAreaRect
|
||||
import org.fairscan.app.domain.ImageSegmentationService.Segmentation
|
||||
import org.fairscan.app.domain.quad.detectDocumentQuadFromProbmap
|
||||
import org.fairscan.app.domain.quad.findQuadFromRightAngles
|
||||
import org.fairscan.app.domain.quad.minAreaRect
|
||||
import org.opencv.android.Utils
|
||||
import org.opencv.core.Core
|
||||
import org.opencv.core.CvType
|
||||
@@ -12,9 +12,10 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.fairscan.app
|
||||
package org.fairscan.app.domain
|
||||
|
||||
import kotlin.math.atan2
|
||||
import kotlin.math.hypot
|
||||
|
||||
data class Point(val x: Double, val y: Double) {
|
||||
constructor(x: Int, y: Int) : this (x.toDouble(), y.toDouble())
|
||||
@@ -29,7 +30,7 @@ data class Line(val from: Point, val to: Point) {
|
||||
fun norm(p1: Point, p2: Point): Double {
|
||||
val dx = (p2.x - p1.x)
|
||||
val dy = (p2.y - p1.y)
|
||||
return kotlin.math.hypot(dx, dy)
|
||||
return hypot(dx, dy)
|
||||
}
|
||||
|
||||
data class Quad(
|
||||
@@ -12,7 +12,7 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.fairscan.app
|
||||
package org.fairscan.app.domain
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Bitmap
|
||||
@@ -12,13 +12,12 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.fairscan.app
|
||||
package org.fairscan.app.domain
|
||||
|
||||
import android.util.Log
|
||||
import org.opencv.core.Core
|
||||
import org.opencv.core.CvType
|
||||
import org.opencv.core.Mat
|
||||
import org.opencv.core.MatOfDouble
|
||||
import org.opencv.core.Scalar
|
||||
import org.opencv.core.Size
|
||||
import org.opencv.imgproc.Imgproc
|
||||
@@ -12,7 +12,7 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.fairscan.app.quad
|
||||
package org.fairscan.app.domain.quad
|
||||
|
||||
import org.opencv.core.Mat
|
||||
import org.opencv.core.CvType
|
||||
@@ -12,9 +12,9 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.fairscan.app.quad
|
||||
package org.fairscan.app.domain.quad
|
||||
|
||||
import org.fairscan.app.Point
|
||||
import org.fairscan.app.domain.Point
|
||||
import kotlin.math.cos
|
||||
import kotlin.math.sin
|
||||
|
||||
@@ -12,9 +12,9 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.fairscan.app.quad
|
||||
package org.fairscan.app.domain.quad
|
||||
|
||||
import org.fairscan.app.Point
|
||||
import org.fairscan.app.domain.Point
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.acos
|
||||
import kotlin.math.sqrt
|
||||
@@ -55,8 +55,8 @@ import androidx.lifecycle.compose.LocalLifecycleOwner
|
||||
import com.google.common.util.concurrent.ListenableFuture
|
||||
import org.fairscan.app.CameraPermissionState
|
||||
import org.fairscan.app.LiveAnalysisState
|
||||
import org.fairscan.app.Point
|
||||
import org.fairscan.app.scaledTo
|
||||
import org.fairscan.app.domain.Point
|
||||
import org.fairscan.app.domain.scaledTo
|
||||
import java.util.concurrent.ExecutorService
|
||||
import java.util.concurrent.Executors
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.fairscan.app
|
||||
package org.fairscan.app.domain
|
||||
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.assertj.core.api.Assertions.assertThatThrownBy
|
||||
Reference in New Issue
Block a user