C++ API Reference
The epc::TOFCam API provides a high-level interface for controlling the EPC670
Time-of-Flight camera module and accessing captured frames.
Overview
The API is split into two main classes:
epc::TOFCam— camera control: open/close, stream management, control parametersepc::TOFFrame— frame data access: DCS, amplitude, distance, phase and metadata
A frame is always owned by a std::unique_ptr<TOFFrame> and is valid until the pointer
goes out of scope.
Quick Start
1#include <epc/tofcam.hpp>
2
3int main() {
4 epc::TOFCam cam(epc::TOFSensor::epc670);
5 cam.open();
6 cam.setControl(epc::ControlID::MODULATION_FREQ_HZ, 10000000);
7 cam.setControl(epc::ControlID::EXPOSURE_US, 2000);
8 cam.startStream();
9
10 std::unique_ptr<epc::TOFFrame> frame;
11 cam.captureFrame(frame);
12
13 const uint16_t *distance = frame->get<epc::DistanceFrame>();
14 const uint16_t *amplitude = frame->get<epc::AmplitudeFrame>();
15 const uint16_t *dcs0 = frame->get<epc::DCSFrame>(0);
16
17 // Your processing code here...
18
19 cam.stopStream();
20 cam.close();
21}
Frame Types
Use the following structs with TOFFrame::get<T>() to access typed frame data:
Tag struct |
Data type |
Unit |
Description |
|---|---|---|---|
|
uint16_t |
LSB |
Raw DCS images |
|
uint16_t |
LSB |
Amplitude image |
|
uint16_t |
mm |
Computed distance image |
|
float |
radian |
Phase image |
API Documentation
-
class TOFCam
Interface for controlling a Time-of-Flight camera.
Public Functions
-
TOFCam(TOFSensor sensor = TOFSensor::autodetect)
Constructor for TOFCam.
- Parameters:
sensor – The specific TOF sensor model to interface with. If the sensor is set to TOFSensor::autodetect, the TOFCam will attempt to auto-detect the sensor model.
-
~TOFCam()
-
int open()
Open the connection to the camera.
- Returns:
int 0 on success, non-zero error code on failure.
-
int close()
Close the connection to the camera.
- Returns:
int 0 on success, non-zero error code on failure.
-
int startStream()
Start the video stream.
-
int stopStream()
Stop the video stream.
-
int captureFrame(std::unique_ptr<TOFFrame> &frame)
Capture next frame. If streaming is active, this function retrieves the latest frame from the stream. If streaming is not active, it triggers a single frame capture.
- Parameters:
frame – Reference to a unique_ptr where the captured frame will be stored.
- Returns:
int 0 on success, non-zero error code on failure.
-
int setControl(ControlID control, int value)
Set a control parameter for the camera.
- Parameters:
control – The control parameter identifier.
value – The value to set.
- Returns:
int 0 on success, non-zero error code on failure.
-
inline int setControl(ControlID control, AcquisitionMode mode)
-
int getControl(ControlID control, int &value)
Get the current value of a control parameter.
- Parameters:
control – The control parameter identifier.
value – Reference to an integer where the value will be stored.
- Returns:
int 0 on success, non-zero error code on failure.
-
bool isStreaming()
Check if the camera is currently streaming.
- Returns:
bool True if streaming is active, false otherwise.
-
TOFCam(TOFSensor sensor = TOFSensor::autodetect)
-
class TOFFrame
Represents a single Time-of-Flight frame.
This class encapsulates the data captured by the TOF camera for a single frame, providing accessors for different data types like DCS, Amplitude, and Distance.
Public Functions
-
~TOFFrame()
-
template<typename T>
inline const T::Type *get(uint8_t index = 0) const Get a pointer to the data of a specific frame type.
- Template Parameters:
T – The frame identifier [DCSFrame, AmplitudeFrame, DistanceFrame, PhaseFrame, GrayscaleFrame].
- Parameters:
index – Index of the DCS frame to retrieve (only applicable for DCSFrame, ignored for others).
- Returns:
const typename T::Type* Pointer to the frame data.
-
TOFMetadata getMetadata() const
Get the metadata for this frame.
- Returns:
TOFMetadata The metadata structure.
-
inline uint16_t getWidth() const
Get the width of the frame.
-
inline uint16_t getHeight() const
Get the height of the frame.
-
~TOFFrame()
-
struct TOFMetadata
Metadata associated with a TOF frame.
-
enum class epc::FrameType : uint8_t
Frame data type selector. Used to request specific image buffers from a epc::TOFFrame object.
Values:
-
enumerator DCS
DCS frames (raw sensor captures)
-
enumerator AMPLITUDE
Amplitude image.
-
enumerator DISTANCE
Distance image.
-
enumerator PHASE
Phase image.
-
enumerator GRAYSCALE
Grayscale image.
-
enumerator DCS
Control Parameters
The following control parameters can be passed to setControl() and getControl()
as the first argument:
-
enum class epc::ControlID : uint8_t
Camera control parameter identifiers used with TOFCam::setControl() and TOFCam::getControl().
Note
Sensor-level controls (gain, exposure, modulation frequency) persist across acquisition mode changes because they are maintained by the sensor hardware. All other controls reset to defaults when switching acquisition modes. Controls marked with “@note Persistent” explicitly retain their values.
Values:
-
enumerator GAIN
Analog gain setting in %
Note
Persistent across acquisition mode changes
-
enumerator ACQUISITION_MODE
Acquisition mode,
See also
Warning
Changing acquisition mode resets all pipeline and filter controls to defaults
-
enumerator MODULATION_FREQ_HZ
Modulation frequency in Hz
Note
Persistent across acquisition mode changes
-
enumerator TRIGGER_SHUTTER
Trigger a single shutter capture.
-
enumerator EXPOSURE_US
Integration time in microseconds (grayscale and non-HDR modes)
Note
Persistent across acquisition mode changes
-
enumerator HDR_INTEGRATION_TIME1_US
First HDR integration time in microseconds
Note
Persistent across acquisition mode changes
-
enumerator HDR_INTEGRATION_TIME2_US
Second HDR integration time in microseconds
Note
Persistent across acquisition mode changes
-
enumerator HDR_INTEGRATION_TIME3_US
Third HDR integration time in microseconds
Note
Persistent across acquisition mode changes
-
enumerator ENABLE_HDR_ROLLING_MODE
Enable HDR rolling mode (0 = off, 1 = on)
-
enumerator ENABLE_DCS_ROLLING_MODE
Enable DCS rolling mode (0 = off, 1 = on)
-
enumerator ENABLE_PHASE_OFFSET_COMPENSATION
Enable phase offset compensation (0 = off, 1 = on)
-
enumerator ENABLE_PHASE_ERROR_COMPENSATION
Enable DRNU phase error compensation (0 = off, 1 = on)
-
enumerator ENABLE_TEMPERATURE_COMPENSATION
Enable temperature compensation (0 = off, 1 = on)
-
enumerator ENABLE_GRAYSCALE_DSNU_COMPENSATION
Enable grayscale DSNU compensation (0 = off, 1 = on)
-
enumerator ENABLE_GRAYSCALE_PRNU_COMPENSATION
Enable grayscale PRNU compensation (0 = off, 1 = on)
-
enumerator LED_DELAY_STEP
LED delay in steps
Note
Persistent across acquisition mode changes
-
enumerator MIN_AMPLITUDE
Minimum amplitude threshold for valid distance measurement.
-
enumerator INTERFERENCE_DETECTION_ENABLE
Enable interference detection (0 = off, 1 = on)
-
enumerator INTERFERENCE_DETECTION_THRESHOLD
Amplitude threshold for interference detection.
-
enumerator INTERFERENCE_ENABLE_LATCHING
Latch to previous pixel value (0 = off, 1 = on)
-
enumerator AVERAGE_FILTER_ENABLE
Enable 3x3 average filter (0 = off, 1 = on)
-
enumerator MEDIAN_FILTER_ENABLE
Enable 3x3 median filter (0 = off, 1 = on)
-
enumerator TEMPORAL_FILTER_ENABLE
Enable temporal (exponential moving average) filter (0 = off, 1 = on)
-
enumerator TEMPORAL_FILTER_ALPHA
Temporal filter ratio percent (0 = more smooth, 100 = more responsive)
-
enumerator TEMPORAL_FILTER_THRESHOLD
Temporal filter jump detection threshold in millimeters.
-
enumerator KALMAN_FILTER_ENABLE
Enable per-pixel Kalman filter (0 = off, 1 = on)
-
enumerator KALMAN_FILTER_THRESHOLD
Kalman filter maximum uncertainty threshold in millimeters.
-
enumerator KALMAN_FILTER_PROCESS_NOISE
Kalman filter average pixel variance in millimeters squared.
-
enumerator EDGE_FILTER_ENABLE
Enable edge masking filter (0 = off, 1 = on)
-
enumerator EDGE_FILTER_THRESHOLD
Edge masking filter threshold in millimeters.
-
enumerator GAIN
Acquisition Modes
-
enum class epc::AcquisitionMode : uint8_t
Acquisition mode selection for TOFCam::setControl(ControlID::ACQUISITION_MODE, …).
Values:
-
enumerator DIST_AMP
Standard mode: computes distance and amplitude from 4 DCS frames.
-
enumerator GRAYSCALE
Grayscale mode: outputs a single grayscale image.
-
enumerator DIST_AMP_HDR
HDR mode: uses multiple integration times .
See also
HDR_INTEGRATION_TIME1_US, HDR_INTEGRATION_TIME2_US, HDR_INTEGRATION_TIME3_US controls
-
enumerator TEST_PATTERN
Internal test pattern output.
-
enumerator DCS4
Raw 4-DCS frame output.
-
enumerator DIST_AMP