diff --git a/include/mynteye/types.h b/include/mynteye/types.h index b81a07f..f34cf11 100644 --- a/include/mynteye/types.h +++ b/include/mynteye/types.h @@ -391,6 +391,16 @@ struct MYNTEYE_API ImuData { } }; +/** + * @ingroup datatypes + * Option info. + */ +struct MYNTEYE_API OptionInfo { + std::int32_t min; + std::int32_t max; + std::int32_t def; +}; + MYNTEYE_END_NAMESPACE #endif // MYNTEYE_TYPES_H_ NOLINT diff --git a/samples/device/camera.cc b/samples/device/camera.cc index 94c009e..0544960 100644 --- a/samples/device/camera.cc +++ b/samples/device/camera.cc @@ -42,6 +42,8 @@ int main(int argc, char *argv[]) { } } + device->LogOptionInfos(); + std::size_t left_count = 0; device->SetStreamCallback( Stream::LEFT, [&left_count](const device::StreamData &data) { diff --git a/src/device/device.cc b/src/device/device.cc index 28afe38..268361d 100644 --- a/src/device/device.cc +++ b/src/device/device.cc @@ -131,6 +131,23 @@ ImuExtrinsics Device::GetImuExtrinsics() const { return imu_extrinsics_; } +OptionInfo Device::GetOptionInfo(const Option &option) const { + auto &&info = channels_->GetControlInfo(option); + return {info.min, info.max, info.def}; +} + +std::int32_t Device::GetOptionValue(const Option &option) const { + return channels_->GetControlValue(option); +} + +void Device::SetOptionValue(const Option &option, std::int32_t value) { + channels_->SetControlValue(option, value); +} + +void Device::LogOptionInfos() const { + channels_->LogControlInfos(); +} + void Device::SetStreamCallback( const Stream &stream, stream_callback_t callback) { if (!Supports(stream)) { diff --git a/src/device/device.h b/src/device/device.h index f2e3a03..d9061c6 100644 --- a/src/device/device.h +++ b/src/device/device.h @@ -61,6 +61,11 @@ class Device { ImuIntrinsics GetImuIntrinsics() const; ImuExtrinsics GetImuExtrinsics() const; + OptionInfo GetOptionInfo(const Option &option) const; + std::int32_t GetOptionValue(const Option &option) const; + void SetOptionValue(const Option &option, std::int32_t value); + void LogOptionInfos() const; + void SetStreamCallback(const Stream &stream, stream_callback_t callback); void SetMotionCallback(motion_callback_t callback); diff --git a/src/internal/channels.cc b/src/internal/channels.cc index 5b99b43..43ece39 100644 --- a/src/internal/channels.cc +++ b/src/internal/channels.cc @@ -2,26 +2,210 @@ #include +#include + MYNTEYE_BEGIN_NAMESPACE +namespace { + +int XuCamCtrlId(Option option) { + switch (option) { + case Option::EXPOSURE_MODE: + return 0; + break; + case Option::MAX_GAIN: + return 1; + break; + case Option::MAX_EXPOSURE_TIME: + return 2; + break; + case Option::DESIRED_BRIGHTNESS: + return 3; + break; + case Option::IMU_FREQUENCY: + return 4; + break; + case Option::IR_CONTROL: + return 5; + break; + case Option::HDR_MODE: + return 6; + break; + case Option::FRAME_RATE: + return 7; + break; + default: + LOG(FATAL) << "No cam ctrl id for " << option; + } +} + +} // namespace + Channels::Channels(std::shared_ptr device) : device_(device) { VLOG(2) << __func__; + + for (auto &&option : std::vector