feat(channels): Limit image params resolution when write it
This commit is contained in:
parent
9474528972
commit
da0566b896
|
@ -22,6 +22,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "mynteye/device/config.h"
|
||||||
#include "mynteye/logger.h"
|
#include "mynteye/logger.h"
|
||||||
#include "mynteye/util/times.h"
|
#include "mynteye/util/times.h"
|
||||||
|
|
||||||
|
@ -520,12 +521,33 @@ bool Channels::SetFiles(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (img_params != nullptr) {
|
if (img_params != nullptr) {
|
||||||
|
// 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);
|
auto n = file_channel_.SetImgParamsToData(img_params, data + 3 + size);
|
||||||
if (n > 0) {
|
if (n > 0) {
|
||||||
header[1] = true;
|
header[1] = true;
|
||||||
size += n;
|
size += n;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (imu_params != nullptr) {
|
if (imu_params != nullptr) {
|
||||||
auto n = file_channel_.SetImuParamsToData(imu_params, data + 3 + size);
|
auto n = file_channel_.SetImuParamsToData(imu_params, data + 3 + size);
|
||||||
if (n > 0) {
|
if (n > 0) {
|
||||||
|
@ -719,4 +741,31 @@ Channels::control_info_t Channels::XuControlInfo(Option option) const {
|
||||||
return {min, max, def};
|
return {min, max, def};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ChannelsAdapter
|
||||||
|
|
||||||
|
ChannelsAdapter::ChannelsAdapter(const Model &model)
|
||||||
|
: model_(model) {
|
||||||
|
}
|
||||||
|
|
||||||
|
ChannelsAdapter::~ChannelsAdapter() {
|
||||||
|
}
|
||||||
|
|
||||||
|
std::set<Option> ChannelsAdapter::GetOptionSupports() {
|
||||||
|
return option_supports_map.at(model_);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::set<Resolution> ChannelsAdapter::GetResolutionSupports() {
|
||||||
|
std::set<Resolution> res;
|
||||||
|
auto requests_map = stream_requests_map.at(model_);
|
||||||
|
for (auto&& r_map : requests_map) {
|
||||||
|
if (r_map.first == Capabilities::STEREO ||
|
||||||
|
r_map.first == Capabilities::STEREO_COLOR) {
|
||||||
|
for (auto&& r : r_map.second) {
|
||||||
|
res.insert({r.width, r.height});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
MYNTEYE_END_NAMESPACE
|
MYNTEYE_END_NAMESPACE
|
||||||
|
|
|
@ -136,9 +136,11 @@ class MYNTEYE_API Channels {
|
||||||
|
|
||||||
class ChannelsAdapter {
|
class ChannelsAdapter {
|
||||||
public:
|
public:
|
||||||
virtual ~ChannelsAdapter() {}
|
explicit ChannelsAdapter(const Model &model);
|
||||||
|
virtual ~ChannelsAdapter();
|
||||||
|
|
||||||
virtual std::set<Option> GetOptionSupports() = 0;
|
virtual std::set<Option> GetOptionSupports();
|
||||||
|
virtual std::set<Resolution> GetResolutionSupports();
|
||||||
|
|
||||||
virtual std::int32_t GetAccelRangeDefault() = 0;
|
virtual std::int32_t GetAccelRangeDefault() = 0;
|
||||||
virtual std::vector<std::int32_t> GetAccelRangeValues() = 0;
|
virtual std::vector<std::int32_t> GetAccelRangeValues() = 0;
|
||||||
|
@ -147,6 +149,9 @@ class ChannelsAdapter {
|
||||||
virtual std::vector<std::int32_t> GetGyroRangeValues() = 0;
|
virtual std::vector<std::int32_t> GetGyroRangeValues() = 0;
|
||||||
|
|
||||||
virtual void GetImuResPacket(const std::uint8_t *data, ImuResPacket *res) = 0;
|
virtual void GetImuResPacket(const std::uint8_t *data, ImuResPacket *res) = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
Model model_;
|
||||||
};
|
};
|
||||||
|
|
||||||
MYNTEYE_END_NAMESPACE
|
MYNTEYE_END_NAMESPACE
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
#include "mynteye/device/standard/channels_adapter_s.h"
|
#include "mynteye/device/standard/channels_adapter_s.h"
|
||||||
|
|
||||||
#include "mynteye/device/config.h"
|
|
||||||
#include "mynteye/logger.h"
|
#include "mynteye/logger.h"
|
||||||
|
|
||||||
MYNTEYE_BEGIN_NAMESPACE
|
MYNTEYE_BEGIN_NAMESPACE
|
||||||
|
@ -95,16 +94,13 @@ void unpack_imu_res_packet(const std::uint8_t *data, ImuResPacket *res) {
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
StandardChannelsAdapter::StandardChannelsAdapter() {
|
StandardChannelsAdapter::StandardChannelsAdapter()
|
||||||
|
: ChannelsAdapter(Model::STANDARD) {
|
||||||
}
|
}
|
||||||
|
|
||||||
StandardChannelsAdapter::~StandardChannelsAdapter() {
|
StandardChannelsAdapter::~StandardChannelsAdapter() {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::set<Option> StandardChannelsAdapter::GetOptionSupports() {
|
|
||||||
return option_supports_map.at(Model::STANDARD);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::int32_t StandardChannelsAdapter::GetAccelRangeDefault() {
|
std::int32_t StandardChannelsAdapter::GetAccelRangeDefault() {
|
||||||
return 8;
|
return 8;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,8 +28,6 @@ class StandardChannelsAdapter : public ChannelsAdapter {
|
||||||
StandardChannelsAdapter();
|
StandardChannelsAdapter();
|
||||||
virtual ~StandardChannelsAdapter();
|
virtual ~StandardChannelsAdapter();
|
||||||
|
|
||||||
std::set<Option> GetOptionSupports() override;
|
|
||||||
|
|
||||||
std::int32_t GetAccelRangeDefault() override;
|
std::int32_t GetAccelRangeDefault() override;
|
||||||
std::vector<std::int32_t> GetAccelRangeValues() override;
|
std::vector<std::int32_t> GetAccelRangeValues() override;
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
#include "mynteye/device/standard2/channels_adapter_s2.h"
|
#include "mynteye/device/standard2/channels_adapter_s2.h"
|
||||||
|
|
||||||
#include "mynteye/device/config.h"
|
|
||||||
#include "mynteye/logger.h"
|
#include "mynteye/logger.h"
|
||||||
|
|
||||||
MYNTEYE_BEGIN_NAMESPACE
|
MYNTEYE_BEGIN_NAMESPACE
|
||||||
|
@ -91,16 +90,13 @@ void unpack_imu_res_packet(const std::uint8_t *data, ImuResPacket *res) {
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
Standard2ChannelsAdapter::Standard2ChannelsAdapter() {
|
Standard2ChannelsAdapter::Standard2ChannelsAdapter()
|
||||||
|
: ChannelsAdapter(Model::STANDARD2) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Standard2ChannelsAdapter::~Standard2ChannelsAdapter() {
|
Standard2ChannelsAdapter::~Standard2ChannelsAdapter() {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::set<Option> Standard2ChannelsAdapter::GetOptionSupports() {
|
|
||||||
return option_supports_map.at(Model::STANDARD2);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::int32_t Standard2ChannelsAdapter::GetAccelRangeDefault() {
|
std::int32_t Standard2ChannelsAdapter::GetAccelRangeDefault() {
|
||||||
return 12;
|
return 12;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,8 +28,6 @@ class Standard2ChannelsAdapter : public ChannelsAdapter {
|
||||||
Standard2ChannelsAdapter();
|
Standard2ChannelsAdapter();
|
||||||
virtual ~Standard2ChannelsAdapter();
|
virtual ~Standard2ChannelsAdapter();
|
||||||
|
|
||||||
std::set<Option> GetOptionSupports() override;
|
|
||||||
|
|
||||||
std::int32_t GetAccelRangeDefault() override;
|
std::int32_t GetAccelRangeDefault() override;
|
||||||
std::vector<std::int32_t> GetAccelRangeValues() override;
|
std::vector<std::int32_t> GetAccelRangeValues() override;
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
#include "mynteye/device/standard2/channels_adapter_s210a.h"
|
#include "mynteye/device/standard2/channels_adapter_s210a.h"
|
||||||
|
|
||||||
#include "mynteye/device/config.h"
|
|
||||||
#include "mynteye/logger.h"
|
#include "mynteye/logger.h"
|
||||||
|
|
||||||
MYNTEYE_BEGIN_NAMESPACE
|
MYNTEYE_BEGIN_NAMESPACE
|
||||||
|
@ -91,16 +90,13 @@ void unpack_imu_res_packet(const std::uint8_t *data, ImuResPacket *res) {
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
Standard210aChannelsAdapter::Standard210aChannelsAdapter() {
|
Standard210aChannelsAdapter::Standard210aChannelsAdapter()
|
||||||
|
: ChannelsAdapter(Model::STANDARD210A) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Standard210aChannelsAdapter::~Standard210aChannelsAdapter() {
|
Standard210aChannelsAdapter::~Standard210aChannelsAdapter() {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::set<Option> Standard210aChannelsAdapter::GetOptionSupports() {
|
|
||||||
return option_supports_map.at(Model::STANDARD210A);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::int32_t Standard210aChannelsAdapter::GetAccelRangeDefault() {
|
std::int32_t Standard210aChannelsAdapter::GetAccelRangeDefault() {
|
||||||
return 12;
|
return 12;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,8 +28,6 @@ class Standard210aChannelsAdapter : public ChannelsAdapter {
|
||||||
Standard210aChannelsAdapter();
|
Standard210aChannelsAdapter();
|
||||||
virtual ~Standard210aChannelsAdapter();
|
virtual ~Standard210aChannelsAdapter();
|
||||||
|
|
||||||
std::set<Option> GetOptionSupports() override;
|
|
||||||
|
|
||||||
std::int32_t GetAccelRangeDefault() override;
|
std::int32_t GetAccelRangeDefault() override;
|
||||||
std::vector<std::int32_t> GetAccelRangeValues() override;
|
std::vector<std::int32_t> GetAccelRangeValues() override;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user