refactor(*): change stream request and params interfaces
This commit is contained in:
@@ -218,52 +218,15 @@ API::~API() {
|
||||
VLOG(2) << __func__;
|
||||
}
|
||||
|
||||
std::shared_ptr<API> API::Create(Resolution res) {
|
||||
auto &&device = device::select();
|
||||
if (!device)
|
||||
return nullptr;
|
||||
device->InitResolution(res);
|
||||
return std::make_shared<API>(device);
|
||||
}
|
||||
|
||||
std::shared_ptr<API> API::Create(
|
||||
std::shared_ptr<Device> device, Resolution res) {
|
||||
if (!device)
|
||||
return nullptr;
|
||||
device->InitResolution(res);
|
||||
return std::make_shared<API>(device);
|
||||
}
|
||||
|
||||
// TODO(Kalman): Compatible with two generation
|
||||
std::shared_ptr<API> API::Create(std::shared_ptr<Device> device) {
|
||||
return Create(device, Resolution::RES_2560x800);
|
||||
}
|
||||
|
||||
std::shared_ptr<API> API::Create(int argc, char *argv[]) {
|
||||
auto &&device = device::select();
|
||||
if (!device) return nullptr;
|
||||
return Create(argc, argv, device);
|
||||
}
|
||||
|
||||
// TODO(Kalman): Compatible with two generation
|
||||
std::shared_ptr<API> API::Create(
|
||||
int argc, char *argv[], std::shared_ptr<Device> device) {
|
||||
int argc, char *argv[], const std::shared_ptr<Device> &device) {
|
||||
static glog_init _(argc, argv);
|
||||
int index = 0;
|
||||
if (argc >= 2) {
|
||||
try {
|
||||
index = std::stoi(argv[1]);
|
||||
} catch (...) {
|
||||
LOG(WARNING) << "Unexpected index.";
|
||||
}
|
||||
}
|
||||
if (!device)
|
||||
return nullptr;
|
||||
if (index == 0)
|
||||
device->InitResolution(Resolution::RES_1280x400);
|
||||
else if (index == 1)
|
||||
device->InitResolution(Resolution::RES_2560x800);
|
||||
else
|
||||
device->InitResolution(Resolution::RES_1280x400);
|
||||
return std::make_shared<API>(device);
|
||||
}
|
||||
|
||||
@@ -287,12 +250,8 @@ bool API::Supports(const AddOns &addon) const {
|
||||
return device_->Supports(addon);
|
||||
}
|
||||
|
||||
void API::InitResolution(const Resolution &res) {
|
||||
return device_->InitResolution(res);
|
||||
}
|
||||
|
||||
void API::SetStreamRequest(const Format &format, const FrameRate &rate) {
|
||||
device_->SetStreamRequest(format, rate);
|
||||
StreamRequest API::SelectStreamRequest(bool *ok) const {
|
||||
return device::select_request(device_, ok);
|
||||
}
|
||||
|
||||
const std::vector<StreamRequest> &API::GetStreamRequests(
|
||||
@@ -305,6 +264,27 @@ void API::ConfigStreamRequest(
|
||||
device_->ConfigStreamRequest(capability, request);
|
||||
}
|
||||
|
||||
const StreamRequest &API::GetStreamRequest(
|
||||
const Capabilities &capability) const {
|
||||
return device_->GetStreamRequest(capability);
|
||||
}
|
||||
|
||||
const std::vector<StreamRequest> &API::GetStreamRequests() const {
|
||||
return device_->GetStreamRequests();
|
||||
}
|
||||
|
||||
void API::ConfigStreamRequest(const StreamRequest &request) {
|
||||
device_->ConfigStreamRequest(request);
|
||||
}
|
||||
|
||||
const StreamRequest &API::GetStreamRequest() const {
|
||||
return device_->GetStreamRequest();
|
||||
}
|
||||
|
||||
std::shared_ptr<DeviceInfo> API::GetInfo() const {
|
||||
return device_->GetInfo();
|
||||
}
|
||||
|
||||
std::string API::GetInfo(const Info &info) const {
|
||||
return device_->GetInfo(info);
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ api::StreamData Synthetic::GetStreamData(const Stream &stream) {
|
||||
auto &&mode = GetStreamEnabledMode(stream);
|
||||
if (mode == MODE_NATIVE) {
|
||||
auto &&device = api_->device();
|
||||
return data2api(device->GetLatestStreamData(stream));
|
||||
return data2api(device->GetStreamData(stream));
|
||||
} else if (mode == MODE_SYNTHETIC) {
|
||||
if (stream == Stream::LEFT_RECTIFIED || stream == Stream::RIGHT_RECTIFIED) {
|
||||
static std::shared_ptr<ObjMat2> output = nullptr;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -29,6 +29,7 @@ const char *to_string(const Model &value) {
|
||||
return "Model::" #X;
|
||||
switch (value) {
|
||||
CASE(STANDARD)
|
||||
CASE(STANDARD2)
|
||||
default:
|
||||
CHECK(is_valid(value));
|
||||
return "Model::UNKNOWN";
|
||||
@@ -62,6 +63,7 @@ const char *to_string(const Capabilities &value) {
|
||||
return "Capabilities::" #X;
|
||||
switch (value) {
|
||||
CASE(STEREO)
|
||||
CASE(STEREO_COLOR)
|
||||
CASE(COLOR)
|
||||
CASE(DEPTH)
|
||||
CASE(POINTS)
|
||||
@@ -109,16 +111,16 @@ const char *to_string(const Option &value) {
|
||||
CASE(EXPOSURE_MODE)
|
||||
CASE(MAX_GAIN)
|
||||
CASE(MAX_EXPOSURE_TIME)
|
||||
CASE(MIN_EXPOSURE_TIME)
|
||||
CASE(DESIRED_BRIGHTNESS)
|
||||
CASE(IR_CONTROL)
|
||||
CASE(HDR_MODE)
|
||||
CASE(ZERO_DRIFT_CALIBRATION)
|
||||
CASE(ERASE_CHIP)
|
||||
CASE(MIN_EXPOSURE_TIME)
|
||||
CASE(ACCELEROMETER_RANGE)
|
||||
CASE(GYROSCOPE_RANGE)
|
||||
CASE(ACCELEROMETER_LOW_PASS_FILTER)
|
||||
CASE(GYROSCOPE_LOW_PASS_FILTER)
|
||||
CASE(ZERO_DRIFT_CALIBRATION)
|
||||
CASE(ERASE_CHIP)
|
||||
default:
|
||||
CHECK(is_valid(value));
|
||||
return "Option::UNKNOWN";
|
||||
@@ -160,6 +162,7 @@ const char *to_string(const Format &value) {
|
||||
switch (value) {
|
||||
CASE(GREY)
|
||||
CASE(YUYV)
|
||||
CASE(BGR888)
|
||||
default:
|
||||
return "Format::UNKNOWN";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user