首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >是否有方法使用OCR从CAD技术图纸中提取特定数据?

是否有方法使用OCR从CAD技术图纸中提取特定数据?
EN

Stack Overflow用户
提问于 2020-12-22 12:50:18
回答 2查看 236关注 0票数 0

我试图使用OCR只提取CAD模型的基本尺寸,但是还有其他我不需要的关联维度(比如角度、从基线到孔的长度等等)。这里是一个技术绘图的例子。(红色圆圈中的数字是基本尺寸,其余的紫色高光是需要忽略的。)如何告诉我的程序只提取基本尺寸(在通过数控系统之前,块的高度、长度和宽度)?

问题是,我得到的图纸不是一个特定的格式,所以我不能告诉OCR的尺寸在哪里。它必须根据自己的具体情况来判断。

我应该通过运行几次迭代来通过机器学习来训练程序并对其进行修正吗?如果是,有什么方法?我唯一能想到的就是Opencv级联分类器。还是有其他方法来解决这个问题?很抱歉寄了这么长的邮筒。谢谢。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2022-01-14 15:14:02

我感觉到你..。这是一个非常棘手的问题,我们花了三年时间为它找到解决方案。请原谅我提到了自己的解决方案,但它肯定会解决您的问题:pip install werk24

代码语言:javascript
运行
复制
from werk24 import Hook, W24AskVariantMeasures
from werk24.models.techread import W24TechreadMessage
from werk24.utils import w24_read_sync
    
from . import get_drawing_bytes # define your own
    
    
def recv_measures(message: W24TechreadMessage) -> None:
    for cur_measure in message.payload_dict.get('measures'):
        print(cur_measure)
    
if __name__ == "__main__":
    # define what information you want to receive from the API
    # and what shall be done when the info is available.
    hooks = [Hook(ask=W24AskVariantMeasures(), function=recv_measures)]
    
    # submit the request to the Werk24 API
    w24_read_sync(get_drawing_bytes(), hooks)

在您的示例中,它将返回例如以下度量

代码语言:javascript
运行
复制
    {
        "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

代码语言:javascript
运行
复制
{
    "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上的文档。

票数 1
EN

Stack Overflow用户

发布于 2022-11-22 21:00:22

虽然米克斯派克是一种托管产品,但它是一种免费选择:

pip install mixpeek

代码语言:javascript
运行
复制
from mixpeek import Mixpeek  
  
mix = Mixpeek(  
    api_key="my-api-key"  
)  
  
mix.upload(file_name="design_spec.dwg", file_path="s3://design_spec_1.dwg")

这个/upload端点将提取DWG文件的内容,然后当您搜索术语时,它将包括file_path,以便在您的file_path中呈现它。

在幕后,它使用开源LibreDWG库运行许多AutoCAD本机命令,如DATAEXTRACTION

现在您可以搜索一个术语,并返回相关的DWG文件(除了其存在的上下文):

代码语言:javascript
运行
复制
mix.search(query="retainer", include_context=True)

[  
    {  
        "file_id": "6377c98b3c4f239f17663d79",  
        "filename": "design_spec.dwg",  
        "context": [  
            {  
                "texts": [  
                    {  
                        "type": "text",  
                        "value": "DV-34-"  
                    },  
                    {  
                        "type": "hit",  
                        "value": "RETAINER"  
                    },  
                    {  
                        "type": "text",  
                        "value": "."  
                    }  
                ]  
            }  
        ],  
        "importance": "100%",  
        "static_file_url": "s3://design_spec_1.dwg"  
    }  
]

这里有更多的文档:https://docs.mixpeek.com/

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65409063

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档