Reputation: 1386
I'm working on an Android project where I have to repeatedly take photos and process them with a facial recognition API. I realize that I have to use camera2's methods (either setRepeatingRequest or setRepeatingBurst), but these methods only take a photo once every 5 seconds or so. I was wondering how I would change this to take a picture at least twice every second without lag. Is this even possible? If not, what would you recommend I use to do this?
Upvotes: 0
Views: 683
Reputation: 309
private final ImageReader.OnImageAvailableListener mOnImageAvailableListener
= new ImageReader.OnImageAvailableListener() {
@Override
public void onImageAvailable(ImageReader reader) {
try (Image image = reader.acquireNextImage()) {
Image.Plane[] planes = image.getPlanes();
if (planes.length > 0) {
ByteBuffer buffer = planes[0].getBuffer();
byte[] data = new byte[buffer.remaining()];
buffer.get(data);
mCallback.onPictureTaken(data);
}
}
}
};
This may help you,here is the use of Camera2
.
https://github.com/google/cameraview https://github.com/google/cameraview/blob/master/library/src/main/api21/com/google/android/cameraview/Camera2.java
Upvotes: 1