ToF Camera Manager
Connect to the ToF camera on the Lumepad
TofCameraManager
is a system service manager for detecting, characterizing, and connecting to ToF camera. Developers can register listeners to listen for ToF frames when they become available. Due to firmware and hardware limitations, the current output format is a Bitmap.Listening for ToF Frames
To listen for ToF frames, you need to instantiate an object of the ToFCameraManager and pass in the
Context
and TofCameraManager.OnTofImageAvailableListener
as parameters.Java
TofCameraManager tofCameraManager = new TofCameraManager(this, new TofCameraManager.OnTofImageAvailableListener() {
@Override
public void onTofBitmapAvailable(Bitmap ir, Bitmap depth, ByteBuffer depthBuffer, long timestamp) {
Matrix matrix = new Matrix();
matrix.preScale(1.0f, -1.0f);
Bitmap irBitmap = Bitmap.createBitmap(ir.copy(Bitmap.Config.RGB_565, false), 0, 0, ir.getWidth(), ir.getHeight(), matrix, true);
matrix.preScale(1.0f, -1.0f);
Bitmap depthBitmap = Bitmap.createBitmap(depth.copy(Bitmap.Config.RGB_565, false), 0, 0, depth.getWidth() - 8, depth.getHeight() - 8, matrix, true);
mDepthBuffer = depthBuffer;
handler.sendEmptyMessage(sTofUpdate);
}
});
To open the ToF camera, you can call
openCamera()
using the TofCameraManager
Java
tofCameraManager.openCamera();