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

#include <Context.hpp>

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.
 
std::shared_ptr< DeviceListqueryDeviceList () const
 Queries the enumerated device list.
 
void enableNetDeviceEnumeration (bool enable) const
 enable or disable net device enumeration.
 
std::shared_ptr< DevicecreateNetDevice (const char *address, uint16_t port) const
 Creates a network device with the specified IP address and port.
 
void setDeviceChangedCallback (DeviceChangedCallback callback)
 Set the device plug-in callback function.
 
void enableDeviceClockSync (uint64_t repeatIntervalMsec) const
 Activates device clock synchronization to synchronize the clock of the host and all created devices (if supported).
 
void freeIdleMemory () const
 Frees idle memory from the internal frame memory pool.
 

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 setLoggerToConsole (OBLogSeverity severity)
 Set log output to the console.
 
static void setLoggerToCallback (OBLogSeverity severity, LogCallback callback)
 Set the logger to callback.
 
static void setExtensionsDirectory (const char *directory)
 Set the extensions directory.
 

Detailed Description

Definition at line 26 of file Context.hpp.

Member Typedef Documentation

◆ DeviceChangedCallback

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
removedListThe list of removed devices.
addedListThe list of added devices.

Definition at line 34 of file Context.hpp.

◆ LogCallback

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

Type definition for the log output callback function.

Parameters
severityThe current callback log level.
logMsgThe log message.

Definition at line 42 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 58 of file Context.hpp.

◆ ~Context()

ob::Context::~Context ( )
inlinenoexcept

Context destructor.

Definition at line 67 of file Context.hpp.

Member Function Documentation

◆ 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 78 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 94 of file Context.hpp.

◆ createNetDevice()

std::shared_ptr< Device > ob::Context::createNetDevice ( const char * address,
uint16_t port ) 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
Returns
std::shared_ptr<Device> The created device object.

Definition at line 107 of file Context.hpp.

◆ setDeviceChangedCallback()

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

Set the device plug-in callback function.

Parameters
callbackThe function triggered when the device is plugged and unplugged.

Definition at line 119 of file Context.hpp.

◆ 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
repeatIntervalThe interval for auto-repeated synchronization, in milliseconds. If the value is 0, synchronization is performed only once.

Definition at line 131 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 141 of file Context.hpp.

◆ setLoggerSeverity()

static 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
severityThe log output level.

Definition at line 152 of file Context.hpp.

◆ setLoggerToFile()

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

Set log output to a file.

Parameters
severityThe log level output to the file.
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 165 of file Context.hpp.

◆ setLoggerToConsole()

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

Set log output to the console.

Parameters
severityThe log level output to the console.

Definition at line 176 of file Context.hpp.

◆ setLoggerToCallback()

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

Set the logger to callback.

Parameters
severityThe callback log level.
callbackThe callback function.

Definition at line 188 of file Context.hpp.

◆ setExtensionsDirectory()

static 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
directoryPath to the extensions directory. If the path is empty, the existing settings will continue to be used (if the existing

Definition at line 203 of file Context.hpp.


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