Skip to content

Latest commit

 

History

History

first_frame

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

First frame Example

Overview

This example shows how to capture a frame using the SDK and Python.

NumPy library is needed for scientific computations. If NumPy library is not found you should install it using pip (a package manager for Python)

pip install numpy

Matplotlib library is needed for displaying the received frame. If Matplotlib library is not found you should install it using pip.

pip install matplotlib

Importing necessary modules

import aditofpython as tof
import numpy as np
import matplotlib.pyplot as plt

For creating the system object

system = tof.System()

Getting a camera from the system, configuring the mode and the frame type and initializing it

cameras = []
status = system.getCameraList(cameras)
print("system.getCameraList()", status)

camera1 = cameras[0]

modes = []
status = camera1.getAvailableModes(modes)
print("system.getAvailableModes()", status)
print(modes)

modes = []
status = camera1.getAvailableModes(modes)
print("system.getAvailableModes()", status)
print(modes)

status = camera1.initialize()
print("camera1.initialize()", status)

camDetails = tof.CameraDetails()
status = camera1.getDetails(camDetails)
print("system.getDetails()", status)
print("camera1 details:", "id:", camDetails.cameraId, "connection:", camDetails.connection)

status = camera1.setModeDetail(types[0])
print("camera1.setModeDetail()", status)

status = camera1.setMode(modes[0])
print("camera1.setMode()", status)

Getting a frame from the camera

frame = tof.Frame()
status = camera1.requestFrame(frame)
print("camera1.requestFrame()", status)

Printing the frame details

frameDataDetails = tof.FrameDataDetails()
status = frame.getDataDetails("depth", frameDataDetails)
print("frame.getDataDetails()", status)
print("depth frame details:", "width:", frameDataDetails.width, "height:", frameDataDetails.height, "type:", frameDataDetails.type)

Displaying the received frame

image = np.array(frame.getData("depth"), copy=False)

plt.figure()
plt.imshow(image, cmap = 'gray')
plt.colorbar()
plt.show()