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