| OrbbecSDK 1.10.18 OrbbecSDK: Software-Development-Kit for Orbbec 3D Cameras

Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | List of all members
ob::Context Class Reference

`#include <Context.hpp>`

## Public Types
using | DeviceChangedCallback = std::function< void(std::shared_ptr< DeviceList > removedList, std::shared_ptr< DeviceList > addedList)>
using | LogCallback = std::function< void(OBLogSeverity severity, const char *logMsg)>
| Log output callback function.

## Public Member Functions
| Context (const char *configPath="")
| 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.
virtual | ~Context () noexcept
std::shared_ptr< DeviceList > | queryDeviceList ()
| Queries the enumerated device list.
void | enableNetDeviceEnumeration (bool enable)
| enable or disable net device enumeration.
std::shared_ptr< Device > | createNetDevice (const char *address, uint16_t port)
| Creates a network device object.
void | changeNetDeviceIpConfig (const char *deviceUid, const OBNetIpConfig &config)
| Changes the IP configuration of a network device.
void | setDeviceChangedCallback (DeviceChangedCallback callback)
| Set the device plug-in callback function.
void | enableDeviceClockSync (uint64_t repeatInterval)
| Activates device clock synchronization to synchronize the clock of the host and all created devices (if supported).
void | freeIdleMemory ()
| Frees idle memory from the internal frame memory pool.
void | setUVCBackend (OBUvcBackend uvcBackend)
| Set the UVC backend for the specified context This function configures the Universal Video Class (UVC) backend for the given context, allowing the selection of a specific backend for video capture operations.

## 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 terminal and output to the file.
static void | setLoggerToFile (OBLogSeverity severity, const char *directory)
| Set log output to a file.
static void | setLoggerToConsole (OBLogSeverity severity)
| Set log output to the terminal.
static void | setLoggerToCallback (OBLogSeverity severity, LogCallback callback)
| Set the logger to callback.
static void | loadLicense (const char *filePath, const char *key=OB_DEFAULT_DECRYPT_KEY)
| Loads a license file.
static void | loadLicenseFromData (const char *data, uint32_t dataLen, const char *key=OB_DEFAULT_DECRYPT_KEY)
| Loads a license from data.

## Detailed Description

Definition at line 21 of file Context.hpp.

## Member Typedef Documentation

## ◆ DeviceChangedCallback

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

Definition at line 69 of file Context.hpp.

## ◆ LogCallback

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

Log output callback function.

Parameters

  severity | The current callback log level.
  logMsg | The log message.

Definition at line 120 of file Context.hpp.

## Constructor & Destructor Documentation

## ◆ Context()

ob::Context::Context | ( | const char * | configPath = `""` | ) |

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.

## ◆ ~Context()

virtual ob::Context::~Context | ( |  | ) |
| virtual noexcept

## Member Function Documentation

## ◆ queryDeviceList()

std::shared_ptr< DeviceList > ob::Context::queryDeviceList | ( |  | ) |

Queries the enumerated device list.

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

## ◆ enableNetDeviceEnumeration()

void ob::Context::enableNetDeviceEnumeration | ( | bool | enable | ) |

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

  [out] | enable | true to enable, false to disable

## ◆ createNetDevice()

std::shared_ptr< Device > ob::Context::createNetDevice | ( | const char * | address,
|  | uint16_t | port
| ) |  |

Creates a network device object.

Parameters

  address | The IP address.
  port | The port.

Returns
  std::shared_ptr<Device> The created device object.

## ◆ changeNetDeviceIpConfig()

void ob::Context::changeNetDeviceIpConfig | ( | const char * | deviceUid,
|  | const OBNetIpConfig & | config
| ) |  |

Changes the IP configuration of a network device.

Parameters

  deviceUid | The device unique ID, which is the network device MAC address. It can be obtained through the DeviceList::uid() function.
  config | The new IP configuration.

## ◆ setDeviceChangedCallback()

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

Set the device plug-in callback function.

Parameters

  callback | The function triggered when the device is plugged and unplugged.

## ◆ enableDeviceClockSync()

void ob::Context::enableDeviceClockSync | ( | uint64_t | repeatInterval | ) |

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

Parameters

  repeatInterval | The interval for auto-repeated synchronization, in milliseconds. If the value is 0, synchronization is performed only once.

## ◆ freeIdleMemory()

void ob::Context::freeIdleMemory | ( |  | ) |

Frees idle memory from the internal frame memory pool.

## ◆ setLoggerSeverity()

static void ob::Context::setLoggerSeverity | ( | OBLogSeverity | severity | ) |
| static

Set the level of the global log, which affects both the log level output to the terminal and output to the file.

Parameters

  severity | The log output level.

## ◆ setLoggerToFile()

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

Set log output to a file.

Parameters

  severity | The log level output to the file.
  directory | The 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).

## ◆ setLoggerToConsole()

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

Set log output to the terminal.

Parameters

  severity | The log level output to the terminal.

## ◆ setLoggerToCallback()

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

Set the logger to callback.

Parameters

  severity | The callback log level.
  callback | The callback function.

## ◆ loadLicense()

static void ob::Context::loadLicense | ( | const char * | filePath,
|  | const char * | key = `OB_DEFAULT_DECRYPT_KEY`
| ) |  |
| static

Loads a license file.

Parameters

  filePath | The license file path.
  key | The decryption key.

## ◆ loadLicenseFromData()

static void ob::Context::loadLicenseFromData | ( | const char * | data,
|  | uint32_t | dataLen,
|  | const char * | key = `OB_DEFAULT_DECRYPT_KEY`
| ) |  |
| static

Loads a license from data.

Parameters

  data | The license data.
  dataLen | The license data length.
  key | The decryption key.

## ◆ setUVCBackend()

void ob::Context::setUVCBackend | ( | OBUvcBackend | uvcBackend | ) |

Set the UVC backend for the specified context This function configures the Universal Video Class (UVC) backend for the given context, allowing the selection of a specific backend for video capture operations.

Attention
  This function is only supported on Linux (ARM) platforms. Some devices, like the Dabai series, do not support V4L2. Therefore, the default backend is LIBUVC. Ensure that the device supports V4L2 before setting it as the backend.

Parameters

  [in] | uvcBackend | Specifies the UVC backend to use: `UVC_BACKEND_AUTO`: Automatically selects between V4L2 or libuvc based on metadata support. `UVC_BACKEND_LIBUVC`: Forces the use of libuvc. `UVC_BACKEND_V4L2`: Forces the use of V4L2.

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

- E:/Projects/Jenkins/workspace/OrbbecSDK/libobsensor/include/libobsensor/hpp/Context.hpp