6.7.0 - Alpha20 - Paddle OCR 支持原始图像传输以提升性能, 并支持更灵活的选项配置

This commit is contained in:
SuperMonster003
2026-02-14 14:22:58 +08:00
parent ff478c0c0c
commit 43b1e890fd
4 changed files with 548 additions and 95 deletions

View File

@@ -14,6 +14,7 @@ import org.autojs.plugin.paddle.ocr.api.OcrResult
*
* Created by JetBrains AI Assistant (GPT-5.2) on Jan 17, 2026.
* Modified by SuperMonster003 as of Jan 18, 2026.
* Modified by JetBrains AI Assistant (GPT-5.2-Codex (xhigh)) as of Feb 13, 2026.
*/
class PredictorNativeBridge : NativeBridge {
@@ -110,6 +111,7 @@ class PredictorNativeBridge : NativeBridge {
}
override fun recognizeText(bitmap: Bitmap, options: OcrOptions): List<String> {
applyRuntimeOptions(options)
val results = predictor.runOcr(bitmap)
val out = ArrayList<String>(results.size)
for (r in results) out.add(r.label)
@@ -124,6 +126,7 @@ class PredictorNativeBridge : NativeBridge {
}
override fun detect(bitmap: Bitmap, options: OcrOptions): List<OcrResult> {
applyRuntimeOptions(options)
val results = predictor.runOcr(bitmap)
return results.map { r ->
OcrResult().apply {
@@ -135,4 +138,15 @@ class PredictorNativeBridge : NativeBridge {
}
}
private fun applyRuntimeOptions(options: OcrOptions) {
val detLongSize = options.detLongSize
if (detLongSize > 0) {
predictor.setDetLongSize(detLongSize)
}
val scoreThreshold = options.scoreThreshold
if (scoreThreshold >= 0f) {
predictor.setScoreThreshold(scoreThreshold)
}
}
}