0
我在Android上使用Google Vision进行人脸检测。目前,我的代码:如何从前置摄像头正确翻译检测到的脸部坐标
public void onPreviewFrame(byte[] data, Camera camera) {
// creating Google Vision frame from a camera frame for face recognition
com.google.android.gms.vision.Frame frame = new com.google.android.gms.vision.Frame.Builder()
.setImageData(ByteBuffer.wrap(data), previewWidth,
previewHeight, ImageFormat.NV21)
.setId(frameId++)
.setRotation(com.google.android.gms.vision.Frame.ROTATION_270)
.setTimestampMillis(lastTimestamp).build();
// recognize the face in the frame
SparseArray<Face> faces = detector.detect(frame);
// wrong coordinates
float x = faces.valueAt(0).getPosition().x;
float y = faces.valueAt(0).getPosition().y;
}
的问题是,x
和y
是不正确的,甚至有时负。我知道为了得到正确的坐标,它应该以某种方式旋转,但究竟是如何?
http://stackoverflow.com/questions/39281320/how-to-detect-the-corners-center-xy-coordinates-using-googles- face-api这是有道理的。 – bvk256