Merge branch 'develop' of http://gitlab.mynt.com/mynteye/mynt-eye-sdk-2 into develop

This commit is contained in:
TinyOh 2019-01-09 13:07:53 +08:00
commit 03dd23f68c
8 changed files with 66 additions and 30 deletions

View File

@ -22,6 +22,7 @@
#include <string>
#include <vector>
#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<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

View File

@ -136,9 +136,11 @@ class MYNTEYE_API Channels {
class ChannelsAdapter {
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::vector<std::int32_t> GetAccelRangeValues() = 0;
@ -147,6 +149,9 @@ class ChannelsAdapter {
virtual std::vector<std::int32_t> GetGyroRangeValues() = 0;
virtual void GetImuResPacket(const std::uint8_t *data, ImuResPacket *res) = 0;
protected:
Model model_;
};
MYNTEYE_END_NAMESPACE

View File

@ -13,7 +13,6 @@
// limitations under the License.
#include "mynteye/device/standard/channels_adapter_s.h"
#include "mynteye/device/config.h"
#include "mynteye/logger.h"
MYNTEYE_BEGIN_NAMESPACE
@ -95,16 +94,13 @@ void unpack_imu_res_packet(const std::uint8_t *data, ImuResPacket *res) {
} // namespace
StandardChannelsAdapter::StandardChannelsAdapter() {
StandardChannelsAdapter::StandardChannelsAdapter()
: ChannelsAdapter(Model::STANDARD) {
}
StandardChannelsAdapter::~StandardChannelsAdapter() {
}
std::set<Option> StandardChannelsAdapter::GetOptionSupports() {
return option_supports_map.at(Model::STANDARD);
}
std::int32_t StandardChannelsAdapter::GetAccelRangeDefault() {
return 8;
}

View File

@ -28,8 +28,6 @@ class StandardChannelsAdapter : public ChannelsAdapter {
StandardChannelsAdapter();
virtual ~StandardChannelsAdapter();
std::set<Option> GetOptionSupports() override;
std::int32_t GetAccelRangeDefault() override;
std::vector<std::int32_t> GetAccelRangeValues() override;

View File

@ -13,7 +13,6 @@
// limitations under the License.
#include "mynteye/device/standard2/channels_adapter_s2.h"
#include "mynteye/device/config.h"
#include "mynteye/logger.h"
MYNTEYE_BEGIN_NAMESPACE
@ -91,16 +90,13 @@ void unpack_imu_res_packet(const std::uint8_t *data, ImuResPacket *res) {
} // namespace
Standard2ChannelsAdapter::Standard2ChannelsAdapter() {
Standard2ChannelsAdapter::Standard2ChannelsAdapter()
: ChannelsAdapter(Model::STANDARD2) {
}
Standard2ChannelsAdapter::~Standard2ChannelsAdapter() {
}
std::set<Option> Standard2ChannelsAdapter::GetOptionSupports() {
return option_supports_map.at(Model::STANDARD2);
}
std::int32_t Standard2ChannelsAdapter::GetAccelRangeDefault() {
return 12;
}

View File

@ -28,8 +28,6 @@ class Standard2ChannelsAdapter : public ChannelsAdapter {
Standard2ChannelsAdapter();
virtual ~Standard2ChannelsAdapter();
std::set<Option> GetOptionSupports() override;
std::int32_t GetAccelRangeDefault() override;
std::vector<std::int32_t> GetAccelRangeValues() override;

View File

@ -13,7 +13,6 @@
// limitations under the License.
#include "mynteye/device/standard2/channels_adapter_s210a.h"
#include "mynteye/device/config.h"
#include "mynteye/logger.h"
MYNTEYE_BEGIN_NAMESPACE
@ -91,16 +90,13 @@ void unpack_imu_res_packet(const std::uint8_t *data, ImuResPacket *res) {
} // namespace
Standard210aChannelsAdapter::Standard210aChannelsAdapter() {
Standard210aChannelsAdapter::Standard210aChannelsAdapter()
: ChannelsAdapter(Model::STANDARD210A) {
}
Standard210aChannelsAdapter::~Standard210aChannelsAdapter() {
}
std::set<Option> Standard210aChannelsAdapter::GetOptionSupports() {
return option_supports_map.at(Model::STANDARD210A);
}
std::int32_t Standard210aChannelsAdapter::GetAccelRangeDefault() {
return 12;
}

View File

@ -28,8 +28,6 @@ class Standard210aChannelsAdapter : public ChannelsAdapter {
Standard210aChannelsAdapter();
virtual ~Standard210aChannelsAdapter();
std::set<Option> GetOptionSupports() override;
std::int32_t GetAccelRangeDefault() override;
std::vector<std::int32_t> GetAccelRangeValues() override;