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.

Set up your Environment

Follow the steps mentioned in the Getting Started guide to set up the Camera SDK in your project.
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
1
TofCameraManager tofCameraManager = new TofCameraManager(this, new TofCameraManager.OnTofImageAvailableListener() {
2
@Override
3
public void onTofBitmapAvailable(Bitmap ir, Bitmap depth, ByteBuffer depthBuffer, long timestamp) {
4
Matrix matrix = new Matrix();
5
matrix.preScale(1.0f, -1.0f);
6
Bitmap irBitmap = Bitmap.createBitmap(ir.copy(Bitmap.Config.RGB_565, false), 0, 0, ir.getWidth(), ir.getHeight(), matrix, true);
7
8
matrix.preScale(1.0f, -1.0f);
9
Bitmap depthBitmap = Bitmap.createBitmap(depth.copy(Bitmap.Config.RGB_565, false), 0, 0, depth.getWidth() - 8, depth.getHeight() - 8, matrix, true);
10
11
mDepthBuffer = depthBuffer;
12
handler.sendEmptyMessage(sTofUpdate);
13
}
14
});
Copied!

Opening the ToF Camera

To open the ToF camera, you can call openCamera() using the TofCameraManager
Java
1
tofCameraManager.openCamera();
Copied!

Closing the ToF Camera

To close the ToF camera, you can call closeCamera() on the TofCameraManager
Java
1
tofCameraManager.closeCamera();
Copied!
Last modified 9mo ago