From 490185a5778b52cc810fafbb0e13e18b7d7dbb5b Mon Sep 17 00:00:00 2001 From: John Zhao Date: Tue, 10 Apr 2018 00:26:22 +0800 Subject: [PATCH] Add options get set --- include/mynteye/types.h | 10 +++ samples/device/camera.cc | 2 + src/device/device.cc | 17 ++++ src/device/device.h | 5 ++ src/internal/channels.cc | 188 ++++++++++++++++++++++++++++++++++++++- src/internal/channels.h | 23 ++++- 6 files changed, 240 insertions(+), 5 deletions(-) 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