使用OCR从CAD技术图纸中提取特定数据的方法?

我想使用OCR仅提取CAD模型的基础尺寸,但有一些我不需要的关联尺寸(如角度、从基线到孔的长度等)。这是一个技术图纸的例子。(红色圆圈中的数字是基础尺寸,其余紫色高亮的部分是需要忽略的。) 如何告诉我的程序只提取基础尺寸(在进入CNC之前的块体的高度、长度和宽度)?

问题在于我得到的图纸没有特定的格式,所以我无法告诉OCR尺寸的位置。它必须通过上下文自己判断。

我应该通过机器学习来训练程序,运行几次迭代并进行纠正吗?如果是,哪些方法是可行的?我能想到的唯一方法是Opencv级联分类器。还有其他解决这个问题的办法吗?抱歉这篇文章有点长。谢谢。


回答:

我理解你的感受…这是一个非常棘手的问题,我们花了过去三年时间寻找解决方案。请原谅我提及自己的解决方案,但它肯定能解决你的问题:pip install werk24

from werk24 import Hook, W24AskVariantMeasuresfrom werk24.models.techread import W24TechreadMessagefrom werk24.utils import w24_read_sync    from . import get_drawing_bytes # 定义你自己的        def recv_measures(message: W24TechreadMessage) -> None:    for cur_measure in message.payload_dict.get('measures'):        print(cur_measure)    if __name__ == "__main__":    # 定义你希望从API接收的信息    # 以及信息可用时要执行的操作。    hooks = [Hook(ask=W24AskVariantMeasures(), function=recv_measures)]        # 向Werk24 API提交请求    w24_read_sync(get_drawing_bytes(), hooks)

在你的例子中,它将返回例如以下测量值

    {        "position": <STRIPPED>        "label": {            "blurb": "ø30 H7 +0.0210/0",            "quantity": 1,            "size": {                "blurb": "30",                "size_type":" "DIAMETER",                "nominal_size": "30.0",            },            "unit": "MILLIMETER",            "size_tolerance": {                "toleration_type": "FIT_SIZE_ISO",                "blurb": "H7",                "deviation_lower": "0.0",                "deviation_upper": "0.0210",                "fundamental_deviation": "H",                "tolerance_grade": {                    "grade":7,                    "warnings":[]                },            "thread": null,            "chamfer": null,            "depth":null,            "test_dimension": null,         },         "warnings": [],         "confidence": 0.98810    }

或者对于GD&T

{    "position": <STRIPPED>,    "frame": {        "blurb": "[⟂|0.05|A]",        "characteristic": "⟂",        "zone_shape": null,        "zone_value": {            "blurb": "0.05",            "width_min": 0.05,            "width_max": null,            "extend_quantity": null,            "extend_shape": null,            "extend": null,            "extend_angle": null        },        "zone_combinations": [],        "zone_offset": null,        "zone_constraint": null,        "feature_filter": null,        "feature_associated": null,        "feature_derived": null,        "reference_association": null,        "reference_parameter": null,        "material_condition": null,        "state": null,        "data": [            {                "blurb": "A"            }         ]    }}

详细信息请查看Werk24的文档。

Related Posts

使用LSTM在Python中预测未来值

这段代码可以预测指定股票的当前日期之前的值,但不能预测…

如何在gensim的word2vec模型中查找双词组的相似性

我有一个word2vec模型,假设我使用的是googl…

dask_xgboost.predict 可以工作但无法显示 – 数据必须是一维的

我试图使用 XGBoost 创建模型。 看起来我成功地…

ML Tuning – Cross Validation in Spark

我在https://spark.apache.org/…

如何在React JS中使用fetch从REST API获取预测

我正在开发一个应用程序,其中Flask REST AP…

如何分析ML.NET中多类分类预测得分数组?

我在ML.NET中创建了一个多类分类项目。该项目可以对…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注