From da0566b896ece35a165a7eb32cc63d4ac43a85f4 Mon Sep 17 00:00:00 2001 From: John Zhao Date: Wed, 9 Jan 2019 11:29:23 +0800 Subject: [PATCH] feat(channels): Limit image params resolution when write it --- src/mynteye/device/channel/channels.cc | 57 +++++++++++++++++-- src/mynteye/device/channel/channels.h | 9 ++- .../device/standard/channels_adapter_s.cc | 8 +-- .../device/standard/channels_adapter_s.h | 2 - .../device/standard2/channels_adapter_s2.cc | 8 +-- .../device/standard2/channels_adapter_s2.h | 2 - .../standard2/channels_adapter_s210a.cc | 8 +-- .../device/standard2/channels_adapter_s210a.h | 2 - 8 files changed, 66 insertions(+), 30 deletions(-) diff --git a/src/mynteye/device/channel/channels.cc b/src/mynteye/device/channel/channels.cc index 7b70e9d..6619cd7 100644 --- a/src/mynteye/device/channel/channels.cc +++ b/src/mynteye/device/channel/channels.cc @@ -22,6 +22,7 @@ #include #include +#include "mynteye/device/config.h" #include "mynteye/logger.h" #include "mynteye/util/times.h" @@ -520,10 +521,31 @@ bool Channels::SetFiles( } } if (img_params != nullptr) { - auto n = file_channel_.SetImgParamsToData(img_params, data + 3 + size); - if (n > 0) { - header[1] = true; - size += n; + // remove not supported resolution + auto&& res = adapter_->GetResolutionSupports(); + for (auto it = img_params->begin(); it != img_params->end(); ) { + if (res.find(it->first) == res.end()) { + LOG(WARNING) << "Image params of resolution " + << it->first.width << "x" << it->first.height << " not supported"; + it = img_params->erase(it); + } else { + ++it; + } + } + + if (img_params->empty()) { + std::ostringstream os; + os << "Image params resolution must be "; + for (auto&& r : res) { + os << r.width << "x" << r.height << " "; + } + LOG(WARNING) << os.str(); + } else { + auto n = file_channel_.SetImgParamsToData(img_params, data + 3 + size); + if (n > 0) { + header[1] = true; + size += n; + } } } if (imu_params != nullptr) { @@ -719,4 +741,31 @@ Channels::control_info_t Channels::XuControlInfo(Option option) const { return {min, max, def}; } +// ChannelsAdapter + +ChannelsAdapter::ChannelsAdapter(const Model &model) + : model_(model) { +} + +ChannelsAdapter::~ChannelsAdapter() { +} + +std::set