OCRResult 在 PaddleOCR 3.x 里是「惰性序列化对象」 #17483
li-yun-peng
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
res.save_to_json() 能正常写文件,但 res.json / res.rec_* 都拿不到,说明 OCRResult 在 PaddleOCR 3.x 里是「惰性序列化对象」
👉 JSON 只在 save_to_json() 内部生成,并不会回填到 Python 对象属性
也就是说:
save_to_json() ≠ res.json
一、为什么会出现这种“反直觉”的情况(原理)
PaddleOCR 3.x 中:
OCRResult 是一个 C++/Python 混合封装对象
save_to_json(path) 内部流程是:
调用 C++ 结果
临时构造一个 dict
写入文件
不挂回 Python 对象
所以:
res.save_to_json("output") # ✅ 有文件
res.json # ❌ None / 不存在
res.rec_texts # ❌ 不存在
这是 PaddleOCR 3.x 的一个设计缺陷 / 未文档化行为。
Beta Was this translation helpful? Give feedback.
All reactions