我正在尝试使用新的Android人脸检测移动视觉API获取框架图像以进行处理。
因此,我创建了自定义检测器来获取框架并尝试调用getBitmap()方法,但它为null,因此我访问了框架的灰度数据。是否有一种方法可以从中创建位图或类似的图像持有者类?
public class CustomFaceDetector extends Detector<Face> {
private Detector<Face> mDelegate;
public CustomFaceDetector(Detector<Face> delegate) {
mDelegate = delegate;
}
public SparseArray<Face> detect(Frame frame) {
ByteBuffer byteBuffer = frame.getGrayscaleImageData();
byte[] bytes = byteBuffer.array();
int w = frame.getMetadata().getWidth();
int h = frame.getMetadata().getHeight();
// Byte array to Bitmap here
return mDelegate.detect(frame);
}
public boolean isOperational() {
return mDelegate.isOperational();
}
public boolean setFocus(int id) {
return mDelegate.setFocus(id);
}}