OrbbecSDK 2.10.6
OrbbecSDK: Software-Development-Kit for Orbbec 3D Cameras
Loading...
Searching...
No Matches
ob::Context Class Reference

#include <Context.hpp>

Classes

struct  DeviceChangedCallbackContext

Public Types

typedef std::function< void(std::shared_ptr< DeviceList > removedList, std::shared_ptr< DeviceList > addedList)> DeviceChangedCallback
 Type definition for the device changed callback function.
typedef std::function< void(OBLogSeverity severity, const char *logMsg)> LogCallback
 Type definition for the log output callback function.

Public Member Functions

 Context (const char *configPath="")
 Context constructor.
 ~Context () noexcept
 Context destructor.
void setTimestampClockType (OBClockType type) const
 Set the host-side timestamp clock type for the current context.
OBClockType getTimestampClockType () const
 Get the current host-side timestamp clock type for the context.
std::shared_ptr< DeviceList > queryDeviceList () const
 Queries the enumerated device list.
void enableNetDeviceEnumeration (bool enable) const
 enable or disable net device enumeration.
bool forceIp (const char *macAddress, const OBNetIpConfig &config)
 "Force" a static IP address configuration in a device identified by its MAC Address.
bool sendActionCommand (uint32_t deviceKey, uint32_t groupKey, uint32_t groupMask, const char *destIp="255.255.255.255", uint64_t scheduledTime=0)
 Send an Action Command to GVCP devices.
void setGvcpPortScheme (OBGvcpPortScheme scheme)
 Set the GVCP port scheme used for network device discovery and control.
OBGvcpPortScheme getGvcpPortScheme () const
 Get the current GVCP port scheme.
std::shared_ptr< Device > createNetDevice (const char *address, uint16_t port, OBDeviceAccessMode accessMode=OB_DEVICE_DEFAULT_ACCESS) const
 Creates a network device with the specified IP address and port.
void setDeviceChangedCallback (DeviceChangedCallback callback)
 Set the device plug-in callback function.
OBCallbackId registerDeviceChangedCallback (DeviceChangedCallback callback)
void unregisterDeviceChangedCallback (OBCallbackId id)
void enableDeviceClockSync (uint64_t repeatIntervalMsec) const
 Activates device clock synchronization to synchronize the clock of the host and all created devices (if supported).
void syncDeviceHardwarePPSTime (uint64_t hardwarePPSTime) const
 Activates synchronization time to all created devices (if supported).
void freeIdleMemory () const
 Frees idle memory from the internal frame memory pool.
void setUvcBackendType (OBUvcBackendType type) const
 For linux, there are two ways to enable the UVC backend: libuvc and v4l2. This function is used to set the backend type.

Static Public Member Functions

static void setLoggerSeverity (OBLogSeverity severity)
 Set the level of the global log, which affects both the log level output to the console, output to the file and output the user defined callback.
static void setLoggerToFile (OBLogSeverity severity, const char *directory)
 Set log output to a file.
static void setLoggerFileName (const std::string &fileName)
 Set the log file name for file output.
static void setLoggerToConsole (OBLogSeverity severity)
 Set log output to the console.
static void setLoggerToCallback (OBLogSeverity severity, LogCallback callback)
 Set the logger to callback.
static void logExternalMessage (OBLogSeverity severity, const std::string &module, const std::string &message, const std::string &file, const std::string &func, int line)
 Logs a message with severity, file, function, and line info.
static void setExtensionsDirectory (const char *directory)
 Set the extensions directory.

Detailed Description

Definition at line 29 of file Context.hpp.

Member Typedef Documentation

◆ DeviceChangedCallback

typedef std::function<void(std::shared_ptr<DeviceList> removedList, std::shared_ptr<DeviceList> addedList)> ob::Context::DeviceChangedCallback

Type definition for the device changed callback function.

Parameters
[in]removedListThe list of removed devices.
[in]addedListThe list of added devices.

Definition at line 37 of file Context.hpp.

◆ LogCallback

typedef std::function<void(OBLogSeverity severity, const char *logMsg)> ob::Context::LogCallback

Type definition for the log output callback function.

Parameters
[in]severityThe current callback log level.
[in]logMsgThe log message.

Definition at line 45 of file Context.hpp.

Constructor & Destructor Documentation

◆ Context()

ob::Context::Context ( const char * configPath = "")
inlineexplicit

Context constructor.

The Context class is a management class that describes the runtime of the SDK. It is responsible for applying and releasing resources for the SDK. The context has the ability to manage multiple devices, enumerate devices, monitor device callbacks, and enable functions such as multi-device synchronization.

Parameters
[in]configPathThe path to the configuration file. If the path is empty, the default configuration will be used.

Definition at line 72 of file Context.hpp.

◆ ~Context()

ob::Context::~Context ( )
inlinenoexcept

Context destructor.

Definition at line 81 of file Context.hpp.

Member Function Documentation

◆ setTimestampClockType()

void ob::Context::setTimestampClockType ( OBClockType type) const
inline

Set the host-side timestamp clock type for the current context.

Attention
All ob::Context instances share the same underlying SDK runtime and clock type.
Switching affects frame system and global timestamps; avoid switching during streaming.
It is recommended to synchronize device timestamps after switching.
Parameters
[in]typeThe clock type to use for host-side timestamps.

Definition at line 97 of file Context.hpp.

◆ getTimestampClockType()

OBClockType ob::Context::getTimestampClockType ( ) const
inline

Get the current host-side timestamp clock type for the context.

Returns
OBClockType The current clock type.

Definition at line 108 of file Context.hpp.

◆ queryDeviceList()

std::shared_ptr< DeviceList > ob::Context::queryDeviceList ( ) const
inline

Queries the enumerated device list.

Returns
std::shared_ptr<DeviceList> A pointer to the device list class.

Definition at line 120 of file Context.hpp.

◆ enableNetDeviceEnumeration()

void ob::Context::enableNetDeviceEnumeration ( bool enable) const
inline

enable or disable net device enumeration.

after enable, the net device will be discovered automatically and can be retrieved by queryDeviceList. The default state can be set in the configuration file.

Attention
Net device enumeration by gvcp protocol, if the device is not in the same subnet as the host, it will be discovered but cannot be connected.
Parameters
[in]enabletrue to enable, false to disable

Definition at line 136 of file Context.hpp.

◆ forceIp()

bool ob::Context::forceIp ( const char * macAddress,
const OBNetIpConfig & config )
inline

"Force" a static IP address configuration in a device identified by its MAC Address.

Parameters
[in]macAddressMAC address of the network device. You can obtain it from ob_device_info_get_uid, or specify it manually in the format xx:xx:xx:xx:xx:xx, where each xx is a two-digit hexadecimal value.
[in]configThe new IP configuration.
Returns
bool true if the configuration command was processed successfully, false otherwise.
Note
This applies to all GVCP devices

Definition at line 153 of file Context.hpp.

◆ sendActionCommand()

bool ob::Context::sendActionCommand ( uint32_t deviceKey,
uint32_t groupKey,
uint32_t groupMask,
const char * destIp = "255.255.255.255",
uint64_t scheduledTime = 0 )
inline

Send an Action Command to GVCP devices.

Parameters
deviceKeyDevice key to match.
groupKeyGroup key to match.
groupMaskGroup mask, bitwise-ANDed with Action block masks.
destIpDestination IPv4 address. Defaults to "255.255.255.255" for broadcast.
scheduledTimePTP timestamp. 0 = immediate, non-zero = scheduled.
Returns
bool true on success.

Definition at line 171 of file Context.hpp.

◆ setGvcpPortScheme()

void ob::Context::setGvcpPortScheme ( OBGvcpPortScheme scheme)
inline

Set the GVCP port scheme used for network device discovery and control.

Parameters
[in]schemeTarget GVCP port scheme. Thrown exception if the specified scheme is invalid or unsupported.
Note
This change affects only the current session and is not persisted.
Switching to a different scheme will force disconnection of all currently connected network devices.

Definition at line 187 of file Context.hpp.

◆ getGvcpPortScheme()

OBGvcpPortScheme ob::Context::getGvcpPortScheme ( ) const
inline

Get the current GVCP port scheme.

Returns
Current GVCP port scheme.

Definition at line 198 of file Context.hpp.

◆ createNetDevice()

std::shared_ptr< Device > ob::Context::createNetDevice ( const char * address,
uint16_t port,
OBDeviceAccessMode accessMode = OB_DEVICE_DEFAULT_ACCESS ) const
inline

Creates a network device with the specified IP address and port.

Parameters
[in]addressThe IP address, ipv4 only. such as "192.168.1.10"
[in]portThe port number, currently only support 8090
[in]accessModeDevice access mode. ob_device_access_mode. If the device does not support setting the Access Mode, the default OB_DEVICE_DEFAULT_ACCESS is used. Applies only on first device creation or after release and re-creation; subsequent calls ignore it.
Returns
std::shared_ptr<Device> The created device object.

Definition at line 216 of file Context.hpp.

◆ setDeviceChangedCallback()

void ob::Context::setDeviceChangedCallback ( DeviceChangedCallback callback)
inline

Set the device plug-in callback function.

Deprecated
This function is deprecated. Please use registerDeviceChangedCallback() instead.
Attention
This function supports multiple callbacks. Each call to this function adds a new callback to an internal list.
Parameters
[in]callbackThe function triggered when the device is plugged and unplugged.

Definition at line 232 of file Context.hpp.

◆ registerDeviceChangedCallback()

OBCallbackId ob::Context::registerDeviceChangedCallback ( DeviceChangedCallback callback)
inline

Definition at line 242 of file Context.hpp.

Referenced by setDeviceChangedCallback().

◆ unregisterDeviceChangedCallback()

void ob::Context::unregisterDeviceChangedCallback ( OBCallbackId id)
inline

Definition at line 257 of file Context.hpp.

Referenced by setDeviceChangedCallback().

◆ enableDeviceClockSync()

void ob::Context::enableDeviceClockSync ( uint64_t repeatIntervalMsec) const
inline

Activates device clock synchronization to synchronize the clock of the host and all created devices (if supported).

Parameters
[in]repeatIntervalMsecThe interval for auto-repeated synchronization, in milliseconds. If the value is 0, synchronization is performed only once.

Definition at line 274 of file Context.hpp.

◆ syncDeviceHardwarePPSTime()

void ob::Context::syncDeviceHardwarePPSTime ( uint64_t hardwarePPSTime) const
inline

Activates synchronization time to all created devices (if supported).

Parameters
[in]hardwarePPSTimeunit:ms.

Definition at line 285 of file Context.hpp.

◆ freeIdleMemory()

void ob::Context::freeIdleMemory ( ) const
inline

Frees idle memory from the internal frame memory pool.

The SDK includes an internal frame memory pool that caches memory allocated for frames received from devices.

Definition at line 295 of file Context.hpp.

◆ setUvcBackendType()

void ob::Context::setUvcBackendType ( OBUvcBackendType type) const
inline

For linux, there are two ways to enable the UVC backend: libuvc and v4l2. This function is used to set the backend type.

It is effective when the new device is created.

Attention
This interface is only available for Linux.
Parameters
[in]typeThe backend type to be used.

Definition at line 309 of file Context.hpp.

◆ setLoggerSeverity()

void ob::Context::setLoggerSeverity ( OBLogSeverity severity)
inlinestatic

Set the level of the global log, which affects both the log level output to the console, output to the file and output the user defined callback.

Parameters
[in]severityThe log output level.

Definition at line 321 of file Context.hpp.

◆ setLoggerToFile()

void ob::Context::setLoggerToFile ( OBLogSeverity severity,
const char * directory )
inlinestatic

Set log output to a file.

Parameters
[in]severityThe log level output to the file.
[in]directoryThe log file output path. If the path is empty, the existing settings will continue to be used (if the existing configuration is also empty, the log will not be output to the file).

Definition at line 334 of file Context.hpp.

◆ setLoggerFileName()

void ob::Context::setLoggerFileName ( const std::string & fileName)
inlinestatic

Set the log file name for file output.

Parameters
[in]fileNameLog file name. Must not be empty.
Note
Other settings, such as log level and output directory, remain unchanged.

Definition at line 347 of file Context.hpp.

◆ setLoggerToConsole()

void ob::Context::setLoggerToConsole ( OBLogSeverity severity)
inlinestatic

Set log output to the console.

Parameters
[in]severityThe log level output to the console.

Definition at line 358 of file Context.hpp.

◆ setLoggerToCallback()

void ob::Context::setLoggerToCallback ( OBLogSeverity severity,
LogCallback callback )
inlinestatic

Set the logger to callback.

Parameters
[in]severityThe callback log level.
[in]callbackThe callback function.

Definition at line 370 of file Context.hpp.

◆ logExternalMessage()

void ob::Context::logExternalMessage ( OBLogSeverity severity,
const std::string & module,
const std::string & message,
const std::string & file,
const std::string & func,
int line )
inlinestatic

Logs a message with severity, file, function, and line info.

Parameters
severityLog level, see OBLogSeverity for details
moduleThe module or component the log belongs to
messageMessage string to log
fileSource file name, e.g., FILE
funcFunction name, e.g., func
lineLine number, e.g., LINE

Definition at line 387 of file Context.hpp.

◆ setExtensionsDirectory()

void ob::Context::setExtensionsDirectory ( const char * directory)
inlinestatic

Set the extensions directory.

The extensions directory is used to search for dynamic libraries that provide additional functionality to the SDK, such as the Frame filters.

Attention
Should be called before creating the context and pipeline, otherwise the default extensions directory (./extensions) will be used.
Parameters
[in]directoryPath to the extensions directory. If the path is empty, the existing settings will continue to be used (if the existing

Definition at line 402 of file Context.hpp.


The documentation for this class was generated from the following file: