refactor(*): change stream request and params interfaces
This commit is contained in:
@@ -563,44 +563,43 @@ std::size_t from_data(
|
||||
return i;
|
||||
}
|
||||
|
||||
// TODO(Kalman): Is there a more elegant way?
|
||||
std::size_t from_data(
|
||||
device::img_params_t *img_params, const std::uint8_t *data,
|
||||
Channels::img_params_t *img_params, const std::uint8_t *data,
|
||||
const Version *spec_version) {
|
||||
std::size_t i = 0;
|
||||
|
||||
// TODO(JohnZhao)
|
||||
Intrinsics in_left, in_right;
|
||||
Extrinsics ex_right_to_left;
|
||||
|
||||
if (spec_version->major() == 1) {
|
||||
if (spec_version->minor() == 0) {
|
||||
i += from_data(
|
||||
&img_params->in_left_map[Resolution::RES_752x480], data + i,
|
||||
spec_version);
|
||||
i += from_data(
|
||||
&img_params->in_right_map[Resolution::RES_752x480], data + i,
|
||||
spec_version);
|
||||
i += from_data(&in_left, data + i, spec_version);
|
||||
i += from_data(&in_right, data + i, spec_version);
|
||||
i += from_data(&ex_right_to_left, data + i, spec_version);
|
||||
(*img_params)[{752, 480}] = {true, in_left, in_right, ex_right_to_left};
|
||||
}
|
||||
|
||||
if (spec_version->minor() == 1) {
|
||||
i += from_data(
|
||||
&img_params->in_left_map[Resolution::RES_1280x400], data + i,
|
||||
spec_version);
|
||||
i += from_data(
|
||||
&img_params->in_right_map[Resolution::RES_1280x400], data + i,
|
||||
spec_version);
|
||||
i += from_data(
|
||||
&img_params->in_left_map[Resolution::RES_2560x800], data + i,
|
||||
spec_version);
|
||||
i += from_data(
|
||||
&img_params->in_right_map[Resolution::RES_2560x800], data + i,
|
||||
spec_version);
|
||||
i += from_data(&in_left, data + i, spec_version);
|
||||
i += from_data(&in_right, data + i, spec_version);
|
||||
(*img_params)[{1280, 400}] = {true, in_left, in_right, ex_right_to_left};
|
||||
|
||||
i += from_data(&in_left, data + i, spec_version);
|
||||
i += from_data(&in_right, data + i, spec_version);
|
||||
(*img_params)[{2560, 800}] = {true, in_left, in_right, ex_right_to_left};
|
||||
|
||||
i += from_data(&ex_right_to_left, data + i, spec_version);
|
||||
(*img_params)[{1280, 400}].ex_right_to_left = ex_right_to_left;
|
||||
(*img_params)[{2560, 800}].ex_right_to_left = ex_right_to_left;
|
||||
}
|
||||
}
|
||||
|
||||
i += from_data(&img_params->ex_right_to_left, data + i, spec_version);
|
||||
return i;
|
||||
}
|
||||
|
||||
std::size_t from_data(
|
||||
device::imu_params_t *imu_params, const std::uint8_t *data,
|
||||
Channels::imu_params_t *imu_params, const std::uint8_t *data,
|
||||
const Version *spec_version) {
|
||||
std::size_t i = 0;
|
||||
i += from_data(&imu_params->in_accel, data + i, spec_version);
|
||||
@@ -674,8 +673,7 @@ bool Channels::GetFiles(
|
||||
CheckSpecVersion(spec_ver);
|
||||
} break;
|
||||
case FID_IMG_PARAMS: {
|
||||
img_params->ok = file_size > 0;
|
||||
if (img_params->ok) {
|
||||
if (file_size > 0) {
|
||||
CheckSpecVersion(spec_ver);
|
||||
from_data(img_params, data + i, spec_ver);
|
||||
// Considering the upgrade, comment this
|
||||
@@ -864,38 +862,34 @@ std::size_t to_data(
|
||||
}
|
||||
|
||||
std::size_t to_data(
|
||||
const device::img_params_t *img_params, std::uint8_t *data,
|
||||
const Channels::img_params_t *img_params, std::uint8_t *data,
|
||||
const Version *spec_version) {
|
||||
std::size_t i = 3; // skip id, size
|
||||
|
||||
// TODO(JohnZhao)
|
||||
if (spec_version->major() == 1) {
|
||||
if (spec_version->minor() == 0) {
|
||||
i += to_data(
|
||||
&img_params->in_left_map.at(Resolution::RES_752x480), data + i,
|
||||
spec_version);
|
||||
i += to_data(
|
||||
&img_params->in_right_map.at(Resolution::RES_752x480), data + i,
|
||||
spec_version);
|
||||
auto &¶ms = (*img_params).at({752, 480});
|
||||
i += to_data(¶ms.in_left, data + i, spec_version);
|
||||
i += to_data(¶ms.in_right, data + i, spec_version);
|
||||
i += to_data(¶ms.ex_right_to_left, data + i, spec_version);
|
||||
}
|
||||
|
||||
if (spec_version->minor() == 1) {
|
||||
i += to_data(
|
||||
&img_params->in_left_map.at(Resolution::RES_1280x400), data + i,
|
||||
spec_version);
|
||||
i += to_data(
|
||||
&img_params->in_right_map.at(Resolution::RES_1280x400), data + i,
|
||||
spec_version);
|
||||
|
||||
i += to_data(
|
||||
&img_params->in_left_map.at(Resolution::RES_2560x800), data + i,
|
||||
spec_version);
|
||||
i += to_data(
|
||||
&img_params->in_right_map.at(Resolution::RES_2560x800), data + i,
|
||||
spec_version);
|
||||
{
|
||||
auto &¶ms = (*img_params).at({1280, 400});
|
||||
i += to_data(¶ms.in_left, data + i, spec_version);
|
||||
i += to_data(¶ms.in_right, data + i, spec_version);
|
||||
}
|
||||
{
|
||||
auto &¶ms = (*img_params).at({2560, 800});
|
||||
i += to_data(¶ms.in_left, data + i, spec_version);
|
||||
i += to_data(¶ms.in_right, data + i, spec_version);
|
||||
i += to_data(¶ms.ex_right_to_left, data + i, spec_version);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
i += to_data(&img_params->ex_right_to_left, data + i, spec_version);
|
||||
// others
|
||||
std::size_t size = i - 3;
|
||||
data[0] = Channels::FID_IMG_PARAMS;
|
||||
|
||||
@@ -68,23 +68,9 @@ class MYNTEYE_API Channels {
|
||||
|
||||
using device_info_t = DeviceInfo;
|
||||
|
||||
using img_params_t = std::map<Resolution, device::img_params_t>;
|
||||
using imu_params_t = device::imu_params_t;
|
||||
using img_params_t = device::img_params_t;
|
||||
/*
|
||||
typedef struct ImgParams {
|
||||
bool ok;
|
||||
std::map<Resolution, Intrinsics> in_left_map;
|
||||
std::map<Resolution, Intrinsics> in_right_map;
|
||||
Extrinsics ex_right_to_left;
|
||||
} img_params_t;
|
||||
|
||||
typedef struct ImuParams {
|
||||
bool ok;
|
||||
ImuIntrinsics in_accel;
|
||||
ImuIntrinsics in_gyro;
|
||||
Extrinsics ex_left_to_imu;
|
||||
} imu_params_t;
|
||||
*/
|
||||
explicit Channels(std::shared_ptr<uvc::device> device);
|
||||
~Channels();
|
||||
|
||||
|
||||
@@ -16,39 +16,65 @@
|
||||
MYNTEYE_BEGIN_NAMESPACE
|
||||
|
||||
const std::map<Model, StreamSupports> stream_supports_map = {
|
||||
{Model::STANDARD, {Stream::LEFT, Stream::RIGHT}}};
|
||||
{Model::STANDARD, {Stream::LEFT, Stream::RIGHT}},
|
||||
{Model::STANDARD2, {Stream::LEFT, Stream::RIGHT}}
|
||||
};
|
||||
|
||||
const std::map<Model, CapabilitiesSupports> capabilities_supports_map = {
|
||||
{Model::STANDARD, {Capabilities::STEREO_COLOR, Capabilities::IMU}}};
|
||||
{Model::STANDARD, {Capabilities::STEREO, Capabilities::IMU}},
|
||||
{Model::STANDARD2, {Capabilities::STEREO_COLOR, Capabilities::IMU}}
|
||||
};
|
||||
|
||||
// TODO(Kalman): Compatible with two generation
|
||||
const std::map<Model, OptionSupports> option_supports_map = {
|
||||
{Model::STANDARD,
|
||||
{Option::BRIGHTNESS, Option::EXPOSURE_MODE, Option::MAX_GAIN,
|
||||
Option::MAX_EXPOSURE_TIME, Option::DESIRED_BRIGHTNESS,
|
||||
Option::MIN_EXPOSURE_TIME, Option::ERASE_CHIP,
|
||||
Option::ACCELEROMETER_RANGE, Option::GYROSCOPE_RANGE,
|
||||
Option::ACCELEROMETER_LOW_PASS_FILTER,
|
||||
Option::GYROSCOPE_LOW_PASS_FILTER}}};
|
||||
{Model::STANDARD, {
|
||||
Option::GAIN, Option::BRIGHTNESS, Option::CONTRAST,
|
||||
Option::FRAME_RATE, Option::IMU_FREQUENCY,
|
||||
Option::EXPOSURE_MODE, Option::MAX_GAIN, Option::MAX_EXPOSURE_TIME,
|
||||
Option::DESIRED_BRIGHTNESS,
|
||||
Option::IR_CONTROL,
|
||||
Option::HDR_MODE,
|
||||
Option::ACCELEROMETER_RANGE, Option::GYROSCOPE_RANGE,
|
||||
Option::ZERO_DRIFT_CALIBRATION,
|
||||
Option::ERASE_CHIP}
|
||||
},
|
||||
{Model::STANDARD2, {
|
||||
Option::BRIGHTNESS,
|
||||
Option::EXPOSURE_MODE, Option::MAX_GAIN, Option::MAX_EXPOSURE_TIME,
|
||||
Option::MIN_EXPOSURE_TIME, Option::DESIRED_BRIGHTNESS,
|
||||
Option::ACCELEROMETER_RANGE, Option::GYROSCOPE_RANGE,
|
||||
Option::ACCELEROMETER_LOW_PASS_FILTER, Option::GYROSCOPE_LOW_PASS_FILTER,
|
||||
Option::ERASE_CHIP}
|
||||
}
|
||||
};
|
||||
|
||||
const std::map<Model, std::map<Capabilities, StreamRequests>>
|
||||
stream_requests_map = {
|
||||
{Model::STANDARD,
|
||||
{{Capabilities::STEREO, {{480, 752, Format::YUYV, 25}}},
|
||||
{Capabilities::STEREO_COLOR,
|
||||
{// {1280, 400, Format::YUYV, 10},
|
||||
// {1280, 400, Format::YUYV, 20},
|
||||
// {1280, 400, Format::YUYV, 30},
|
||||
// {1280, 400, Format::YUYV, 60},
|
||||
// {2560, 800, Format::YUYV, 10},
|
||||
// {2560, 800, Format::YUYV, 20},
|
||||
// {2560, 800, Format::YUYV, 30},
|
||||
{1280, 400, Format::BGR888, 10},
|
||||
{1280, 400, Format::BGR888, 20},
|
||||
{1280, 400, Format::BGR888, 30},
|
||||
{1280, 400, Format::BGR888, 60},
|
||||
{2560, 800, Format::BGR888, 10},
|
||||
{2560, 800, Format::BGR888, 20},
|
||||
{2560, 800, Format::BGR888, 30}}}}}};
|
||||
stream_requests_map = {
|
||||
{Model::STANDARD,
|
||||
{{Capabilities::STEREO, {
|
||||
{752, 480, Format::YUYV, 10},
|
||||
{752, 480, Format::YUYV, 15},
|
||||
{752, 480, Format::YUYV, 20},
|
||||
{752, 480, Format::YUYV, 25},
|
||||
{752, 480, Format::YUYV, 30},
|
||||
{752, 480, Format::YUYV, 35},
|
||||
{752, 480, Format::YUYV, 40},
|
||||
{752, 480, Format::YUYV, 45},
|
||||
{752, 480, Format::YUYV, 50},
|
||||
{752, 480, Format::YUYV, 55},
|
||||
{752, 480, Format::YUYV, 60}}
|
||||
}}
|
||||
},
|
||||
{Model::STANDARD2,
|
||||
{{Capabilities::STEREO_COLOR, {
|
||||
{1280, 400, Format::BGR888, 10},
|
||||
{1280, 400, Format::BGR888, 20},
|
||||
{1280, 400, Format::BGR888, 30},
|
||||
{1280, 400, Format::BGR888, 60},
|
||||
{2560, 800, Format::BGR888, 10},
|
||||
{2560, 800, Format::BGR888, 20},
|
||||
{2560, 800, Format::BGR888, 30}}
|
||||
}}
|
||||
}
|
||||
};
|
||||
|
||||
MYNTEYE_END_NAMESPACE
|
||||
|
||||
@@ -27,18 +27,13 @@ MYNTEYE_BEGIN_NAMESPACE
|
||||
using StreamSupports = std::set<Stream>;
|
||||
using CapabilitiesSupports = std::set<Capabilities>;
|
||||
using OptionSupports = std::set<Option>;
|
||||
using ResolutionSupports = std::set<Resolution>;
|
||||
using FrameRateSupports = std::set<FrameRate>;
|
||||
|
||||
extern const std::map<Model, StreamSupports> stream_supports_map;
|
||||
extern const std::map<Model, CapabilitiesSupports> capabilities_supports_map;
|
||||
extern const std::map<Model, OptionSupports> option_supports_map;
|
||||
extern const std::map<Model, ResolutionSupports> resolution_supports_map;
|
||||
|
||||
using StreamRequests = std::vector<StreamRequest>;
|
||||
|
||||
extern const std::map<Model, std::map<Resolution, FrameRateSupports>>
|
||||
framerate_Supports_supports_map;
|
||||
|
||||
extern const std::map<Model, std::map<Capabilities, StreamRequests>>
|
||||
stream_requests_map;
|
||||
|
||||
|
||||
@@ -172,6 +172,33 @@ void Device::ConfigStreamRequest(
|
||||
return;
|
||||
}
|
||||
stream_config_requests_[capability] = request;
|
||||
UpdateStreamIntrinsics(capability, request);
|
||||
}
|
||||
|
||||
const StreamRequest &Device::GetStreamRequest(
|
||||
const Capabilities &capability) const {
|
||||
try {
|
||||
return stream_config_requests_.at(capability);
|
||||
} catch (const std::out_of_range &e) {
|
||||
auto &&requests = GetStreamRequests(capability);
|
||||
if (requests.size() >= 1) {
|
||||
return requests[0];
|
||||
} else {
|
||||
LOG(FATAL) << "Please config the stream request of " << capability;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const std::vector<StreamRequest> &Device::GetStreamRequests() const {
|
||||
return GetStreamRequests(GetKeyStreamCapability());
|
||||
}
|
||||
|
||||
void Device::ConfigStreamRequest(const StreamRequest &request) {
|
||||
ConfigStreamRequest(GetKeyStreamCapability(), request);
|
||||
}
|
||||
|
||||
const StreamRequest &Device::GetStreamRequest() const {
|
||||
return GetStreamRequest(GetKeyStreamCapability());
|
||||
}
|
||||
|
||||
std::shared_ptr<DeviceInfo> Device::GetInfo() const {
|
||||
@@ -406,6 +433,14 @@ void Device::WaitForStreams() {
|
||||
streams_->WaitForStreams();
|
||||
}
|
||||
|
||||
device::StreamData Device::GetStreamData(const Stream &stream) {
|
||||
CHECK(video_streaming_);
|
||||
CHECK_NOTNULL(streams_);
|
||||
CheckSupports(this, stream);
|
||||
std::lock_guard<std::mutex> _(mtx_streams_);
|
||||
return streams_->GetLatestStreamData(stream);
|
||||
}
|
||||
|
||||
std::vector<device::StreamData> Device::GetStreamDatas(const Stream &stream) {
|
||||
CHECK(video_streaming_);
|
||||
CHECK_NOTNULL(streams_);
|
||||
@@ -414,14 +449,6 @@ std::vector<device::StreamData> Device::GetStreamDatas(const Stream &stream) {
|
||||
return streams_->GetStreamDatas(stream);
|
||||
}
|
||||
|
||||
device::StreamData Device::GetLatestStreamData(const Stream &stream) {
|
||||
CHECK(video_streaming_);
|
||||
CHECK_NOTNULL(streams_);
|
||||
CheckSupports(this, stream);
|
||||
std::lock_guard<std::mutex> _(mtx_streams_);
|
||||
return streams_->GetLatestStreamData(stream);
|
||||
}
|
||||
|
||||
void Device::EnableMotionDatas() {
|
||||
EnableMotionDatas(std::numeric_limits<std::size_t>::max());
|
||||
}
|
||||
@@ -437,33 +464,6 @@ std::vector<device::MotionData> Device::GetMotionDatas() {
|
||||
return motions_->GetMotionDatas();
|
||||
}
|
||||
|
||||
void Device::InitResolution(const Resolution &res) {
|
||||
res_ = res;
|
||||
ConfigIntrinsics(res_);
|
||||
}
|
||||
|
||||
void Device::SetStreamRequest(const Format &format, const FrameRate &rate) {
|
||||
StreamRequest request(res_, format, rate);
|
||||
request_ = request;
|
||||
}
|
||||
|
||||
const StreamRequest &Device::GetStreamRequest(const Capabilities &capability) {
|
||||
try {
|
||||
return stream_config_requests_.at(capability);
|
||||
} catch (const std::out_of_range &e) {
|
||||
auto &&requests = GetStreamRequests(capability);
|
||||
if (requests.size() >= 1) {
|
||||
for (auto &&request : requests) {
|
||||
if (request == request_)
|
||||
return request;
|
||||
}
|
||||
return requests[0];
|
||||
} else {
|
||||
LOG(FATAL) << "Please config the stream request of " << capability;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Device::StartVideoStreaming() {
|
||||
if (video_streaming_) {
|
||||
LOG(WARNING) << "Cannot start video streaming without first stopping it";
|
||||
@@ -557,8 +557,9 @@ void Device::ReadAllInfos() {
|
||||
device_info_ = std::make_shared<DeviceInfo>();
|
||||
|
||||
CHECK_NOTNULL(channels_);
|
||||
all_img_params_.clear();
|
||||
Device::imu_params_t imu_params;
|
||||
if (!channels_->GetFiles(device_info_.get(), &img_params_, &imu_params)) {
|
||||
if (!channels_->GetFiles(device_info_.get(), &all_img_params_, &imu_params)) {
|
||||
#if defined(WITH_DEVICE_INFO_REQUIRED)
|
||||
LOG(FATAL)
|
||||
#else
|
||||
@@ -579,14 +580,28 @@ void Device::ReadAllInfos() {
|
||||
<< ", nominal_baseline: " << device_info_->nominal_baseline << "}";
|
||||
|
||||
device_info_->name = uvc::get_name(*device_);
|
||||
if (img_params_.ok) {
|
||||
SetExtrinsics(Stream::LEFT, Stream::RIGHT, img_params_.ex_right_to_left);
|
||||
VLOG(2) << "Extrinsics left to right: {"
|
||||
<< GetExtrinsics(Stream::LEFT, Stream::RIGHT) << "}";
|
||||
} else {
|
||||
|
||||
bool img_params_ok = false;
|
||||
for (auto &¶ms : all_img_params_) {
|
||||
auto &&img_params = params.second;
|
||||
if (img_params.ok) {
|
||||
img_params_ok = true;
|
||||
SetIntrinsics(Stream::LEFT, img_params.in_left);
|
||||
SetIntrinsics(Stream::RIGHT, img_params.in_right);
|
||||
SetExtrinsics(Stream::LEFT, Stream::RIGHT, img_params.ex_right_to_left);
|
||||
VLOG(2) << "Intrinsics left: {" << GetIntrinsics(Stream::LEFT) << "}";
|
||||
VLOG(2) << "Intrinsics right: {" << GetIntrinsics(Stream::RIGHT) << "}";
|
||||
VLOG(2) << "Extrinsics left to right: {"
|
||||
<< GetExtrinsics(Stream::LEFT, Stream::RIGHT) << "}";
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!img_params_ok) {
|
||||
LOG(WARNING) << "Intrinsics & extrinsics not exist";
|
||||
}
|
||||
|
||||
if (imu_params.ok) {
|
||||
imu_params_ = imu_params;
|
||||
SetMotionIntrinsics({imu_params.in_accel, imu_params.in_gyro});
|
||||
SetMotionExtrinsics(Stream::LEFT, imu_params.ex_left_to_imu);
|
||||
VLOG(2) << "Motion intrinsics: {" << GetMotionIntrinsics() << "}";
|
||||
@@ -597,12 +612,25 @@ void Device::ReadAllInfos() {
|
||||
}
|
||||
}
|
||||
|
||||
void Device::ConfigIntrinsics(const Resolution &res) {
|
||||
if (img_params_.ok) {
|
||||
SetIntrinsics(Stream::LEFT, img_params_.in_left_map[res]);
|
||||
SetIntrinsics(Stream::RIGHT, img_params_.in_right_map[res]);
|
||||
VLOG(2) << "Intrinsics left: {" << GetIntrinsics(Stream::LEFT) << "}";
|
||||
VLOG(2) << "Intrinsics right: {" << GetIntrinsics(Stream::RIGHT) << "}";
|
||||
void Device::UpdateStreamIntrinsics(
|
||||
const Capabilities &capability, const StreamRequest &request) {
|
||||
if (capability != GetKeyStreamCapability()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto &¶ms : all_img_params_) {
|
||||
auto &&img_res = params.first;
|
||||
auto &&img_params = params.second;
|
||||
if (img_params.ok && img_res == request.GetResolution()) {
|
||||
SetIntrinsics(Stream::LEFT, img_params.in_left);
|
||||
SetIntrinsics(Stream::RIGHT, img_params.in_right);
|
||||
SetExtrinsics(Stream::LEFT, Stream::RIGHT, img_params.ex_right_to_left);
|
||||
VLOG(2) << "Intrinsics left: {" << GetIntrinsics(Stream::LEFT) << "}";
|
||||
VLOG(2) << "Intrinsics right: {" << GetIntrinsics(Stream::RIGHT) << "}";
|
||||
VLOG(2) << "Extrinsics left to right: {"
|
||||
<< GetExtrinsics(Stream::LEFT, Stream::RIGHT) << "}";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -629,8 +657,4 @@ void Device::CallbackMotionData(const device::MotionData &data) {
|
||||
}
|
||||
}
|
||||
|
||||
Device::img_params_t Device::GetImgParams() {
|
||||
return img_params_;
|
||||
}
|
||||
|
||||
MYNTEYE_END_NAMESPACE
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
MYNTEYE_BEGIN_NAMESPACE
|
||||
|
||||
StandardDevice::StandardDevice(std::shared_ptr<uvc::device> device)
|
||||
: Device(Model::STANDARD, device) {
|
||||
: Device(Model::STANDARD2, device) {
|
||||
VLOG(2) << __func__;
|
||||
}
|
||||
|
||||
@@ -27,6 +27,10 @@ StandardDevice::~StandardDevice() {
|
||||
VLOG(2) << __func__;
|
||||
}
|
||||
|
||||
Capabilities StandardDevice::GetKeyStreamCapability() const {
|
||||
return Capabilities::STEREO_COLOR;
|
||||
}
|
||||
|
||||
std::vector<Stream> StandardDevice::GetKeyStreams() const {
|
||||
return {Stream::LEFT, Stream::RIGHT};
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ class StandardDevice : public Device {
|
||||
explicit StandardDevice(std::shared_ptr<uvc::device> device);
|
||||
virtual ~StandardDevice();
|
||||
|
||||
Capabilities GetKeyStreamCapability() const override;
|
||||
std::vector<Stream> GetKeyStreams() const override;
|
||||
|
||||
void OnStereoStreamUpdate() override;
|
||||
|
||||
@@ -31,14 +31,14 @@ std::shared_ptr<Device> select() {
|
||||
Context context;
|
||||
auto &&devices = context.devices();
|
||||
|
||||
size_t n = devices.size();
|
||||
std::size_t n = devices.size();
|
||||
if (n <= 0) {
|
||||
LOG(ERROR) << "No MYNT EYE devices :(";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
LOG(INFO) << "MYNT EYE devices:";
|
||||
for (size_t i = 0; i < n; i++) {
|
||||
for (std::size_t i = 0; i < n; i++) {
|
||||
auto &&device = devices[i];
|
||||
LOG(INFO) << " index: " << i
|
||||
<< ", name: " << device->GetInfo(Info::DEVICE_NAME)
|
||||
@@ -51,7 +51,7 @@ std::shared_ptr<Device> select() {
|
||||
LOG(INFO) << "Only one MYNT EYE device, select index: 0";
|
||||
} else {
|
||||
while (true) {
|
||||
size_t i;
|
||||
std::size_t i;
|
||||
LOG(INFO) << "There are " << n << " MYNT EYE devices, select index: ";
|
||||
std::cin >> i;
|
||||
if (i >= n) {
|
||||
@@ -66,6 +66,42 @@ std::shared_ptr<Device> select() {
|
||||
return device;
|
||||
}
|
||||
|
||||
MYNTEYE_NAMESPACE::StreamRequest select_request(
|
||||
const std::shared_ptr<Device> &device, bool *ok) {
|
||||
auto &&requests = device->GetStreamRequests();
|
||||
std::size_t n = requests.size();
|
||||
if (n <= 0) {
|
||||
LOG(ERROR) << "No MYNT EYE devices :(";
|
||||
*ok = false;
|
||||
return {};
|
||||
}
|
||||
|
||||
LOG(INFO) << "MYNT EYE devices:";
|
||||
for (std::size_t i = 0; i < n; i++) {
|
||||
auto &&request = requests[i];
|
||||
LOG(INFO) << " index: " << i
|
||||
<< ", request: " << request;
|
||||
}
|
||||
|
||||
if (n <= 1) {
|
||||
LOG(INFO) << "Only one stream request, select index: 0";
|
||||
*ok = true;
|
||||
return requests[0];
|
||||
} else {
|
||||
while (true) {
|
||||
std::size_t i;
|
||||
LOG(INFO) << "There are " << n << " stream requests, select index: ";
|
||||
std::cin >> i;
|
||||
if (i >= n) {
|
||||
LOG(WARNING) << "Index out of range :(";
|
||||
continue;
|
||||
}
|
||||
*ok = true;
|
||||
return requests[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace device
|
||||
|
||||
namespace utils {
|
||||
|
||||
Reference in New Issue
Block a user