ToF SDK API Guide¶
Software Stack of Arducam ToF Camera¶
ArduCam TOF SDK is a dynamic link library written in C++, There are three classes, Camera, Frame, and Sensor. Camera is responsible for managing camera image acquisition calculation, Frame is responsible for memory management of camera data storage, and Sensor is the specific implementation of calling the camera. It is called as a member object in the Camera class, and users generally do not touch it.
Demos with Arducam ToF camera.
Driver Installation¶
Please refer to this guide to install drivers and dependencies.
SDK Installation¶
cd Release/
mkdir build
cd build
cmake ..
sudo make install
sudo ldconfig
log
Examples with C¶
SDK workflow
- create a camera instance.
- start the camera.
- request a frame.
- get frame data
- release frame space
- stop the camera
Demo
ArducamDepthCamera tof = createArducamDepthCamera();
FrameBuffer frame;
if (initialize(tof,DEPTH_TYPE))
exit(-1);
if (start(tof))
exit(-1);
FrameFormat format;
if ((frame = requestFrame(tof,200)) != 0x00){
getFormat(frame,DEPTH_FRAME,format);
}
releaseFrame(tof,frame);
uint8_t *preview_ptr = malloc(format.width*format.height*sizeof(uint8_t)) ;
float* depth_ptr = 0;
int16_t *raw_ptr = 0;
float *amplitude_ptr = 0;
for (;;)
{
if ((frame = requestFrame(tof,200)) != 0x00)
{
depth_ptr = (float*)getDepthData(frame);
amplitude_ptr = (float*)getAmplitudeData(frame);
getPreview(preview_ptr,depth_ptr,amplitude_ptr);
releaseFrame(tof,frame);
}
}
if (stop(tof))
exit(-1);
return 0;
Results
Examples with C++¶
SDK workflow
- create a camera instance.
- initialize camera instance.
- start the camera.
- request a frame.
- get frame data
- release frame space
- stop the camera
Demo
ArduCam::ArduCamTOFCamera tof;
ArduCam::ArduCamTOFFrame *frame;
if (tof.initialize(ArduCam::RAW_TYPE))
exit(-1);
if (tof.start())
exit(-1);
ArduCam::FrameFormat tofFormat = tof.getFrameFormats();
int16_t *raw_ptr;
for (;;)
{
frame = tof.requestFrame(200);
if (frame != nullptr)
{
raw_ptr = (int16_t *)frame->getFrameData(ArduCam::RAW_FRAME);
cv::Mat raw_frame(720, 240, CV_16S, raw_ptr);
raw_frame.convertTo(raw_frame,CV_32F);
cv::imshow("preview", raw_frame);
if (cv::waitKey(1) == 27)
break;
display_fps();
}
tof.releaseFrame(frame);
}
if (tof.stop())
exit(-1);
return 0;
Results
Example with Python¶
SDK workflow
- create a camera instance.
- initialize camera instance.
- start the camera.
- request a frame.
- get frame data
- release frame space
- stop the camera
Demo
cam = ac.ArducamCamera()
cam.initialize(ac.TOFOutput.RAW)
cam.start()
while True:
frame = cam.requestFrame(200)
buf = frame.getRawData()
cam.releaseFrame(frame)
cv2.imshow("window", buf.astype(np.float32))
key = cv2.waitKey(1)
if key == ord("q"):
cam.stop()
sys.exit(0)
Results
API References for C¶
You can find C references here.
API References for C++¶
You can find C++ references here.





