gpt4 book ai didi

face-recognition - 是否可以使用 Google 的 Vision API 或 Amazon 的 Rekognition 获取对象的数量?

转载 作者:行者123 更新时间:2023-12-04 07:23:02 26 4
gpt4 key购买 nike

我一直在探索使用 AWS Rekognition 和 Google 的 Vision 来获取图像/视频中对象的数量,但一直找不到出路。虽然在 Google's Vision网站上,他们确实有一个“图像洞察”部分,其中似乎已经捕获了数量。

附件是来自该 URL 的快照。 Vision

有人可以建议是否可以使用 Google 的 Vision 或任何其他可以帮助获取图像中对象数量的 API。谢谢

编辑:

例如 - 对于下面显示的图像,返回的计数应该是 10 辆汽车。正如托里杨在他的回答中所建议的那样,标签注释计数可以给出所需的数量,但似乎并非如此,因为标签注释的计数是18。返回的对象有点像这样。
"labelAnnotations": [
{
"mid": "/m/0k4j",
"description": "car",
"score": 0.98658943,
"topicality": 0.98658943
},
{
"mid": "/m/012f08",
"description": "motor vehicle",
"score": 0.9631113,
"topicality": 0.9631113
},
{
"mid": "/m/07yv9",
"description": "vehicle",
"score": 0.9223521,
"topicality": 0.9223521
},
{
"mid": "/m/01w71f",
"description": "personal luxury car",
"score": 0.8976857,
"topicality": 0.8976857
},
{
"mid": "/m/068mqj",
"description": "automotive design",
"score": 0.8736646,
"topicality": 0.8736646
},
{
"mid": "/m/012mq4",
"description": "sports car",
"score": 0.8418799,
"topicality": 0.8418799
},
{
"mid": "/m/01lcwm",
"description": "luxury vehicle",
"score": 0.7761523,
"topicality": 0.7761523
},
{
"mid": "/m/06j11d",
"description": "performance car",
"score": 0.76816446,
"topicality": 0.76816446
},
{
"mid": "/m/03vnt4",
"description": "mid size car",
"score": 0.75732976,
"topicality": 0.75732976
},
{
"mid": "/m/03vntj",
"description": "full size car",
"score": 0.6855145,
"topicality": 0.6855145
},
{
"mid": "/m/0h8ls87",
"description": "automotive exterior",
"score": 0.66056395,
"topicality": 0.66056395
},
{
"mid": "/m/014f__",
"description": "supercar",
"score": 0.592226,
"topicality": 0.592226
},
{
"mid": "/m/02swz_",
"description": "compact car",
"score": 0.5807265,
"topicality": 0.5807265
},
{
"mid": "/m/0h6dlrc",
"description": "bmw",
"score": 0.5801241,
"topicality": 0.5801241
},
{
"mid": "/m/01h80k",
"description": "muscle car",
"score": 0.55745816,
"topicality": 0.55745816
},
{
"mid": "/m/021mp2",
"description": "sedan",
"score": 0.5522745,
"topicality": 0.5522745
},
{
"mid": "/m/0369ss",
"description": "city car",
"score": 0.52938646,
"topicality": 0.52938646
},
{
"mid": "/m/01d1dj",
"description": "coupé",
"score": 0.50642073,
"topicality": 0.50642073
}
]

image

最佳答案

在 Google Cloud Vision 上,您应该能够获得计数。例如,如果你想用 Python 计算人脸的数量,你可以这样做:

def detect_faces(path):
"""Detects faces in an image."""
client = vision.ImageAnnotatorClient()

with io.open(path, 'rb') as image_file:
content = image_file.read()

image = vision.types.Image(content=content)

response = client.face_detection(image=image)
faces = response.face_annotations
print(len(faces))

注意最后一行。在每种支持的语言中,您应该能够计算结果。

以下是您如何获得每个标签的计数。
def detect_labels(path):
"""Detects labels in the file."""
client = vision.ImageAnnotatorClient()

with io.open(path, 'rb') as image_file:
content = image_file.read()

image = vision.types.Image(content=content)

response = client.label_detection(image=image)
labels = response.label_annotations

count = {}
for label in labels:
if label in count:
count[label] += 1
else:
count[label] = 1

在第二个示例中,count 将是每个标签的字典以及它在图像中出现的次数。

关于face-recognition - 是否可以使用 Google 的 Vision API 或 Amazon 的 Rekognition 获取对象的数量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50815200/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com