feat(ocr): 支持 PP-OCRv6 异步识别模型并设为默认,解决排队与高延迟问题
This commit is contained in:
@@ -222,3 +222,20 @@ func pngHeader(width, height uint32) []byte {
|
||||
binary.Write(&result, binary.BigEndian, checksum)
|
||||
return result.Bytes()
|
||||
}
|
||||
|
||||
func TestCollectPaddleOCRJSONLTextSupportsPPOCRv6(t *testing.T) {
|
||||
rawJSONL := `{"result":{"ocrResults":[{"prunedResult":{"rec_texts":["火爆出租-778群","扫码加入群聊"]},"ocrImage":"https://example.com/ocr.jpg","inputImage":"https://example.com/in.jpg"}]}}`
|
||||
text := collectPaddleOCRJSONLText(rawJSONL)
|
||||
if !strings.Contains(text, "火爆出租-778群") || !strings.Contains(text, "扫码加入群聊") {
|
||||
t.Fatalf("collected text = %q, expected recognized group texts", text)
|
||||
}
|
||||
if strings.Contains(text, "ocr.jpg") || strings.Contains(text, "in.jpg") {
|
||||
t.Fatalf("collected text = %q, should not include image URLs", text)
|
||||
}
|
||||
|
||||
candidates := parseQrCodeGroupNameCandidates(text)
|
||||
if len(candidates) == 0 || candidates[0] != "火爆出租-778群" {
|
||||
t.Fatalf("candidates = %v, want 火爆出租-778群 as first candidate", candidates)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user