|
@@ -3,6 +3,7 @@ package com.ys.imageProcess.viewModel
|
|
import android.content.ContentValues.TAG
|
|
import android.content.ContentValues.TAG
|
|
import android.content.Context
|
|
import android.content.Context
|
|
import android.graphics.Bitmap
|
|
import android.graphics.Bitmap
|
|
|
|
+import android.graphics.Point
|
|
import android.graphics.PointF
|
|
import android.graphics.PointF
|
|
import android.net.Uri
|
|
import android.net.Uri
|
|
import android.util.Log
|
|
import android.util.Log
|
|
@@ -119,11 +120,18 @@ class WorkViewModel : ViewModel() {
|
|
val bitmap = ProcessDataStore.getProcessedImage(name)
|
|
val bitmap = ProcessDataStore.getProcessedImage(name)
|
|
|
|
|
|
val ocrRes = OCRModelLoader.runModel(bitmap!!)
|
|
val ocrRes = OCRModelLoader.runModel(bitmap!!)
|
|
|
|
+ var scale = 100
|
|
|
|
+ var topLeft = Point()
|
|
|
|
+
|
|
for (model in ocrRes) {
|
|
for (model in ocrRes) {
|
|
- val scale = scaleLength(model.label)
|
|
|
|
- Log.i(TAG, "OCR result: ${model.label}, $scale, ${model.points}")
|
|
|
|
|
|
+ if (model.label.contains("0") && model.label.contains("m")) {
|
|
|
|
+ scale = scaleLength(model.label)
|
|
|
|
+ topLeft = model.points.first()
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ Log.i(TAG, "--- $scale, $topLeft")
|
|
|
|
+
|
|
val store = ProcessedData(bitmap)
|
|
val store = ProcessedData(bitmap)
|
|
store.setMap(storedMap)
|
|
store.setMap(storedMap)
|
|
final = store
|
|
final = store
|
|
@@ -135,19 +143,18 @@ class WorkViewModel : ViewModel() {
|
|
updateInfoMap()
|
|
updateInfoMap()
|
|
val ocrRes = OCRModelLoader.runModel(it)
|
|
val ocrRes = OCRModelLoader.runModel(it)
|
|
var scale = 100
|
|
var scale = 100
|
|
- val ocrPos = mutableListOf<Int>()
|
|
|
|
- if (ocrRes.isNotEmpty()) {
|
|
|
|
- scale = scaleLength(ocrRes.first().label)
|
|
|
|
- for (point in ocrRes.first().points) {
|
|
|
|
- ocrPos.add(point.x)
|
|
|
|
- ocrPos.add(point.y)
|
|
|
|
- break
|
|
|
|
|
|
+ var topLeft = Point()
|
|
|
|
+
|
|
|
|
+ for (model in ocrRes) {
|
|
|
|
+ if (model.label.contains("0") && model.label.contains("m")) {
|
|
|
|
+ scale = scaleLength(model.label)
|
|
|
|
+ topLeft = model.points.first()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
val result =
|
|
val result =
|
|
- Process().Detect(it, scale, ocrPos.toIntArray())
|
|
|
|
- Log.i(TAG, "--- $scale, $ocrPos")
|
|
|
|
|
|
+ Process().Detect(it, scale, topLeft.x, topLeft.y)
|
|
|
|
+ Log.i(TAG, "--- $scale, $topLeft")
|
|
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(
|