#include "FemtoBoltDevice.hpp"
#include "FemtoBoltPropertyAccessor.hpp"
#include "environment/EnvConfig.hpp"
#include "stream/StreamProfileFactory.hpp"
#include "sensor/video/VideoSensor.hpp"
#include "sensor/video/DisparityBasedSensor.hpp"
#include "sensor/imu/ImuStreamer.hpp"
#include "sensor/imu/AccelSensor.hpp"
#include "sensor/imu/GyroSensor.hpp"
#include "usb/uvc/UvcDevicePort.hpp"
#include "FilterFactory.hpp"
#include "metadata/FrameMetadataParserContainer.hpp"
#include "timestamp/GlobalTimestampFitter.hpp"
#include "timestamp/FrameTimestampCalculator.hpp"
#include "timestamp/DeviceClockSynchronizer.hpp"
#include "property/VendorPropertyAccessor.hpp"
#include "property/UvcPropertyAccessor.hpp"
#include "property/PropertyServer.hpp"
#include "property/CommonPropertyAccessors.hpp"
#include "property/FilterPropertyAccessors.hpp"
#include "property/PrivateFilterPropertyAccessors.hpp"
#include "monitor/DeviceMonitor.hpp"
#include "FemtoBoltAlgParamManager.hpp"
#include "FemtoBoltPresetManager.hpp"
#include "syncconfig/DeviceSyncConfigurator.hpp"
#include "rawphase/RawPhaseStreamer.hpp"
#include "rawphase/RawPhaseBasedSensor.hpp"
#include "publicfilters/FormatConverterProcess.hpp"
#include "publicfilters/IMUCorrector.hpp"
namespace libobsensor {
FemtoBoltDevice::FemtoBoltDevice(const std::shared_ptr<const IDeviceEnumInfo> &info) : DeviceBase(info) {
init();
checkAndStartHeartbeat();
}
FemtoBoltDevice::~FemtoBoltDevice() noexcept {}
void FemtoBoltDevice::init() {
initSensorList();
initProperties();
fetchDeviceInfo();
fetchExtensionInfo();
if(getFirmwareVersionInt() >= 10101) {
deviceTimeFreq_ = 1000000;
frameTimeFreq_ = 1000000;
}
auto globalTimestampFilter = std::make_shared<GlobalTimestampFitter>(this);
registerComponent(OB_DEV_COMPONENT_GLOBAL_TIMESTAMP_FILTER, globalTimestampFilter);
auto algParamManager = std::make_shared<FemtoBoltAlgParamManager>(this);
registerComponent(OB_DEV_COMPONENT_ALG_PARAM_MANAGER, algParamManager);
auto presetManager = std::make_shared<BoltPresetManager>(this);
registerComponent(OB_DEV_COMPONENT_PRESET_MANAGER, presetManager);
static const std::vector<OBMultiDeviceSyncMode> supportedSyncModes = { OB_MULTI_DEVICE_SYNC_MODE_FREE_RUN, OB_MULTI_DEVICE_SYNC_MODE_STANDALONE,
OB_MULTI_DEVICE_SYNC_MODE_PRIMARY, OB_MULTI_DEVICE_SYNC_MODE_SECONDARY };
static const std::map<OBMultiDeviceSyncMode, OBSyncMode> syncModeNewToOldMap = { { OB_MULTI_DEVICE_SYNC_MODE_FREE_RUN, OB_SYNC_MODE_CLOSE },
{ OB_MULTI_DEVICE_SYNC_MODE_STANDALONE, OB_SYNC_MODE_STANDALONE },
{ OB_MULTI_DEVICE_SYNC_MODE_PRIMARY, OB_SYNC_MODE_PRIMARY_MCU_TRIGGER },
{ OB_MULTI_DEVICE_SYNC_MODE_SECONDARY, OB_SYNC_MODE_SECONDARY },
{ OB_MULTI_DEVICE_SYNC_MODE_SECONDARY_SYNCED, OB_SYNC_MODE_SECONDARY } };
static const std::map<OBSyncMode, OBMultiDeviceSyncMode> syncModeOldToNewMap = { { OB_SYNC_MODE_CLOSE, OB_MULTI_DEVICE_SYNC_MODE_FREE_RUN },
{ OB_SYNC_MODE_STANDALONE, OB_MULTI_DEVICE_SYNC_MODE_STANDALONE },
{ OB_SYNC_MODE_PRIMARY_MCU_TRIGGER, OB_MULTI_DEVICE_SYNC_MODE_PRIMARY },
{ OB_SYNC_MODE_SECONDARY, OB_MULTI_DEVICE_SYNC_MODE_SECONDARY } };
auto deviceSyncConfigurator = std::make_shared<DeviceSyncConfiguratorOldProtocol>(this, supportedSyncModes);
deviceSyncConfigurator->updateModeAliasMap(syncModeOldToNewMap, syncModeNewToOldMap);
deviceSyncConfigurator->enableDepthDelaySupport(true);
registerComponent(OB_DEV_COMPONENT_DEVICE_SYNC_CONFIGURATOR, deviceSyncConfigurator);
auto deviceClockSynchronizer = std::make_shared<DeviceClockSynchronizer>(this, deviceTimeFreq_, deviceTimeFreq_);
registerComponent(OB_DEV_COMPONENT_DEVICE_CLOCK_SYNCHRONIZER, deviceClockSynchronizer);
}
void FemtoBoltDevice::initSensorStreamProfile(std::shared_ptr<ISensor> sensor) {
auto sensorType = sensor->getSensorType();
auto streamProfile = StreamProfileFactory::getDefaultStreamProfileFromEnvConfig(deviceInfo_->name_, sensorType);
if(streamProfile) {
sensor->updateDefaultStreamProfile(streamProfile);
}
auto profiles = sensor->getStreamProfileList();
{
auto algParamManager = getComponentT<FemtoBoltAlgParamManager>(OB_DEV_COMPONENT_ALG_PARAM_MANAGER);
algParamManager->bindStreamProfileParams(profiles);
}
LOG_INFO("Sensor {} created! Found {} stream profiles.", sensorType, profiles.size());
for(auto &profile: profiles) {
LOG_INFO(" - {}", profile);
}
}
void FemtoBoltDevice::initSensorList() {
registerComponent(OB_DEV_COMPONENT_FRAME_PROCESSOR_FACTORY, [this]() {
std::shared_ptr<FrameProcessorFactory> factory;
TRY_EXECUTE({ factory = std::make_shared<FrameProcessorFactory>(this); })
return factory;
});
const auto &sourcePortInfoList = enumInfo_->getSourcePortInfoList();
auto depthPortInfoIter = std::find_if(sourcePortInfoList.begin(), sourcePortInfoList.end(), [](const std::shared_ptr<const SourcePortInfo> &portInfo) {
return portInfo->portType == SOURCE_PORT_USB_UVC && std::dynamic_pointer_cast<const USBSourcePortInfo>(portInfo)->infIndex == 2;
});
if(depthPortInfoIter != sourcePortInfoList.end()) {
auto depthPortInfo = *depthPortInfoIter;
registerComponent(OB_DEV_COMPONENT_RAW_PHASE_STREAMER, [this, depthPortInfo]() {
auto port = getSourcePort(depthPortInfo);
auto dataStreamPort = std::dynamic_pointer_cast<IVideoStreamPort>(port);
std::shared_ptr<RawPhaseStreamer> rawPhaseStreamer;
BEGIN_TRY_EXECUTE({ rawPhaseStreamer = std::make_shared<RawPhaseStreamer>(this, dataStreamPort); })
CATCH_EXCEPTION_AND_LOG(WARN, "create RawPhaseStreamer failed.")
return rawPhaseStreamer;
});
registerComponent(
OB_DEV_COMPONENT_DEPTH_SENSOR,
[this, depthPortInfo]() {
auto rawPhaseStreamer = getComponentT<RawPhaseStreamer>(OB_DEV_COMPONENT_RAW_PHASE_STREAMER);
rawPhaseStreamer->waitNvramDataReady();
auto sensor = std::make_shared<RawPhaseBasedSensor>(this, OB_SENSOR_DEPTH, rawPhaseStreamer.get());
auto videoFrameTimestampCalculator = std::make_shared<FrameTimestampCalculatorOverUvcSCR>(this, frameTimeFreq_);
sensor->setFrameTimestampCalculator(videoFrameTimestampCalculator);
auto globalFrameTimestampCalculator = std::make_shared<GlobalTimestampCalculator>(this, deviceTimeFreq_, frameTimeFreq_);
sensor->setGlobalTimestampCalculator(globalFrameTimestampCalculator);
auto frameProcessor = getComponentT<FrameProcessor>(OB_DEV_COMPONENT_DEPTH_FRAME_PROCESSOR, false);
if(frameProcessor) {
sensor->setFrameProcessor(frameProcessor.get());
}
auto propServer = getPropertyServer();
auto passiveIrValue = propServer->getPropertyValueT<int>(OB_PROP_SWITCH_IR_MODE_INT);
rawPhaseStreamer->enablePassiveIRMode(static_cast<bool>(passiveIrValue));
initSensorStreamProfile(sensor);
return sensor;
},
true);
registerSensorPortInfo(OB_SENSOR_DEPTH, depthPortInfo);
registerComponent(OB_DEV_COMPONENT_DEPTH_FRAME_PROCESSOR, [this]() {
auto factory = getComponentT<FrameProcessorFactory>(OB_DEV_COMPONENT_FRAME_PROCESSOR_FACTORY);
auto frameProcessor = factory->createFrameProcessor(OB_SENSOR_DEPTH);
return frameProcessor;
});
registerComponent(
OB_DEV_COMPONENT_IR_SENSOR,
[this, depthPortInfo]() {
auto rawPhaseStreamer = getComponentT<RawPhaseStreamer>(OB_DEV_COMPONENT_RAW_PHASE_STREAMER);
rawPhaseStreamer->waitNvramDataReady();
auto sensor = std::make_shared<RawPhaseBasedSensor>(this, OB_SENSOR_IR, rawPhaseStreamer.get());
auto videoFrameTimestampCalculator = std::make_shared<FrameTimestampCalculatorOverUvcSCR>(this, frameTimeFreq_);
sensor->setFrameTimestampCalculator(videoFrameTimestampCalculator);
auto globalFrameTimestampCalculator = std::make_shared<GlobalTimestampCalculator>(this, deviceTimeFreq_, frameTimeFreq_);
sensor->setGlobalTimestampCalculator(globalFrameTimestampCalculator);
auto frameProcessor = getComponentT<FrameProcessor>(OB_DEV_COMPONENT_IR_FRAME_PROCESSOR, false);
if(frameProcessor) {
sensor->setFrameProcessor(frameProcessor.get());
}
initSensorStreamProfile(sensor);
return sensor;
},
true);
registerSensorPortInfo(OB_SENSOR_IR, depthPortInfo);
registerComponent(OB_DEV_COMPONENT_IR_FRAME_PROCESSOR, [this]() {
auto factory = getComponentT<FrameProcessorFactory>(OB_DEV_COMPONENT_FRAME_PROCESSOR_FACTORY);
auto frameProcessor = factory->createFrameProcessor(OB_SENSOR_IR);
return frameProcessor;
});
registerComponent(OB_DEV_COMPONENT_MAIN_PROPERTY_ACCESSOR, [this, depthPortInfo]() {
auto port = getSourcePort(depthPortInfo);
auto accessor = std::make_shared<VendorPropertyAccessor>(this, port);
return accessor;
});
registerComponent(OB_DEV_COMPONENT_DEVICE_MONITOR, [this, depthPortInfo]() {
auto port = getSourcePort(depthPortInfo);
auto uvcDevicePort = std::dynamic_pointer_cast<UvcDevicePort>(port);
auto devMonitor = std::make_shared<DeviceMonitor>(this, port);
return devMonitor;
});
}
auto colorPortInfoIter = std::find_if(sourcePortInfoList.begin(), sourcePortInfoList.end(), [](const std::shared_ptr<const SourcePortInfo> &portInfo) {
return portInfo->portType == SOURCE_PORT_USB_UVC && std::dynamic_pointer_cast<const USBSourcePortInfo>(portInfo)->infIndex == 0;
});
if(colorPortInfoIter != sourcePortInfoList.end()) {
auto colorPortInfo = *colorPortInfoIter;
registerComponent(
OB_DEV_COMPONENT_COLOR_SENSOR,
[this, colorPortInfo]() {
auto port = getSourcePort(colorPortInfo);
auto sensor = std::make_shared<VideoSensor>(this, OB_SENSOR_COLOR, port);
std::vector<FormatFilterConfig> formatFilterConfigs = {};
auto formatConverter = getSensorFrameFilter("FormatConverter", OB_SENSOR_COLOR, false);
if(formatConverter) {
#ifdef WIN32
formatFilterConfigs.push_back({ FormatFilterPolicy::ADD, OB_FORMAT_BGR, OB_FORMAT_RGB, formatConverter });
#else
formatFilterConfigs.push_back({ FormatFilterPolicy::ADD, OB_FORMAT_MJPG, OB_FORMAT_RGB, formatConverter });
formatFilterConfigs.push_back({ FormatFilterPolicy::ADD, OB_FORMAT_MJPG, OB_FORMAT_BGR, formatConverter });
formatFilterConfigs.push_back({ FormatFilterPolicy::ADD, OB_FORMAT_MJPG, OB_FORMAT_BGRA, formatConverter });
formatFilterConfigs.push_back({ FormatFilterPolicy::ADD, OB_FORMAT_MJPG, OB_FORMAT_NV12, formatConverter });
#endif
}
sensor->updateFormatFilterConfig(formatFilterConfigs);
auto videoFrameTimestampCalculator = std::make_shared<FrameTimestampCalculatorOverUvcSCR>(this, frameTimeFreq_);
sensor->setFrameTimestampCalculator(videoFrameTimestampCalculator);
auto globalFrameTimestampCalculator = std::make_shared<GlobalTimestampCalculator>(this, deviceTimeFreq_, frameTimeFreq_);
sensor->setGlobalTimestampCalculator(globalFrameTimestampCalculator);
auto frameProcessor = getComponentT<FrameProcessor>(OB_DEV_COMPONENT_COLOR_FRAME_PROCESSOR, false);
if(frameProcessor) {
sensor->setFrameProcessor(frameProcessor.get());
}
initSensorStreamProfile(sensor);
return sensor;
},
true);
registerSensorPortInfo(OB_SENSOR_COLOR, colorPortInfo);
registerComponent(OB_DEV_COMPONENT_COLOR_FRAME_PROCESSOR, [this]() {
auto factory = getComponentT<FrameProcessorFactory>(OB_DEV_COMPONENT_FRAME_PROCESSOR_FACTORY);
auto frameProcessor = factory->createFrameProcessor(OB_SENSOR_COLOR);
return frameProcessor;
});
}
auto imuPortInfoIter = std::find_if(sourcePortInfoList.begin(), sourcePortInfoList.end(),
[](const std::shared_ptr<const SourcePortInfo> &portInfo) { return portInfo->portType == SOURCE_PORT_USB_HID; });
if(imuPortInfoIter != sourcePortInfoList.end()) {
auto imuPortInfo = *imuPortInfoIter;
registerComponent(OB_DEV_COMPONENT_IMU_STREAMER, [this, imuPortInfo]() {
auto port = getSourcePort(imuPortInfo);
auto imuReversionFilter = getSensorFrameFilter("IMUFrameReversion", OB_SENSOR_ACCEL, true);
auto imuCorrectorFilter = getSensorFrameFilter("IMUCorrector", OB_SENSOR_ACCEL, true);
std::vector<std::shared_ptr<IFilter>> imuFilters = { imuReversionFilter, imuCorrectorFilter };
auto dataStreamPort = std::dynamic_pointer_cast<IDataStreamPort>(port);
auto imuStreamer = std::make_shared<ImuStreamer>(this, dataStreamPort, imuFilters);
return imuStreamer;
});
registerComponent(
OB_DEV_COMPONENT_ACCEL_SENSOR,
[this, imuPortInfo]() {
auto port = getSourcePort(imuPortInfo);
auto imuStreamer = getComponentT<ImuStreamer>(OB_DEV_COMPONENT_IMU_STREAMER);
auto imuStreamerSharedPtr = imuStreamer.get();
auto sensor = std::make_shared<AccelSensor>(this, port, imuStreamerSharedPtr);
auto globalFrameTimestampCalculator = std::make_shared<GlobalTimestampCalculator>(this, deviceTimeFreq_, frameTimeFreq_);
sensor->setGlobalTimestampCalculator(globalFrameTimestampCalculator);
initSensorStreamProfile(sensor);
return sensor;
},
true);
registerSensorPortInfo(OB_SENSOR_ACCEL, imuPortInfo);
registerComponent(
OB_DEV_COMPONENT_GYRO_SENSOR,
[this, imuPortInfo]() {
auto port = getSourcePort(imuPortInfo);
auto imuStreamer = getComponentT<ImuStreamer>(OB_DEV_COMPONENT_IMU_STREAMER);
auto imuStreamerSharedPtr = imuStreamer.get();
auto sensor = std::make_shared<GyroSensor>(this, port, imuStreamerSharedPtr);
auto globalFrameTimestampCalculator = std::make_shared<GlobalTimestampCalculator>(this, deviceTimeFreq_, frameTimeFreq_);
sensor->setGlobalTimestampCalculator(globalFrameTimestampCalculator);
initSensorStreamProfile(sensor);
return sensor;
},
true);
registerSensorPortInfo(OB_SENSOR_GYRO, imuPortInfo);
}
}
void FemtoBoltDevice::initProperties() {
auto propertyServer = std::make_shared<PropertyServer>(this);
auto irModePropertyAccessor = std::make_shared<FemtoBoltIrModePropertyAccessor>(this);
propertyServer->registerProperty(OB_PROP_SWITCH_IR_MODE_INT, "rw", "rw", irModePropertyAccessor);
auto tempPropertyAccessor = std::make_shared<FemtoBoltTempPropertyAccessor>(this);
propertyServer->registerProperty(OB_STRUCT_DEVICE_TEMPERATURE, "r", "r", tempPropertyAccessor);
auto frameTransformPropertyAccessor = std::make_shared<MonocularFrameTransformPropertyAccessor>(this);
propertyServer->registerProperty(OB_PROP_DEPTH_MIRROR_BOOL, "rw", "rw", frameTransformPropertyAccessor); propertyServer->registerProperty(OB_PROP_DEPTH_FLIP_BOOL, "rw", "rw", frameTransformPropertyAccessor);
propertyServer->registerProperty(OB_PROP_DEPTH_ROTATE_INT, "rw", "rw", frameTransformPropertyAccessor);
propertyServer->registerProperty(OB_PROP_COLOR_MIRROR_BOOL, "rw", "rw", frameTransformPropertyAccessor); propertyServer->registerProperty(OB_PROP_COLOR_FLIP_BOOL, "rw", "rw", frameTransformPropertyAccessor);
propertyServer->registerProperty(OB_PROP_COLOR_ROTATE_INT, "rw", "rw", frameTransformPropertyAccessor);
propertyServer->registerProperty(OB_PROP_IR_MIRROR_BOOL, "rw", "rw", frameTransformPropertyAccessor); propertyServer->registerProperty(OB_PROP_IR_FLIP_BOOL, "rw", "rw", frameTransformPropertyAccessor);
propertyServer->registerProperty(OB_PROP_IR_ROTATE_INT, "rw", "rw", frameTransformPropertyAccessor);
auto privatePropertyAccessor = std::make_shared<PrivateFilterPropertyAccessor>(this);
propertyServer->registerProperty(OB_PROP_DEPTH_SOFT_FILTER_BOOL, "rw", "rw", privatePropertyAccessor);
propertyServer->registerProperty(OB_PROP_DEPTH_MAX_DIFF_INT, "rw", "rw", privatePropertyAccessor);
propertyServer->registerProperty(OB_PROP_DEPTH_MAX_SPECKLE_SIZE_INT, "rw", "rw", privatePropertyAccessor);
auto sensors = getSensorTypeList();
for(auto &sensor: sensors) {
auto &sourcePortInfo = getSensorPortInfo(sensor);
if(sensor == OB_SENSOR_COLOR) {
auto uvcPropertyAccessor = std::make_shared<LazyPropertyAccessor>([this, &sourcePortInfo]() {
auto port = getSourcePort(sourcePortInfo);
auto accessor = std::make_shared<UvcPropertyAccessor>(port);
return accessor;
});
propertyServer->registerProperty(OB_PROP_COLOR_AUTO_EXPOSURE_BOOL, "rw", "rw", uvcPropertyAccessor);
propertyServer->registerProperty(OB_PROP_COLOR_GAIN_INT, "rw", "rw", uvcPropertyAccessor);
propertyServer->registerProperty(OB_PROP_COLOR_SATURATION_INT, "rw", "rw", uvcPropertyAccessor);
propertyServer->registerProperty(OB_PROP_COLOR_AUTO_WHITE_BALANCE_BOOL, "rw", "rw", uvcPropertyAccessor);
propertyServer->registerProperty(OB_PROP_COLOR_WHITE_BALANCE_INT, "rw", "rw", uvcPropertyAccessor);
propertyServer->registerProperty(OB_PROP_COLOR_BRIGHTNESS_INT, "rw", "rw", uvcPropertyAccessor);
propertyServer->registerProperty(OB_PROP_COLOR_SHARPNESS_INT, "rw", "rw", uvcPropertyAccessor);
propertyServer->registerProperty(OB_PROP_COLOR_CONTRAST_INT, "rw", "rw", uvcPropertyAccessor);
propertyServer->registerProperty(OB_PROP_COLOR_POWER_LINE_FREQUENCY_INT, "rw", "rw", uvcPropertyAccessor);
}
else if(sensor == OB_SENSOR_DEPTH) {
auto vendorPropertyAccessor = std::make_shared<LazySuperPropertyAccessor>([this, &sourcePortInfo]() {
auto port = getSourcePort(sourcePortInfo);
auto accessor = std::make_shared<VendorPropertyAccessor>(this, port);
return accessor;
});
propertyServer->registerProperty(OB_PROP_TIMESTAMP_OFFSET_INT, "rw", "rw", vendorPropertyAccessor);
propertyServer->registerProperty(OB_PROP_INDICATOR_LIGHT_BOOL, "rw", "rw", vendorPropertyAccessor);
propertyServer->registerProperty(OB_PROP_USB_POWER_STATE_INT, "r", "r", vendorPropertyAccessor);
propertyServer->registerProperty(OB_PROP_DC_POWER_STATE_INT, "r", "r", vendorPropertyAccessor);
propertyServer->registerProperty(OB_PROP_BOOT_INTO_RECOVERY_MODE_BOOL, "w", "w", vendorPropertyAccessor);
propertyServer->registerProperty(OB_PROP_REBOOT_DEVICE_BOOL, "w", "w", vendorPropertyAccessor);
propertyServer->registerProperty(OB_PROP_TIMER_RESET_ENABLE_BOOL, "rw", "rw", vendorPropertyAccessor);
propertyServer->registerProperty(OB_PROP_TIMER_RESET_SIGNAL_BOOL, "w", "w", vendorPropertyAccessor);
propertyServer->registerProperty(OB_STRUCT_DEVICE_TIME, "rw", "rw", vendorPropertyAccessor);
propertyServer->registerProperty(OB_RAW_DATA_CAMERA_CALIB_JSON_FILE, "r", "r", vendorPropertyAccessor);
propertyServer->registerProperty(OB_RAW_DATA_ALIGN_CALIB_PARAM, "", "r", vendorPropertyAccessor);
propertyServer->registerProperty(OB_RAW_DATA_D2C_ALIGN_SUPPORT_PROFILE_LIST, "", "rw", vendorPropertyAccessor);
propertyServer->registerProperty(OB_RAW_DATA_IMU_CALIB_PARAM, "", "rw", vendorPropertyAccessor);
propertyServer->registerProperty(OB_STRUCT_VERSION, "", "r", vendorPropertyAccessor);
propertyServer->registerProperty(OB_PROP_GYRO_ODR_INT, "rw", "rw", vendorPropertyAccessor);
propertyServer->registerProperty(OB_PROP_ACCEL_ODR_INT, "rw", "rw", vendorPropertyAccessor);
propertyServer->registerProperty(OB_PROP_GYRO_FULL_SCALE_INT, "rw", "rw", vendorPropertyAccessor);
propertyServer->registerProperty(OB_PROP_ACCEL_FULL_SCALE_INT, "rw", "rw", vendorPropertyAccessor);
propertyServer->registerProperty(OB_STRUCT_GET_ACCEL_PRESETS_ODR_LIST, "", "rw", vendorPropertyAccessor);
propertyServer->registerProperty(OB_STRUCT_GET_ACCEL_PRESETS_FULL_SCALE_LIST, "", "rw", vendorPropertyAccessor);
propertyServer->registerProperty(OB_STRUCT_GET_GYRO_PRESETS_ODR_LIST, "", "rw", vendorPropertyAccessor);
propertyServer->registerProperty(OB_STRUCT_GET_GYRO_PRESETS_FULL_SCALE_LIST, "", "rw", vendorPropertyAccessor);
propertyServer->registerProperty(OB_PROP_ACCEL_SWITCH_BOOL, "", "rw", vendorPropertyAccessor);
propertyServer->registerProperty(OB_PROP_GYRO_SWITCH_BOOL, "", "rw", vendorPropertyAccessor);
propertyServer->registerProperty(OB_PROP_TOF_EXPOSURE_TIME_INT, "r", "r", vendorPropertyAccessor);
propertyServer->registerProperty(OB_PROP_STOP_COLOR_STREAM_BOOL, "rw", "rw", vendorPropertyAccessor);
propertyServer->registerProperty(OB_PROP_STOP_DEPTH_STREAM_BOOL, "rw", "rw", vendorPropertyAccessor);
propertyServer->registerProperty(OB_STRUCT_MULTI_DEVICE_SYNC_CONFIG, "rw", "rw", vendorPropertyAccessor);
propertyServer->registerProperty(OB_PROP_COLOR_HDR_BOOL, "rw", "rw", vendorPropertyAccessor);
propertyServer->registerProperty(OB_PROP_COLOR_EXPOSURE_INT, "rw", "rw", vendorPropertyAccessor);
}
else if(sensor == OB_SENSOR_ACCEL) {
auto imuCorrectorFilter = getSensorFrameFilter("IMUCorrector", sensor);
if(imuCorrectorFilter) {
auto filterStateProperty = std::make_shared<FilterStatePropertyAccessor>(imuCorrectorFilter);
propertyServer->registerProperty(OB_PROP_SDK_ACCEL_FRAME_TRANSFORMED_BOOL, "rw", "rw", filterStateProperty);
}
}
else if(sensor == OB_SENSOR_GYRO) {
auto imuCorrectorFilter = getSensorFrameFilter("IMUCorrector", sensor);
if(imuCorrectorFilter) {
auto filterStateProperty = std::make_shared<FilterStatePropertyAccessor>(imuCorrectorFilter);
propertyServer->registerProperty(OB_PROP_SDK_GYRO_FRAME_TRANSFORMED_BOOL, "rw", "rw", filterStateProperty);
}
}
}
propertyServer->aliasProperty(OB_PROP_IR_EXPOSURE_INT, OB_PROP_TOF_EXPOSURE_TIME_INT);
propertyServer->aliasProperty(OB_PROP_DEPTH_EXPOSURE_INT, OB_PROP_TOF_EXPOSURE_TIME_INT);
auto heartbeatPropertyAccessor = std::make_shared<HeartbeatPropertyAccessor>(this);
propertyServer->registerProperty(OB_PROP_HEARTBEAT_BOOL, "rw", "rw", heartbeatPropertyAccessor);
registerComponent(OB_DEV_COMPONENT_PROPERTY_SERVER, propertyServer, true);
}
std::vector<std::shared_ptr<IFilter>> FemtoBoltDevice::createRecommendedPostProcessingFilters(OBSensorType type) {
auto filterFactory = FilterFactory::getInstance();
if(type == OB_SENSOR_DEPTH) {
getComponentT<FrameProcessor>(OB_DEV_COMPONENT_DEPTH_FRAME_PROCESSOR, false);
std::vector<std::shared_ptr<IFilter>> depthFilterList;
if(filterFactory->isFilterCreatorExists("DecimationFilter")) {
auto decimationFilter = filterFactory->createFilter("DecimationFilter");
depthFilterList.push_back(decimationFilter);
}
if(filterFactory->isFilterCreatorExists("SpatialAdvancedFilter")) {
auto spatFilter = filterFactory->createFilter("SpatialAdvancedFilter");
std::vector<std::string> params = { "1", "0.5", "5", "1" };
spatFilter->updateConfig(params);
depthFilterList.push_back(spatFilter);
}
if(filterFactory->isFilterCreatorExists("TemporalFilter")) {
auto tempFilter = filterFactory->createFilter("TemporalFilter");
std::vector<std::string> params = { "0.1", "0.4" };
tempFilter->updateConfig(params);
depthFilterList.push_back(tempFilter);
}
if(filterFactory->isFilterCreatorExists("HoleFillingFilter")) {
auto hfFilter = filterFactory->createFilter("HoleFillingFilter");
std::vector<std::string> params = { "2" };
hfFilter->updateConfig(params);
depthFilterList.push_back(hfFilter);
}
if(filterFactory->isFilterCreatorExists("ThresholdFilter")) {
auto ThresholdFilter = filterFactory->createFilter("ThresholdFilter");
depthFilterList.push_back(ThresholdFilter);
}
for(size_t i = 0; i < depthFilterList.size(); i++) {
auto filter = depthFilterList[i];
filter->enable(false);
}
return depthFilterList;
}
else if(type == OB_SENSOR_COLOR) {
getComponentT<FrameProcessor>(OB_DEV_COMPONENT_COLOR_FRAME_PROCESSOR, false);
std::vector<std::shared_ptr<IFilter>> colorFilterList;
if(filterFactory->isFilterCreatorExists("DecimationFilter")) {
auto decimationFilter = filterFactory->createFilter("DecimationFilter");
decimationFilter->enable(false);
colorFilterList.push_back(decimationFilter);
}
return colorFilterList;
}
return {};
}
}