AWSTextract(OCR)未检测到某些单元格
创始人
2024-09-27 15:30:17
0

你可以在代码中使用Amazon Textract Python SDK的detect_tables函数来检测表格。 在表格检测后,您可以使用Amazon Textract Python SDK的get_tabular_data函数来提取表格中的单元格数据。

下面是一个使用Python和Amazon Textract Python SDK的示例代码:

import boto3

# set up AWS credentials and create Textract client
session = boto3.Session(profile_name='default', region_name='us-east-1')
textract = session.client('textract')

# process the image using Textract
response = textract.analyze_document(
    Document={
        'S3Object': {
            'Bucket': 'my-bucket',
            'Name': 'my-image.jpg'
        }
    },
    FeatureTypes=['TABLES']
)

# extract table data
for table in response['Blocks']:
    if table['BlockType'] == 'TABLE':
        rows = {}
        for relationship in table['Relationships']:
            if relationship['Type'] == 'CHILD':
                for child_id in relationship['Ids']:
                    cell = response['Blocks'][child_id]
                    if cell['BlockType'] == 'CELL':
                        row_index = cell['RowIndex']
                        col_index = cell['ColumnIndex']
                        text = cell['Text']
                        rows.setdefault(row_index, {})[col_index] = text

        # print the table content
        for row_index, row in rows.items():
            row_values = [row.get(col_index, '') for col_index in range(max(row.keys()) + 1)]
            print(row_values)

这个示例代码使用了Amazon Textract Python SDK的analyze_document函数来检测表格。 它返回一个包含所有检测到的块(包括表格)的响应对象。 然后,它遍历响应对象以查找表格块并提取表格单元格的数据。 最后,它打印出表格中的所有行。

请注意,Amazon Textract不保证能够检测所有类型的表格或所有单元格。 因此,如果您的表格不是常

相关内容

热门资讯

wepokeai机器人(透视)... wepokeai机器人(透视)wepoke有没有玄学(详细辅助新2025版)确实是有挂(可靠辅助德之...
wepoke模拟器(透视)we... wepoke模拟器(透视)wepoke软件透明功能实现方法(详细辅助教你教程)好像是真的有挂(科普插...
wepoke辅助德之星(透视)... wepoke辅助德之星(透视)wepooke app系统规律(详细辅助攻略方法)真是是有挂(教你有辅...
wepoke有辅助挂(透视)w... wepoke有辅助挂(透视)wepoke有辅助挂吗(详细辅助科技教程)一直是有挂(教你透视挂)1、让...
wepoke辅助有挂(透视)w... wepoke辅助有挂(透视)wepoke人有挂吗(详细辅助可靠技巧)其实有挂(了解辅助)1.wepo...
wepoke插件(透视)wep... wepoke插件(透视)wepoke软件收费是真的吗(详细辅助辅助教程)其实真的是有挂(专业模拟器)...
wepoke辅助德之星(透视)... wepoke辅助德之星(透视)wopoker辅助(详细辅助新2025教程)真是真的有挂(玩家ai机器...
we辅助poker德之星(透视... we辅助poker德之星(透视)wepoke辅助挂在哪开(详细辅助新2025版)确实是真的有挂(大神...
wepoke黑科技(透视)we... wepoke黑科技(透视)wepoke挂真的假的(详细辅助揭秘攻略)竟然存在有挂(攻略计算辅助)1、...
wepoke智能ai(透视)w... wepoke智能ai(透视)wepower让系统发好牌(详细辅助教你攻略)真是真的有挂(详细有挂)1...