feat(ocr): 添加本地照片路径支持用于喷洒识别功能
- 在OcrNavigationData数据类中新增localPhotoPath字段 - 在SprayingOCRActivity中传递localPhotoPath到结果页面 - 在SprayingResultActivity中接收并处理localPhotoPath参数 - 集成BitmapDecodeHelper进行图片解码处理 - 使用单线程执行器异步加载和显示本地照片 - 实现图片尺寸采样以优化内存使用
这个提交包含在:
父节点
6ed458bae2
当前提交
1f9edb54ed
@ -34,6 +34,7 @@ data class RecognizeByPathResponse(
|
|||||||
|
|
||||||
data class OcrNavigationData(
|
data class OcrNavigationData(
|
||||||
val filePath: String,
|
val filePath: String,
|
||||||
|
val localPhotoPath: String,
|
||||||
val ocrResultJson: String,
|
val ocrResultJson: String,
|
||||||
val judgment: String,
|
val judgment: String,
|
||||||
val one: String,
|
val one: String,
|
||||||
|
|||||||
@ -123,6 +123,7 @@ class SprayingOCRActivity :
|
|||||||
putExtra("taskId", taskId)
|
putExtra("taskId", taskId)
|
||||||
putExtra("productionInfoId", productionInfoId)
|
putExtra("productionInfoId", productionInfoId)
|
||||||
putExtra("filePath", result.filePath)
|
putExtra("filePath", result.filePath)
|
||||||
|
putExtra("localPhotoPath", result.localPhotoPath)
|
||||||
putExtra("ocrResultJson", result.ocrResultJson)
|
putExtra("ocrResultJson", result.ocrResultJson)
|
||||||
putExtra("judgment", result.judgment)
|
putExtra("judgment", result.judgment)
|
||||||
putExtra("one", result.one)
|
putExtra("one", result.one)
|
||||||
|
|||||||
@ -10,9 +10,11 @@ import android.os.Looper
|
|||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
import androidx.activity.result.contract.ActivityResultContracts
|
import androidx.activity.result.contract.ActivityResultContracts
|
||||||
|
import androidx.core.view.doOnLayout
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.nova.brain.glass.R
|
import com.nova.brain.glass.R
|
||||||
import com.nova.brain.glass.databinding.ActivitySprayingResultBinding
|
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.GlassMediaServiceHelper
|
||||||
import com.nova.brain.glass.helper.OfflineCmdListener
|
import com.nova.brain.glass.helper.OfflineCmdListener
|
||||||
import com.nova.brain.glass.helper.OfflineCmdServiceHelper
|
import com.nova.brain.glass.helper.OfflineCmdServiceHelper
|
||||||
@ -31,6 +33,7 @@ import com.xuqm.base.extensions.showMessage
|
|||||||
import com.xuqm.base.ui.BaseListFormLayoutNormalActivity
|
import com.xuqm.base.ui.BaseListFormLayoutNormalActivity
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.UUID
|
import java.util.UUID
|
||||||
|
import java.util.concurrent.Executors
|
||||||
|
|
||||||
class SprayingResultActivity :
|
class SprayingResultActivity :
|
||||||
BaseListFormLayoutNormalActivity<ItemItem, SprayingResultVM, ActivitySprayingResultBinding>() {
|
BaseListFormLayoutNormalActivity<ItemItem, SprayingResultVM, ActivitySprayingResultBinding>() {
|
||||||
@ -48,10 +51,14 @@ class SprayingResultActivity :
|
|||||||
private val filePath: String by lazy {
|
private val filePath: String by lazy {
|
||||||
intent.getStringExtra("filePath").orEmpty()
|
intent.getStringExtra("filePath").orEmpty()
|
||||||
}
|
}
|
||||||
|
private val localPhotoPath: String by lazy {
|
||||||
|
intent.getStringExtra("localPhotoPath").orEmpty()
|
||||||
|
}
|
||||||
private val ocrResultJson: String by lazy {
|
private val ocrResultJson: String by lazy {
|
||||||
intent.getStringExtra("ocrResultJson").orEmpty()
|
intent.getStringExtra("ocrResultJson").orEmpty()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val imageDecodeExecutor = Executors.newSingleThreadExecutor()
|
||||||
private var ocrOne: String = ""
|
private var ocrOne: String = ""
|
||||||
private var ocrTwo: String = ""
|
private var ocrTwo: String = ""
|
||||||
private var status = true
|
private var status = true
|
||||||
@ -220,6 +227,18 @@ class SprayingResultActivity :
|
|||||||
binding.value2.paintFlags = binding.value2.paintFlags or strikeFlag
|
binding.value2.paintFlags = binding.value2.paintFlags or strikeFlag
|
||||||
binding.value3.paintFlags = binding.value3.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() {
|
override fun onResume() {
|
||||||
|
|||||||
@ -90,6 +90,7 @@ class SprayingOCRVM : BaseListViewModel<ItemItem>() {
|
|||||||
val data = response.data ?: OcrResultData()
|
val data = response.data ?: OcrResultData()
|
||||||
ocrResult.value = OcrNavigationData(
|
ocrResult.value = OcrNavigationData(
|
||||||
filePath = serverPath,
|
filePath = serverPath,
|
||||||
|
localPhotoPath = localPath,
|
||||||
ocrResultJson = gson.toJson(data),
|
ocrResultJson = gson.toJson(data),
|
||||||
judgment = data.judgment,
|
judgment = data.judgment,
|
||||||
one = data.one,
|
one = data.one,
|
||||||
|
|||||||
正在加载...
在新工单中引用
屏蔽一个用户