Fix app crash when no image is read in camera block.
This commit is contained in:
parent
d07d73b56a
commit
13fa966557
@ -69,6 +69,8 @@ public class CameraStreamer implements Part {
|
||||
private ImageReader imageReader = null;
|
||||
private HandlerThread _thread = null;
|
||||
private Handler _handler = null;
|
||||
private static final int CAPTURE_IMAGE_WIDTH = 256;
|
||||
private static final int CAPTURE_IMAGE_HEIGHT = 256;
|
||||
|
||||
private CameraStreamer(String id, PartGrid partGrid, int left, int top, int right, int bottom) {
|
||||
_id = id;
|
||||
@ -335,10 +337,14 @@ public class CameraStreamer implements Part {
|
||||
}
|
||||
}
|
||||
|
||||
this.imageReader = ImageReader.newInstance(100, 100, ImageFormat.JPEG, 30);
|
||||
this.imageReader = ImageReader.newInstance(CAPTURE_IMAGE_WIDTH, CAPTURE_IMAGE_HEIGHT, ImageFormat.JPEG, 30);
|
||||
this.imageReader.setOnImageAvailableListener((ImageReader.OnImageAvailableListener) newImageReader -> {
|
||||
Image latestImage = newImageReader.acquireLatestImage();
|
||||
|
||||
if (latestImage == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
CameraStreamer.this.onNewImage(latestImage);
|
||||
latestImage.close();
|
||||
}, new Handler());
|
||||
|
Loading…
Reference in New Issue
Block a user