LibTOF API
Mars Main API Reference (For Windows&Linux)
LibTof.a API Functions
Controls device connection and shutdown. Get device depth data, raw data, and set device-specific parameters
1. LibTOF_Connect
Routine
int LIBTOF_CALL LibTOF_Connect();
Description
Connect and initialize the TOF camera.
Return value
LTOF_SUCCESS – success
other – error code.
2. LibTOF_DisConnect
Routine
int LIBTOF_CALL LibTOF_DisConnect ();
Description
Disconnect the TOF camera
Return value
LTOF_SUCCESS – success;
other – error code.
3. LibTOF_RcvDepthFrame2
Routine
int LIBTOF_CALL LibTOF_RcvDepthFrame2(FrameData_t* frame_data, FrameDataRgb_t* frame_data_Rgb, int width, int height,IMU_data_t* IMU_data=NULL);
Description
Get the depth data for Mars4 or latest mars3 equipment(from 2017/05) When the camera mode(SET_CAMERA_MODE =2) is set to grayscale, frame_data_Rgb is gray data (16bits ,the valid data is 12bit)
Parameters:
- frame_data [output] Depth data structure pointer
- frame_data_Rgb
- *[output] The RGB parameter of the depth point corresponds to the frame_data one by one
- width [input] image width
- height [input] image height
- IMU_data [output] Get IMU date
Return value
LTOF_SUCCESS – success;
other – error code.
4. LibTOF_RcvVideoFrame
Routine
int LibTOF_RcvVideoFrame(short* video_data,unsigned int frame_len);
Description
Get the raw image(YUYV)
Parameters:
video_data [output] Video data pointer
frame_len [input] Data lens(2688*1520*2)
Return value
LTOF_SUCCESS – success;
other – error code.
5. LibTOF_GetTemperture
Routine
int LIBTOF_CALL LibTOF_GetTemperture(float* Cpu_t, float* Sensor_t);
Description
Get CPU and sensor temperature
Parameters:
- Cpu_t [output] CPU temperature
- Sensor_t [output] Sensor temperature
6. LibTOF_PseudoColor
Routine
int LIBTOF_CALL LibTOF_PseudoColor(FrameData_t* buffer, int width, int height, unsigned char *Colorbuffer, float depth_min, float depth_max);
Description
Convert the depth data to pseudo color data
Parameters:
- buffer [input] Pointer to the depth data, cannot be NULL.
- width [input] Width of the image
- height [input] Height of the image
- Colorbuffer [output] Pointer to the data of pseudo color
- depth_min [input] The minimum depth
- depth_max [input] The maximum depth
Return value** 1
7. LibTOF_SetExpourseMode
Routine
int LIBTOF_CALL LibTOF_SetExpourseMode(ExpourseMode_e ExpMode);
Description
Set TOF camera Expourse Mode.
Parameters:
- ExpMode [input] Manual or Auto.
Return value
LTOF_SUCCESS – success;
other – error code.
8. LibTOF_SetSceneMode
Routine
int LIBTOF_CALL LibTOF_SetSceneMode(SceneMode_e SceneMode);
Description
Set TOF camera Scene Mode.
Parameters:
- SceneMode [input] 30cm 75cm. See SceneMode_e
Return value
LTOF_SUCCESS – success;
other – error code.
9. LibTOF_SetUseCase
Routine
int LIBTOF_CALL LibTOF_SetUseCase(CameraUseCase_e UseCase);
Description
Set up the camera exposure frame rate pattern.
Parameters:
- UseCase [input] See CameraUseCase_e
Return value
LTOF_SUCCESS – success;
other – error code.
10. LibTOF_Setparam
Routine
int LIBTOF_CALL LibTOF_Setparam(CameraControlCommand_e Cmd, int value);
Description
Send command to TOF camera.
Parameters:
- Cmd [input] CamerControlCommand, See 15.3 enumeration defines.
- Value [input] The command parameter values.
Return value
LTOF_SUCCESS – success;
other – error code.
11. LibTOF_GetDeviceInfo
Routine
int LIBTOF_CALL LibTOF_GetDeviceInfo(DeviceInfo_t *deviceinfo);
Description
Get device information.
Parameters:
- deviceinfo [output] Device information.
Return value
LTOF_SUCCESS – success;
other – error code.
12. LibTOF_UpdataFalsh
Routine
int LIBTOF_CALL LibTOF_UpdataFalsh();
Description
Send the upgrade command.
Return value
LTOF_SUCCESS – success;
other – error code.
13. LibTOF_RgbdEnSet
Routine
int LibTOF_RgbdEnSet(int RgbdEn);
Description
Rgbd scale switch Settings
Parameters:
- RgbdEn [input] 1 open rgbd; 0 close rgbd
Return value
LTOF_SUCCESS – success;
other – error code.
14. LibTOF_SetGrayExp
Routine
int LibTOF_SetGrayExp(int value);
Description
Grayscale exposure time Settings.
Parameters:
- value [input] Grayscale exposure
Return value
LTOF_SUCCESS – success;
other – error code.
Enums and structures
1. FrameData_t
typedef struct tag_FRAMEDATA {
float x;
float y;
float z;
} FrameData_t;
Description
Depth data structure
Members:
- x X coordinate
- y Y coordinate
- z Z coordinate
2. FrameDataRgb_t
typedef struct tag_FRAMEDATA_RGB
{
char r;
char g;
char b;
}FrameDataRgb_t;
Description
Depth data structure
Members:
r R value
g G value
* b B value
3. CameraControlCommand_e
typedef enum CameraControlCommand
{
/** Set the working mode of TOF camera, 0:Mono-Frequency,1 Multi-Frequencies*/
SET_CAMERA_MODE = 17, /** Command: Setting the frame rate, range: 1-30 */
SET_CAMERA_FPS = 18, /** Command: Set the exposure time, range: 1-2000 */
SET_CAMERA_EXP = 19,
}CameraControlCommand_e;
Description
Camera control commands for LibTOF_Setparam interface function
4. DeviceInfo_t
typedef struct tag_DeviceInfo {
uint32_t DeviceVersion;
uint32_t DeviceType;
uint16_t DepthFrameWidth;
uint16_t DepthFrameHeight;
uint16_t BitsPerPoint;
uint16_t VisibleFrameWidth;
uint16_t VisibleFrameHeight;
uint16_t BitsPerPixel;
uint16_t BlockSizeIn;
uint16_t BlockSizeOut;
char TofAlgVersion[20];
char DeviceId[19];
uint8_t RgbdEn;
}DeviceInfo_t;
Description
Device information
Members:
- DeviceVersion N/A
- DeviceType G value
- DepthFrameWidth Depth data width
- DepthFrameHeight Depth data height
- BitsPerPoint The number of bits per pixel
- VisibleFrameWidth VisibleFrame width
- VisibleFrameHeight VisibleFrame height
- BitsPerPixel The number of bits per pixel
- BlockSizeIn Input block size
- BlockSizeOut Output block size
- TofAlgVersion TOF device Information, device name, device version number
5. SceneMode_e
typedef enum SceneMode
{
Scene_No = 0,
Scene_30cm = 1,
Scene_75cm = 2,
}SceneMode_e;
Description
Camer Scene mode
Members: Scene_No No Scene mode Scene_30cm The camera is 30 centimeters away from the subject * Scene_75cm The camera is 75 centimeters away from the subject
6. S_MetaData;
typedef struct{
int version[3]; /*reserve byte*/
int cameraNum; /*camera number*/
int width; /*image width*/
int height; /*image height*/
int bpp; /*bpp bits per pixel*/
int dataFormat; /*data format*/
int frameCount;
int getFrameTime;
int sendFrameTime;
int headerLength;
}S_MetaData;
Description
Frame information structure
Members:
- version Firmware version
- cameraNum Camera channel number
- width image width
- height image height
- bpp Each pixel occupies a number of bytes
- dataFormat The data format
- frameCount Frame number
- getFrameTime Acquisition time stamp
- sendFrameTime Send the timestamp
- headerLength The length of head
7. ErrorCode_t
typedef enum tag_ErrorCode_TOF
{
/** Success (no error) */
LTOF_SUCCESS = 0,
/** Input/output error */
LTOF_ERROR_IO = -1,
/** Invalid parameter */
LTOF_ERROR_INVALID\_PARAM = -2,
/** Access denied (insufficient permissions) */
LTOF_ERROR_ACCESS = -3,
/** No such device (it may have been disconnected) */
LTOF_ERROR_NO\_DEVICE = -4,
/** Operation timed out */
LTOF_ERROR_TIMEOUT = -5,
/** Overflow */
LTOF_ERROR_OVERFLOW = -6,
/** Insufficient memory */
LTOF_ERROR_NO_MEM = -7,
/** Operation not supported or unimplemented on this platform */
LTOF_ERROR_NOT_SUPPORTED = -8,
/** usb write error*/
LTOF_ERROR_USB_WRITE = -9,
/**usb read error*/
LTOF_ERROR_USB_READ = -10,
/** Other error */
LTOF_ERROR_OTHER = -99,
} TOF_ErrorCode_t;
Description
Error codes