|
@@ -1,13 +1,10 @@
|
|
|
package com.ys.imageProcess.viewModel
|
|
|
|
|
|
-import android.content.ContentResolver
|
|
|
import android.content.ContentValues.TAG
|
|
|
import android.content.Context
|
|
|
-import android.database.Cursor
|
|
|
import android.graphics.Bitmap
|
|
|
import android.graphics.PointF
|
|
|
import android.net.Uri
|
|
|
-import android.provider.MediaStore
|
|
|
import android.util.Log
|
|
|
import androidx.compose.ui.geometry.Offset
|
|
|
import androidx.compose.ui.geometry.Rect
|
|
@@ -27,7 +24,6 @@ import com.ys.imageProcess.ui.work.zoomStep
|
|
|
import com.ys.imageProcess.utils.fileSizeString
|
|
|
import com.ys.imageProcess.utils.formatDate
|
|
|
import com.ys.imageProcess.utils.scaleLength
|
|
|
-import com.ys.imageProcess.utils.uriToBitmap
|
|
|
import com.ys.imageProcess.utils.zoomToFit
|
|
|
import kotlinx.coroutines.CoroutineScope
|
|
|
import kotlinx.coroutines.Dispatchers
|
|
@@ -123,7 +119,10 @@ class WorkViewModel : ViewModel() {
|
|
|
val bitmap = ProcessDataStore.getProcessedImage(name)
|
|
|
|
|
|
val ocrRes = OCRModelLoader.runModel(bitmap!!)
|
|
|
- Log.i(TAG, "OCR result: $ocrRes")
|
|
|
+ for (model in ocrRes) {
|
|
|
+ val scale = scaleLength(model.label)
|
|
|
+ Log.i(TAG, "OCR result: ${model.label}, $scale, ${model.points}")
|
|
|
+ }
|
|
|
|
|
|
val store = ProcessedData(bitmap)
|
|
|
store.setMap(storedMap)
|
|
@@ -135,19 +134,20 @@ class WorkViewModel : ViewModel() {
|
|
|
isAlgRunning = true
|
|
|
updateInfoMap()
|
|
|
val ocrRes = OCRModelLoader.runModel(it)
|
|
|
- var ocrStr = 100
|
|
|
+ var scale = 100
|
|
|
val ocrPos = mutableListOf<Int>()
|
|
|
if (ocrRes.isNotEmpty()) {
|
|
|
- ocrStr = scaleLength(ocrRes.first().label)
|
|
|
+ scale = scaleLength(ocrRes.first().label)
|
|
|
for (point in ocrRes.first().points) {
|
|
|
ocrPos.add(point.x)
|
|
|
ocrPos.add(point.y)
|
|
|
+ break
|
|
|
}
|
|
|
}
|
|
|
|
|
|
val result =
|
|
|
- Process().Detect(it, ocrStr, ocrPos.toIntArray())
|
|
|
- Log.i(TAG, "--- $result")
|
|
|
+ Process().Detect(it, scale, ocrPos.toIntArray())
|
|
|
+ Log.i(TAG, "--- $scale, $ocrPos")
|
|
|
val processed = ProcessedData(result.processedImage, result)
|
|
|
ProcessDataStore.saveResult(processed.map(), name)
|
|
|
ProcessDataStore.saveProcessedImage(
|