简体   繁体   English

如何将归一化设备坐标转换为 Android 上 canvas 的像素坐标?

[英]How to convert Normalized Device Coordinates to pixel coordinates for canvas on Android?

I'm using Mediapipe framework to detect hands and i want to display own image on finger's landmark.我正在使用 Mediapipe 框架来检测手,我想在手指的地标上显示自己的图像。 The library provides landmarks in form of "Normalized Device Coordinate"(0...1).该库以“标准化设备坐标”(0...1) 的形式提供地标。 So i need to convert these coordinates to device(phone) coordinates in form of pixels.所以我需要将这些坐标转换为像素形式的设备(电话)坐标。

Tried试过了

  int  width= device_width;
  int  height= device_height;

        float  x = (float) ( handLandmarkList.get(HandLandmark.RING_FINGER_PIP).getX() * width );
        float  y = (float) (  handLandmarkList.get(HandLandmark.RING_FINGER_PIP).getY()*height );

x and y coordinates are not showing correct on device. x 和 y 坐标在设备上显示不正确。

You need to multiply NDCs by your render target dimensions.您需要将 NDC 乘以渲染目标尺寸。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM