OrbbecSDK 2.5.5
OrbbecSDK: Software-Development-Kit for Orbbec 3D Cameras
Loading...
Searching...
No Matches
Context.h File Reference

Context is a management class that describes the runtime of the SDK and is responsible for resource allocation and release of the SDK. Context has the ability to manage multiple devices. It is responsible for enumerating devices, monitoring device callbacks, and enabling multi-device synchronization. More...

#include "ObTypes.h"

Go to the source code of this file.

Macros

#define ob_enable_multi_device_sync   ob_enable_device_clock_sync
#define ob_set_logger_callback   ob_set_logger_to_callback

Functions

OB_EXPORT ob_contextob_create_context (ob_error **error)
 Create a context object with the default configuration file.
OB_EXPORT ob_contextob_create_context_with_config (const char *config_file_path, ob_error **error)
 Create a context object with a specified configuration file.
OB_EXPORT void ob_delete_context (ob_context *context, ob_error **error)
 Delete a context object.
OB_EXPORT ob_device_listob_query_device_list (ob_context *context, ob_error **error)
 Get a list of enumerated devices.
OB_EXPORT void ob_enable_net_device_enumeration (ob_context *context, bool enable, ob_error **error)
 Enable or disable network device enumeration.
OB_EXPORT bool ob_force_ip_config (const char *deviceUid, ob_net_ip_config config, ob_error **error)
 "Force" a static IP address configuration in a device identified by its MAC Address.
OB_EXPORT ob_deviceob_create_net_device (ob_context *context, const char *address, uint16_t port, ob_error **error)
 Create a network device object.
OB_EXPORT void ob_set_device_changed_callback (ob_context *context, ob_device_changed_callback callback, void *user_data, ob_error **error)
 Set a device plug-in callback function.
OB_EXPORT void ob_enable_device_clock_sync (ob_context *context, uint64_t repeat_interval_msec, ob_error **error)
 Activates device clock synchronization to synchronize the clock of the host and all created devices (if supported).
OB_EXPORT void ob_free_idle_memory (ob_context *context, ob_error **error)
 Free idle memory from the internal frame memory pool.
OB_EXPORT void ob_set_uvc_backend_type (ob_context *context, ob_uvc_backend_type backend_type, ob_error **error)
 For linux, there are two ways to enable the UVC backend: libuvc and v4l2. This function is used to set the backend type.
OB_EXPORT void ob_set_logger_severity (ob_log_severity severity, ob_error **error)
 Set the global log level.
OB_EXPORT void ob_set_logger_to_file (ob_log_severity severity, const char *directory, ob_error **error)
 Set the log output to a file.
OB_EXPORT void ob_set_logger_to_callback (ob_log_severity severity, ob_log_callback callback, void *user_data, ob_error **error)
 Set the log callback function.
OB_EXPORT void ob_set_logger_to_console (ob_log_severity severity, ob_error **error)
 Set the log output to the console.
OB_EXPORT void ob_set_extensions_directory (const char *directory, ob_error **error)
 Set the extensions directory.

Detailed Description

Context is a management class that describes the runtime of the SDK and is responsible for resource allocation and release of the SDK. Context has the ability to manage multiple devices. It is responsible for enumerating devices, monitoring device callbacks, and enabling multi-device synchronization.

Definition in file Context.h.

Macro Definition Documentation

◆ ob_enable_multi_device_sync

#define ob_enable_multi_device_sync   ob_enable_device_clock_sync

Definition at line 182 of file Context.h.

◆ ob_set_logger_callback

#define ob_set_logger_callback   ob_set_logger_to_callback

Definition at line 183 of file Context.h.

Function Documentation

◆ ob_create_context()

OB_EXPORT ob_context * ob_create_context ( ob_error ** error)

Create a context object with the default configuration file.

Parameters
[out]errorPointer to an error object that will be populated if an error occurs during context creation
Returns
Pointer to the created context object

◆ ob_create_context_with_config()

OB_EXPORT ob_context * ob_create_context_with_config ( const char * config_file_path,
ob_error ** error )

Create a context object with a specified configuration file.

Parameters
[in]config_file_pathPath to the configuration file. If NULL, the default configuration file will be used.
[out]errorPointer to an error object that will be populated if an error occurs during context creation
Returns
Pointer to the created context object

Referenced by ob::Context::Context().

◆ ob_delete_context()

OB_EXPORT void ob_delete_context ( ob_context * context,
ob_error ** error )

Delete a context object.

Parameters
[in]contextPointer to the context object to be deleted
[out]errorPointer to an error object that will be populated if an error occurs during context deletion

Referenced by ob::Context::~Context().

◆ ob_query_device_list()

OB_EXPORT ob_device_list * ob_query_device_list ( ob_context * context,
ob_error ** error )

Get a list of enumerated devices.

Parameters
[in]contextPointer to the context object
[out]errorPointer to an error object that will be populated if an error occurs during device enumeration
Returns
Pointer to the device list object

Referenced by ob::Context::queryDeviceList().

◆ ob_enable_net_device_enumeration()

OB_EXPORT void ob_enable_net_device_enumeration ( ob_context * context,
bool enable,
ob_error ** error )

Enable or disable network device enumeration.

After enabling, the network device will be automatically discovered and can be retrieved through ob_query_device_list. The default state can be set in the configuration file.

Attention
Network device enumeration is performed through the GVCP protocol. If the device is not in the same subnet as the host, it will be discovered but cannot be connected.
Parameters
[in]contextPointer to the context object
[in]enabletrue to enable, false to disable
[out]errorPointer to an error object that will be populated if an error occurs.

Referenced by ob::Context::enableNetDeviceEnumeration().

◆ ob_force_ip_config()

OB_EXPORT bool ob_force_ip_config ( const char * deviceUid,
ob_net_ip_config config,
ob_error ** error )

"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 DeviceList::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.
[out]errorPointer to an error object that will be populated if an error occurs.
Returns
bool true if the configuration command was processed successfully, false otherwise.
Note
This applies to all Orbbec GigE Vision devices

Referenced by ob::Context::forceIp().

◆ ob_create_net_device()

OB_EXPORT ob_device * ob_create_net_device ( ob_context * context,
const char * address,
uint16_t port,
ob_error ** error )

Create a network device object.

Parameters
[in]contextPointer to the context object
[in]addressIP address of the device
[in]portPort number of the device
[out]errorPointer to an error object that will be populated if an error occurs during device creation
Returns
Pointer to the created device object

Referenced by ob::Context::createNetDevice().

◆ ob_set_device_changed_callback()

OB_EXPORT void ob_set_device_changed_callback ( ob_context * context,
ob_device_changed_callback callback,
void * user_data,
ob_error ** error )

Set a device plug-in callback function.

Attention
The added and removed device lists returned through the callback interface need to be released manually
This function supports multiple callbacks. Each call to this function adds a new callback to an internal list.
Parameters
[in]contextPointer to the context object
[in]callbackPointer to the callback function triggered when a device is plugged or unplugged
[in]user_dataPointer to user data that can be passed to and retrieved from the callback function
[out]errorPointer to an error object that will be populated if an error occurs during callback function setting

Referenced by ob::Context::setDeviceChangedCallback().

◆ ob_enable_device_clock_sync()

OB_EXPORT void ob_enable_device_clock_sync ( ob_context * context,
uint64_t repeat_interval_msec,
ob_error ** error )

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

Parameters
[in]contextPointer to the context object
[in]repeat_interval_msecThe interval for auto-repeated synchronization, in milliseconds. If the value is 0, synchronization is performed only once.
[out]errorPointer to an error object that will be populated if an error occurs during execution

Referenced by ob::Context::enableDeviceClockSync().

◆ ob_free_idle_memory()

OB_EXPORT void ob_free_idle_memory ( ob_context * context,
ob_error ** error )

Free idle memory from the internal frame memory pool.

Parameters
[in]contextPointer to the context object
[out]errorPointer to an error object that will be populated if an error occurs during memory freeing

Referenced by ob::Context::freeIdleMemory().

◆ ob_set_uvc_backend_type()

OB_EXPORT void ob_set_uvc_backend_type ( ob_context * context,
ob_uvc_backend_type backend_type,
ob_error ** error )

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]contextPointer to the context object
[in]backend_typeThe backend type to be used.
[out]errorPointer to an error object that will be populated if an error occurs during backend type setting

Referenced by ob::Context::setUvcBackendType().

◆ ob_set_logger_severity()

OB_EXPORT void ob_set_logger_severity ( ob_log_severity severity,
ob_error ** error )

Set the global log level.

Attention
This interface setting will affect the output level of all logs (terminal, file, callback)
Parameters
[in]severityLog level to set
[out]errorPointer to an error object that will be populated if an error occurs during log level setting

Referenced by ob::Context::setLoggerSeverity().

◆ ob_set_logger_to_file()

OB_EXPORT void ob_set_logger_to_file ( ob_log_severity severity,
const char * directory,
ob_error ** error )

Set the log output to a file.

Parameters
[in]severityLog level to output to file
[in]directoryPath to the log file output directory. 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)
[out]errorPointer to an error object that will be populated if an error occurs during log output setting

Referenced by ob::Context::setLoggerToFile().

◆ ob_set_logger_to_callback()

OB_EXPORT void ob_set_logger_to_callback ( ob_log_severity severity,
ob_log_callback callback,
void * user_data,
ob_error ** error )

Set the log callback function.

Parameters
[in]severityLog level to set for the callback function
[in]callbackPointer to the callback function
[in]user_dataPointer to user data that can be passed to and retrieved from the callback function
[out]errorPointer to an error object that will be populated if an error occurs during log callback function setting

Referenced by ob::Context::setLoggerToCallback().

◆ ob_set_logger_to_console()

OB_EXPORT void ob_set_logger_to_console ( ob_log_severity severity,
ob_error ** error )

Set the log output to the console.

Parameters
[in]severityLog level to output to the console
[out]errorPointer to an error object that will be populated if an error occurs during log output setting

Referenced by ob::Context::setLoggerToConsole().

◆ ob_set_extensions_directory()

OB_EXPORT void ob_set_extensions_directory ( const char * directory,
ob_error ** error )

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, extensions path will be set to the current working directory.
errorPointer to an error object that will be populated if an error occurs during extensions directory setting

Referenced by ob::Context::setExtensionsDirectory().