Tôi đang cố gắng để có được hình ảnh khung để xử lý trong khi sử dụng Android mới phát hiện khuôn mặt điện thoại di động tầm nhìn api.Làm thế nào để tạo Bitmap từ hình ảnh đệm byte grayscaled?
Vì vậy, tôi đã tạo Custom Detector để nhận Frame và cố gắng gọi phương thức getBitmap() nhưng nó là null vì vậy tôi đã truy cập dữ liệu màu xám của khung. Có cách nào để tạo bitmap từ nó hoặc lớp chủ sở hữu hình ảnh tương tự?
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);
}}
Khung không có dữ liệu bitmap vì nó đến trực tiếp từ máy ảnh. Định dạng hình ảnh từ máy ảnh là NV21: http://developer.android.com/reference/android/graphics/ImageFormat.html#NV21 – pm0733464