feat(ocr): 添加本地照片路径支持用于喷洒识别功能

- 在OcrNavigationData数据类中新增localPhotoPath字段
- 在SprayingOCRActivity中传递localPhotoPath到结果页面
- 在SprayingResultActivity中接收并处理localPhotoPath参数
- 集成BitmapDecodeHelper进行图片解码处理
- 使用单线程执行器异步加载和显示本地照片
- 实现图片尺寸采样以优化内存使用
这个提交包含在:
徐勤民 2026-04-21 16:20:42 +08:00
父节点 6ed458bae2
当前提交 1f9edb54ed
共有 4 个文件被更改,包括 22 次插入0 次删除

查看文件

@ -34,6 +34,7 @@ data class RecognizeByPathResponse(
data class OcrNavigationData(
val filePath: String,
val localPhotoPath: String,
val ocrResultJson: String,
val judgment: String,
val one: String,

查看文件

@ -123,6 +123,7 @@ class SprayingOCRActivity :
putExtra("taskId", taskId)
putExtra("productionInfoId", productionInfoId)
putExtra("filePath", result.filePath)
putExtra("localPhotoPath", result.localPhotoPath)
putExtra("ocrResultJson", result.ocrResultJson)
putExtra("judgment", result.judgment)
putExtra("one", result.one)

查看文件

@ -10,9 +10,11 @@ import android.os.Looper
import android.view.LayoutInflater
import android.view.WindowManager
import androidx.activity.result.contract.ActivityResultContracts
import androidx.core.view.doOnLayout
import androidx.recyclerview.widget.RecyclerView
import com.nova.brain.glass.R
import com.nova.brain.glass.databinding.ActivitySprayingResultBinding
import com.nova.brain.glass.helper.BitmapDecodeHelper
import com.nova.brain.glass.helper.GlassMediaServiceHelper
import com.nova.brain.glass.helper.OfflineCmdListener
import com.nova.brain.glass.helper.OfflineCmdServiceHelper
@ -31,6 +33,7 @@ import com.xuqm.base.extensions.showMessage
import com.xuqm.base.ui.BaseListFormLayoutNormalActivity
import java.io.File
import java.util.UUID
import java.util.concurrent.Executors
class SprayingResultActivity :
BaseListFormLayoutNormalActivity<ItemItem, SprayingResultVM, ActivitySprayingResultBinding>() {
@ -48,10 +51,14 @@ class SprayingResultActivity :
private val filePath: String by lazy {
intent.getStringExtra("filePath").orEmpty()
}
private val localPhotoPath: String by lazy {
intent.getStringExtra("localPhotoPath").orEmpty()
}
private val ocrResultJson: String by lazy {
intent.getStringExtra("ocrResultJson").orEmpty()
}
private val imageDecodeExecutor = Executors.newSingleThreadExecutor()
private var ocrOne: String = ""
private var ocrTwo: String = ""
private var status = true
@ -220,6 +227,18 @@ class SprayingResultActivity :
binding.value2.paintFlags = binding.value2.paintFlags or strikeFlag
binding.value3.paintFlags = binding.value3.paintFlags or strikeFlag
}
if (localPhotoPath.isNotBlank()) {
binding.iv.doOnLayout {
val w = it.width.coerceAtLeast(1)
val h = it.height.coerceAtLeast(1)
imageDecodeExecutor.execute {
val bitmap = BitmapDecodeHelper.decodeSampledBitmap(localPhotoPath, w, h)
runOnUiThread {
if (!isFinishing && !isDestroyed) binding.iv.setImageBitmap(bitmap)
}
}
}
}
}
override fun onResume() {

查看文件

@ -90,6 +90,7 @@ class SprayingOCRVM : BaseListViewModel<ItemItem>() {
val data = response.data ?: OcrResultData()
ocrResult.value = OcrNavigationData(
filePath = serverPath,
localPhotoPath = localPath,
ocrResultJson = gson.toJson(data),
judgment = data.judgment,
one = data.one,