1 package com.introlab.rtabmap;
4 import android.graphics.ImageFormat;
5 import android.media.Image;
6 import android.media.ImageReader;
7 import android.os.Handler;
8 import android.os.HandlerThread;
9 import android.util.Log;
11 import java.nio.ByteBuffer;
35 ImageReader.newInstance(
40 this.imageReader.setOnImageAvailableListener(
this, this.backgroundHandler);
46 Image image = imageReader.acquireLatestImage();
48 Log.w(
"RTABMapActivity",
"onImageAvailable: Skipping null image.");
52 if(image.getFormat() == ImageFormat.DEPTH16){
53 this.timestamp = image.getTimestamp();
54 depth16_raw = image.getPlanes()[0].getBuffer().asReadOnlyBuffer();
59 Log.w(
"RTABMapActivity",
"onImageAvailable: depth image not in DEPTH16 format, skipping image");
67 this.backgroundThread =
new HandlerThread(
"DepthDecoderThread");
68 this.backgroundThread.start();
69 this.backgroundHandler =
new Handler(backgroundThread.getLooper());
74 if (this.backgroundThread != null) {
75 this.backgroundThread.quitSafely();
77 this.backgroundThread.join();
78 this.backgroundThread = null;
79 this.backgroundHandler = null;
80 }
catch (InterruptedException
e) {
81 Log.e(
"RTABMapActivity",
"Interrupted while trying to join depth background handler thread", e);
void stopBackgroundThread()
HandlerThread backgroundThread
GLM_FUNC_DECL genType e()
void startBackgroundThread()
void onImageAvailable(ImageReader imageReader)
void createImageReader(int width, int height)
Handler backgroundHandler