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不保证能够检测所有类型的表格或所有单元格。 因此,如果您的表格不是常

相关内容

热门资讯

今日头条!wepokerplu... 今日头条!wepokerplus外挂(辅助挂)确实有挂(有挂技巧辅助脚本)1、完成辅助器v3.3的残...
记者发布!fishpoker透... 记者发布!fishpoker透视底牌(辅助挂)切实是真的有挂(有挂方法辅助教程)1. 选牌创建新账号...
查到实测!aapoker脚本怎... 查到实测!aapoker脚本怎么用(辅助挂)果然是有挂(揭秘有挂辅助技巧)1. 选牌创建新账号,点击...
传递经验!wepoker轻量版... 传递经验!wepoker轻量版透视系统(辅助挂)其实存在有挂(有挂功能辅助软件)1、下载好正确养号方...
查到实测!红龙poker辅助器... 查到实测!红龙poker辅助器免费观看(辅助挂)都是是有挂(确实有挂辅助攻略)1、下载好脚本下载之后...
重大消息!wepoker怎么设... 重大消息!wepoker怎么设置房间(辅助挂)都是存在有挂(有挂秘笈辅助教程)1、不需要AI权限,帮...
必看攻略!wepoker私人局... 必看攻略!wepoker私人局辅助挂(辅助挂)确实有挂(有挂实锤辅助器)1、公共底牌简单,透视插件操...
大神推荐!wepoker破解游... 大神推荐!wepoker破解游戏盒子(辅助挂)本来真的有挂(有挂方法辅助方法)1、进入到是否有挂之后...
查到实测辅助!wpk透视辅助方... 查到实测辅助!wpk透视辅助方法(辅助挂)一直有挂(有挂分享辅助工具)1、很好的工具软件,可以解锁游...
实测发现!wepoker有什么... 实测发现!wepoker有什么规律(辅助挂)其实真的有挂(了解有挂辅助器)进入游戏-大厅左侧-新手福...