gpt4 book ai didi

javascript - AWS重新识别x,y公式

转载 作者:行者123 更新时间:2023-12-03 04:13:50 27 4
gpt4 key购买 nike

我正在尝试使用 AWS rekognition 查找照片中人物 Nose 的 x,y 坐标,我使用 javascript SDK,并以图片大小的比率形式返回值。文档中已经明确说明了这一点,我对此没有任何问题。

我追求的是从整个图像而不是边界框的 Angular 找到 Nose “地标”的精确 x,y 的公式。下面是我的 rekognition 输出。

{ FaceDetails: 
[ { BoundingBox:
{ Width: 0.6399999856948853,
Height: 0.47999998927116394,
Left: 0.1644444465637207,
Top: 0.17666666209697723 },
Landmarks:
[ { Type: 'eyeLeft',
X: 0.36238425970077515,
Y: 0.3900916874408722 },
{ Type: 'eyeRight', X: 0.5580493807792664, Y: 0.362303763628006 },
{ Type: 'nose', X: 0.4164798855781555, Y: 0.4511926472187042 },
{ Type: 'mouthLeft',
X: 0.42259901762008667,
Y: 0.5591621994972229 },
{ Type: 'mouthRight',
X: 0.5580134391784668,
Y: 0.5394133925437927 } ],
Pose:
{ Roll: -9.781778335571289,
Yaw: -20.029239654541016,
Pitch: 10.893087387084961 },
Quality: { Brightness: 59.32780456542969, Sharpness: 99.9980239868164 },
Confidence: 99.99403381347656 } ] }

我有一张 2576x1932 的图像,是否可以在此处应用一些公式来给出图片中 Nose 的 x,y 值。目前它给出了边界框内 Nose 的x,y(我认为)。我的数学能力还达不到这个水平。

来自文档:

边界框:

The top and left values returned are ratios of the overall image size. For example, if the input image is 700x200 pixels, and the top-left coordinate of the bounding box is 350x50 pixels, the API returns a left value of 0.5 (350/700) and a top value of 0.25 (50/200).

地标:

x-coordinate from the top left of the landmark expressed as the ration of the width of the image. For example, if the images is 700x200 and the x-coordinate of the landmark is at 350 pixels, this value is 0.5.

最佳答案

Rekognition 返回的 X/Y 值只是图像宽度/高度的百分比。根据 Rekognition API 文档,地标位置是相对于整个图像的,而不是相对于边界框的。

因此,您所要做的就是将图像的宽度乘以地标的 X 值即可得到该地标的 X 位置(然后将图像的高度乘以地标的 Y 位置即可得到)地标的 Y 位置(以像素为单位)。

Rekognition 这样做的原因是,无论图像的像素大小如何, Nose 的位置(例如)都是相同的。在上面的示例中, Nose 位于:

 { Type: 'nose', X: 0.4164798855781555, Y: 0.4511926472187042 }, 

这只是意味着它位于从左边框开始的图像宽度的 41.6% 处,以及从上边框处开始的向下图像高度的 45.1% 处。将这些百分比乘以实际宽度和高度即可获得像素坐标。

参见: http://docs.aws.amazon.com/rekognition/latest/dg/API_Landmark.html

关于javascript - AWS重新识别x,y公式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44225909/

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