新しい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);
}}
フレームは、カメラから直接送られるため、ビットマップデータはありません。カメラの画像フォーマットはNV21です:http://developer.android.com/reference/android/graphics/ImageFormat.html#NV21 – pm0733464