代码之家  ›  专栏  ›  技术社区  ›  Pro-Web

dynamodb重新识别的条件。通过图像功能搜索面

  •  0
  • Pro-Web  · 技术社区  · 6 年前

    嗨,我正在用这样的代码获取数据库数据

    response = rekognition.search_faces_by_image(
                            CollectionId='athlete_collection',
                            Image={'Bytes': image_crop_binary}
                        )
    

    我有一个专栏叫 event 在里面 athlete_collection 所以我想把一个条件放在event='newevent'的

    1 回复  |  直到 6 年前
        1
  •  0
  •   Mausam Sharma    6 年前

    如果并且仅当您在为集合中的这些面编制索引时将这些详细信息存储在数据库中时(如果在您的用例中) 存储在数据库中,因此在从数据库中检索与从中获取的结果相对应的结果时,必须筛选数据。

    response = rekognition.search_faces_by_image(
        CollectionId='collection_name',
        Image={'Bytes':image_crop_binary}
        )
    
    if len(response['FaceMatches']) > 0:
        # Return results
        for match in response['FaceMatches']:
    
            face = dynamodb.get_item(
            TableName='table_name',               
            Key={'RekognitionId': {'S': match['Face']['FaceId']}}
            )
    
    
        if 'Item' in face:
            event = face['Item']['event_name']['S']
            full = face['Item']['full_name']['S']
    
        if(event=='newevent'):
            #your code goes here , i.e what you want to do if event=="newevent"