refactor(*): change stream request and params interfaces
This commit is contained in:
parent
098b307260
commit
d2a32e0ec1
|
@ -28,6 +28,8 @@
|
||||||
|
|
||||||
MYNTEYE_BEGIN_NAMESPACE
|
MYNTEYE_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
struct DeviceInfo;
|
||||||
|
|
||||||
class Device;
|
class Device;
|
||||||
class Synthetic;
|
class Synthetic;
|
||||||
|
|
||||||
|
@ -93,25 +95,6 @@ class MYNTEYE_API API {
|
||||||
explicit API(std::shared_ptr<Device> device);
|
explicit API(std::shared_ptr<Device> device);
|
||||||
virtual ~API();
|
virtual ~API();
|
||||||
|
|
||||||
/**
|
|
||||||
* Create the API instance.
|
|
||||||
* @return the API instance.
|
|
||||||
* @note This will call device::select() to select a device.
|
|
||||||
*/
|
|
||||||
static std::shared_ptr<API> Create(Resolution res);
|
|
||||||
/**
|
|
||||||
* Create the API instance.
|
|
||||||
* @param device the selected device.
|
|
||||||
* @return the API instance.
|
|
||||||
*/
|
|
||||||
static std::shared_ptr<API> Create(
|
|
||||||
std::shared_ptr<Device> device, Resolution res);
|
|
||||||
/**
|
|
||||||
* Create the API instance.
|
|
||||||
* @param device the selected device.
|
|
||||||
* @return the API instance.
|
|
||||||
*/
|
|
||||||
static std::shared_ptr<API> Create(std::shared_ptr<Device> device);
|
|
||||||
/**
|
/**
|
||||||
* Create the API instance.
|
* Create the API instance.
|
||||||
* @param argc the arg count.
|
* @param argc the arg count.
|
||||||
|
@ -130,7 +113,7 @@ class MYNTEYE_API API {
|
||||||
* @note This will init glog with args.
|
* @note This will init glog with args.
|
||||||
*/
|
*/
|
||||||
static std::shared_ptr<API> Create(
|
static std::shared_ptr<API> Create(
|
||||||
int argc, char *argv[], std::shared_ptr<Device> device);
|
int argc, char *argv[], const std::shared_ptr<Device> &device);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the model.
|
* Get the model.
|
||||||
|
@ -155,9 +138,10 @@ class MYNTEYE_API API {
|
||||||
bool Supports(const AddOns &addon) const;
|
bool Supports(const AddOns &addon) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set the stream request.
|
* Log all stream requests and prompt user to select one.
|
||||||
*/
|
*/
|
||||||
void SetStreamRequest(const Format &format, const FrameRate &rate);
|
StreamRequest SelectStreamRequest(bool *ok) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all stream requests of the capability.
|
* Get all stream requests of the capability.
|
||||||
*/
|
*/
|
||||||
|
@ -168,7 +152,28 @@ class MYNTEYE_API API {
|
||||||
*/
|
*/
|
||||||
void ConfigStreamRequest(
|
void ConfigStreamRequest(
|
||||||
const Capabilities &capability, const StreamRequest &request);
|
const Capabilities &capability, const StreamRequest &request);
|
||||||
|
/**
|
||||||
|
* Get the config stream requests of the capability.
|
||||||
|
*/
|
||||||
|
const StreamRequest &GetStreamRequest(const Capabilities &capability) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all stream requests of the key stream capability.
|
||||||
|
*/
|
||||||
|
const std::vector<StreamRequest> &GetStreamRequests() const;
|
||||||
|
/**
|
||||||
|
* Config the stream request to the key stream capability.
|
||||||
|
*/
|
||||||
|
void ConfigStreamRequest(const StreamRequest &request);
|
||||||
|
/**
|
||||||
|
* Get the config stream requests of the key stream capability.
|
||||||
|
*/
|
||||||
|
const StreamRequest &GetStreamRequest() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the device info.
|
||||||
|
*/
|
||||||
|
std::shared_ptr<DeviceInfo> GetInfo() const;
|
||||||
/**
|
/**
|
||||||
* Get the device info.
|
* Get the device info.
|
||||||
*/
|
*/
|
||||||
|
@ -214,11 +219,6 @@ class MYNTEYE_API API {
|
||||||
*/
|
*/
|
||||||
bool RunOptionAction(const Option &option) const;
|
bool RunOptionAction(const Option &option) const;
|
||||||
|
|
||||||
/**
|
|
||||||
* Init device resolution.
|
|
||||||
*/
|
|
||||||
void InitResolution(const Resolution &res);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the callback of stream.
|
* Set the callback of stream.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -32,8 +32,8 @@ namespace device {
|
||||||
|
|
||||||
typedef struct ImgParams {
|
typedef struct ImgParams {
|
||||||
bool ok;
|
bool ok;
|
||||||
std::map<Resolution, Intrinsics> in_left_map;
|
Intrinsics in_left;
|
||||||
std::map<Resolution, Intrinsics> in_right_map;
|
Intrinsics in_right;
|
||||||
Extrinsics ex_right_to_left;
|
Extrinsics ex_right_to_left;
|
||||||
} img_params_t;
|
} img_params_t;
|
||||||
|
|
||||||
|
|
|
@ -104,14 +104,7 @@ class MYNTEYE_API Device {
|
||||||
* Supports the addon or not.
|
* Supports the addon or not.
|
||||||
*/
|
*/
|
||||||
bool Supports(const AddOns &addon) const;
|
bool Supports(const AddOns &addon) const;
|
||||||
/**
|
|
||||||
* Init device resolution.
|
|
||||||
*/
|
|
||||||
void InitResolution(const Resolution &res);
|
|
||||||
/**
|
|
||||||
* set the stream request.
|
|
||||||
*/
|
|
||||||
void SetStreamRequest(const Format &format, const FrameRate &rate);
|
|
||||||
/**
|
/**
|
||||||
* Get all stream requests of the capability.
|
* Get all stream requests of the capability.
|
||||||
*/
|
*/
|
||||||
|
@ -122,6 +115,23 @@ class MYNTEYE_API Device {
|
||||||
*/
|
*/
|
||||||
void ConfigStreamRequest(
|
void ConfigStreamRequest(
|
||||||
const Capabilities &capability, const StreamRequest &request);
|
const Capabilities &capability, const StreamRequest &request);
|
||||||
|
/**
|
||||||
|
* Get the config stream requests of the capability.
|
||||||
|
*/
|
||||||
|
const StreamRequest &GetStreamRequest(const Capabilities &capability) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all stream requests of the key stream capability.
|
||||||
|
*/
|
||||||
|
const std::vector<StreamRequest> &GetStreamRequests() const;
|
||||||
|
/**
|
||||||
|
* Config the stream request to the key stream capability.
|
||||||
|
*/
|
||||||
|
void ConfigStreamRequest(const StreamRequest &request);
|
||||||
|
/**
|
||||||
|
* Get the config stream requests of the key stream capability.
|
||||||
|
*/
|
||||||
|
const StreamRequest &GetStreamRequest() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the device info.
|
* Get the device info.
|
||||||
|
@ -241,15 +251,15 @@ class MYNTEYE_API Device {
|
||||||
*/
|
*/
|
||||||
void WaitForStreams();
|
void WaitForStreams();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the latest data of stream.
|
||||||
|
*/
|
||||||
|
device::StreamData GetStreamData(const Stream &stream);
|
||||||
/**
|
/**
|
||||||
* Get the datas of stream.
|
* Get the datas of stream.
|
||||||
* @note default cache 4 datas at most.
|
* @note default cache 4 datas at most.
|
||||||
*/
|
*/
|
||||||
std::vector<device::StreamData> GetStreamDatas(const Stream &stream);
|
std::vector<device::StreamData> GetStreamDatas(const Stream &stream);
|
||||||
/**
|
|
||||||
* Get the latest data of stream.
|
|
||||||
*/
|
|
||||||
device::StreamData GetLatestStreamData(const Stream &stream);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable cache motion datas.
|
* Enable cache motion datas.
|
||||||
|
@ -263,10 +273,6 @@ class MYNTEYE_API Device {
|
||||||
* Get the motion datas.
|
* Get the motion datas.
|
||||||
*/
|
*/
|
||||||
std::vector<device::MotionData> GetMotionDatas();
|
std::vector<device::MotionData> GetMotionDatas();
|
||||||
/**
|
|
||||||
* Get the device img params
|
|
||||||
*/
|
|
||||||
img_params_t GetImgParams();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::shared_ptr<uvc::device> device() const {
|
std::shared_ptr<uvc::device> device() const {
|
||||||
|
@ -285,8 +291,6 @@ class MYNTEYE_API Device {
|
||||||
return motions_;
|
return motions_;
|
||||||
}
|
}
|
||||||
|
|
||||||
const StreamRequest &GetStreamRequest(const Capabilities &capability);
|
|
||||||
|
|
||||||
virtual void StartVideoStreaming();
|
virtual void StartVideoStreaming();
|
||||||
virtual void StopVideoStreaming();
|
virtual void StopVideoStreaming();
|
||||||
|
|
||||||
|
@ -295,25 +299,33 @@ class MYNTEYE_API Device {
|
||||||
|
|
||||||
virtual void OnStereoStreamUpdate();
|
virtual void OnStereoStreamUpdate();
|
||||||
|
|
||||||
|
virtual Capabilities GetKeyStreamCapability() const = 0;
|
||||||
virtual std::vector<Stream> GetKeyStreams() const = 0;
|
virtual std::vector<Stream> GetKeyStreams() const = 0;
|
||||||
|
|
||||||
|
std::map<Resolution, device::img_params_t> GetImgParams() const {
|
||||||
|
return all_img_params_;
|
||||||
|
}
|
||||||
|
device::imu_params_t GetImuParams() const {
|
||||||
|
return imu_params_;
|
||||||
|
}
|
||||||
|
|
||||||
bool video_streaming_;
|
bool video_streaming_;
|
||||||
bool motion_tracking_;
|
bool motion_tracking_;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Model model_;
|
Model model_;
|
||||||
Resolution res_ = Resolution::RES_752x480;
|
|
||||||
StreamRequest request_;
|
|
||||||
std::shared_ptr<uvc::device> device_;
|
std::shared_ptr<uvc::device> device_;
|
||||||
std::shared_ptr<DeviceInfo> device_info_;
|
std::shared_ptr<DeviceInfo> device_info_;
|
||||||
|
|
||||||
|
std::map<Resolution, device::img_params_t> all_img_params_;
|
||||||
|
device::imu_params_t imu_params_;
|
||||||
|
|
||||||
std::map<Stream, Intrinsics> stream_intrinsics_;
|
std::map<Stream, Intrinsics> stream_intrinsics_;
|
||||||
std::map<Stream, std::map<Stream, Extrinsics>> stream_from_extrinsics_;
|
std::map<Stream, std::map<Stream, Extrinsics>> stream_from_extrinsics_;
|
||||||
|
|
||||||
std::shared_ptr<MotionIntrinsics> motion_intrinsics_;
|
std::shared_ptr<MotionIntrinsics> motion_intrinsics_;
|
||||||
std::map<Stream, Extrinsics> motion_from_extrinsics_;
|
std::map<Stream, Extrinsics> motion_from_extrinsics_;
|
||||||
|
|
||||||
img_params_t img_params_;
|
|
||||||
stream_callbacks_t stream_callbacks_;
|
stream_callbacks_t stream_callbacks_;
|
||||||
motion_callback_t motion_callback_;
|
motion_callback_t motion_callback_;
|
||||||
|
|
||||||
|
@ -331,8 +343,8 @@ class MYNTEYE_API Device {
|
||||||
std::shared_ptr<Motions> motions_;
|
std::shared_ptr<Motions> motions_;
|
||||||
|
|
||||||
void ReadAllInfos();
|
void ReadAllInfos();
|
||||||
|
void UpdateStreamIntrinsics(
|
||||||
void ConfigIntrinsics(const Resolution &res);
|
const Capabilities &capability, const StreamRequest &request);
|
||||||
|
|
||||||
void CallbackPushedStreamData(const Stream &stream);
|
void CallbackPushedStreamData(const Stream &stream);
|
||||||
void CallbackMotionData(const device::MotionData &data);
|
void CallbackMotionData(const device::MotionData &data);
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "mynteye/mynteye.h"
|
#include "mynteye/mynteye.h"
|
||||||
|
#include "mynteye/types.h"
|
||||||
|
|
||||||
MYNTEYE_BEGIN_NAMESPACE
|
MYNTEYE_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
@ -39,6 +40,16 @@ namespace device {
|
||||||
*/
|
*/
|
||||||
MYNTEYE_API std::shared_ptr<Device> select();
|
MYNTEYE_API std::shared_ptr<Device> select();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup utils
|
||||||
|
*
|
||||||
|
* List stream requests and prompt user to select one.
|
||||||
|
*
|
||||||
|
* @return the selected request.
|
||||||
|
*/
|
||||||
|
MYNTEYE_API MYNTEYE_NAMESPACE::StreamRequest select_request(
|
||||||
|
const std::shared_ptr<Device> &device, bool *ok);
|
||||||
|
|
||||||
} // namespace device
|
} // namespace device
|
||||||
|
|
||||||
namespace utils {
|
namespace utils {
|
||||||
|
|
|
@ -37,6 +37,8 @@ MYNTEYE_BEGIN_NAMESPACE
|
||||||
enum class Model : std::uint8_t {
|
enum class Model : std::uint8_t {
|
||||||
/** Standard */
|
/** Standard */
|
||||||
STANDARD,
|
STANDARD,
|
||||||
|
/** Standard 2 */
|
||||||
|
STANDARD2,
|
||||||
/** Last guard */
|
/** Last guard */
|
||||||
LAST
|
LAST
|
||||||
};
|
};
|
||||||
|
@ -74,10 +76,10 @@ enum class Stream : std::uint8_t {
|
||||||
enum class Capabilities : std::uint8_t {
|
enum class Capabilities : std::uint8_t {
|
||||||
/** Provides stereo stream */
|
/** Provides stereo stream */
|
||||||
STEREO,
|
STEREO,
|
||||||
/** Provides color stream */
|
|
||||||
COLOR,
|
|
||||||
/** Provide stereo color stream */
|
/** Provide stereo color stream */
|
||||||
STEREO_COLOR,
|
STEREO_COLOR,
|
||||||
|
/** Provides color stream */
|
||||||
|
COLOR,
|
||||||
/** Provides depth stream */
|
/** Provides depth stream */
|
||||||
DEPTH,
|
DEPTH,
|
||||||
/** Provides point cloud stream */
|
/** Provides point cloud stream */
|
||||||
|
@ -143,6 +145,7 @@ enum class Option : std::uint8_t {
|
||||||
* range: [0,255], default: 127
|
* range: [0,255], default: 127
|
||||||
*/
|
*/
|
||||||
CONTRAST,
|
CONTRAST,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Image frame rate, must set IMU_FREQUENCY together
|
* Image frame rate, must set IMU_FREQUENCY together
|
||||||
*
|
*
|
||||||
|
@ -155,6 +158,7 @@ enum class Option : std::uint8_t {
|
||||||
* values: {100,200,250,333,500}, default: 200
|
* values: {100,200,250,333,500}, default: 200
|
||||||
*/
|
*/
|
||||||
IMU_FREQUENCY,
|
IMU_FREQUENCY,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exposure mode
|
* Exposure mode
|
||||||
*
|
*
|
||||||
|
@ -174,12 +178,19 @@ enum class Option : std::uint8_t {
|
||||||
* range: [0,1000], default: 333
|
* range: [0,1000], default: 333
|
||||||
*/
|
*/
|
||||||
MAX_EXPOSURE_TIME,
|
MAX_EXPOSURE_TIME,
|
||||||
|
/**
|
||||||
|
* min exposure time, valid if auto-exposure
|
||||||
|
*
|
||||||
|
* range: [0,1000], default: 0
|
||||||
|
*/
|
||||||
|
MIN_EXPOSURE_TIME,
|
||||||
/**
|
/**
|
||||||
* Desired brightness, valid if auto-exposure
|
* Desired brightness, valid if auto-exposure
|
||||||
*
|
*
|
||||||
* range: [1,255], default: 122
|
* range: [1,255], default: 122
|
||||||
*/
|
*/
|
||||||
DESIRED_BRIGHTNESS,
|
DESIRED_BRIGHTNESS,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* IR control
|
* IR control
|
||||||
*
|
*
|
||||||
|
@ -193,16 +204,7 @@ enum class Option : std::uint8_t {
|
||||||
* 1: 12-bit
|
* 1: 12-bit
|
||||||
*/
|
*/
|
||||||
HDR_MODE,
|
HDR_MODE,
|
||||||
/** Zero drift calibration */
|
|
||||||
ZERO_DRIFT_CALIBRATION,
|
|
||||||
/** Erase chip */
|
|
||||||
ERASE_CHIP,
|
|
||||||
/**
|
|
||||||
* min exposure time, valid if auto-exposure
|
|
||||||
*
|
|
||||||
* range: [0,1000], default: 0
|
|
||||||
*/
|
|
||||||
MIN_EXPOSURE_TIME,
|
|
||||||
/**
|
/**
|
||||||
* The range of accelerometer
|
* The range of accelerometer
|
||||||
*
|
*
|
||||||
|
@ -227,6 +229,12 @@ enum class Option : std::uint8_t {
|
||||||
* values: {23,64}, default: 64
|
* values: {23,64}, default: 64
|
||||||
*/
|
*/
|
||||||
GYROSCOPE_LOW_PASS_FILTER,
|
GYROSCOPE_LOW_PASS_FILTER,
|
||||||
|
|
||||||
|
/** Zero drift calibration */
|
||||||
|
ZERO_DRIFT_CALIBRATION,
|
||||||
|
/** Erase chip */
|
||||||
|
ERASE_CHIP,
|
||||||
|
|
||||||
/** Last guard */
|
/** Last guard */
|
||||||
LAST
|
LAST
|
||||||
};
|
};
|
||||||
|
@ -259,40 +267,6 @@ enum class AddOns : std::uint8_t {
|
||||||
LAST
|
LAST
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* @ingroup enumerations
|
|
||||||
* @brief Camera supported resolution.
|
|
||||||
*/
|
|
||||||
enum class Resolution : std::uint8_t {
|
|
||||||
/** 752x480 */
|
|
||||||
RES_752x480,
|
|
||||||
/** 1280x400 */
|
|
||||||
RES_1280x400,
|
|
||||||
/** 2560x800 */
|
|
||||||
RES_2560x800,
|
|
||||||
/** Last guard */
|
|
||||||
LAST
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ingroup enumerations
|
|
||||||
* @brief Camera supported frame rate.
|
|
||||||
*/
|
|
||||||
enum class FrameRate : std::uint8_t {
|
|
||||||
/** 10 fps */
|
|
||||||
RATE_10_FPS = 10,
|
|
||||||
/** 20 fps */
|
|
||||||
RATE_20_FPS = 20,
|
|
||||||
/** 20 fps */
|
|
||||||
RATE_25_FPS = 25,
|
|
||||||
/** 30 fps */
|
|
||||||
RATE_30_FPS = 30,
|
|
||||||
/** 60 fps */
|
|
||||||
RATE_60_FPS = 60,
|
|
||||||
/** Last guard */
|
|
||||||
LAST
|
|
||||||
};
|
|
||||||
|
|
||||||
#define MYNTEYE_ENUM_HELPERS(TYPE) \
|
#define MYNTEYE_ENUM_HELPERS(TYPE) \
|
||||||
MYNTEYE_API const char *to_string(const TYPE &value); \
|
MYNTEYE_API const char *to_string(const TYPE &value); \
|
||||||
inline bool is_valid(const TYPE &value) { \
|
inline bool is_valid(const TYPE &value) { \
|
||||||
|
@ -316,8 +290,6 @@ MYNTEYE_ENUM_HELPERS(Info)
|
||||||
MYNTEYE_ENUM_HELPERS(Option)
|
MYNTEYE_ENUM_HELPERS(Option)
|
||||||
MYNTEYE_ENUM_HELPERS(Source)
|
MYNTEYE_ENUM_HELPERS(Source)
|
||||||
MYNTEYE_ENUM_HELPERS(AddOns)
|
MYNTEYE_ENUM_HELPERS(AddOns)
|
||||||
MYNTEYE_ENUM_HELPERS(Resolution)
|
|
||||||
MYNTEYE_ENUM_HELPERS(FrameRate)
|
|
||||||
|
|
||||||
#undef MYNTEYE_ENUM_HELPERS
|
#undef MYNTEYE_ENUM_HELPERS
|
||||||
|
|
||||||
|
@ -350,6 +322,26 @@ inline std::ostream &operator<<(std::ostream &os, const Format &value) {
|
||||||
|
|
||||||
MYNTEYE_API std::size_t bytes_per_pixel(const Format &value);
|
MYNTEYE_API std::size_t bytes_per_pixel(const Format &value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resolution.
|
||||||
|
*/
|
||||||
|
struct MYNTEYE_API Resolution {
|
||||||
|
/** Width */
|
||||||
|
std::uint16_t width;
|
||||||
|
/** Height */
|
||||||
|
std::uint16_t height;
|
||||||
|
|
||||||
|
bool operator==(const Resolution &other) const {
|
||||||
|
return width == other.width && height == other.height;
|
||||||
|
}
|
||||||
|
bool operator!=(const Resolution &other) const {
|
||||||
|
return !(*this == other);
|
||||||
|
}
|
||||||
|
bool operator<(const Resolution &other) const {
|
||||||
|
return (width * height) < (other.width * other.height);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stream request.
|
* Stream request.
|
||||||
*/
|
*/
|
||||||
|
@ -370,25 +362,10 @@ struct MYNTEYE_API StreamRequest {
|
||||||
std::uint16_t fps)
|
std::uint16_t fps)
|
||||||
: width(width), height(height), format(format), fps(fps) {}
|
: width(width), height(height), format(format), fps(fps) {}
|
||||||
|
|
||||||
StreamRequest(Resolution res, Format format, FrameRate rate)
|
StreamRequest(const Resolution &res, Format format, std::uint16_t fps)
|
||||||
: format(format) {
|
: width(res.width), height(res.height), format(format), fps(fps) {}
|
||||||
fps = static_cast<uint16_t>(rate);
|
|
||||||
|
|
||||||
switch (res) {
|
Resolution GetResolution() const { return {width, height}; }
|
||||||
case Resolution::RES_752x480:
|
|
||||||
width = 480, height = 752;
|
|
||||||
break;
|
|
||||||
case Resolution::RES_1280x400:
|
|
||||||
width = 1280, height = 400;
|
|
||||||
break;
|
|
||||||
case Resolution::RES_2560x800:
|
|
||||||
width = 2560, height = 800;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
width = 480, height = 752;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator==(const StreamRequest &other) const {
|
bool operator==(const StreamRequest &other) const {
|
||||||
return width == other.width && height == other.height &&
|
return width == other.width && height == other.height &&
|
||||||
|
|
|
@ -21,9 +21,13 @@ MYNTEYE_USE_NAMESPACE
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
auto &&api = API::Create(argc, argv);
|
auto &&api = API::Create(argc, argv);
|
||||||
if (!api)
|
if (!api) return 1;
|
||||||
return 1;
|
|
||||||
api->SetStreamRequest(Format::BGR888, FrameRate::RATE_30_FPS);
|
bool ok;
|
||||||
|
auto &&request = api->SelectStreamRequest(&ok);
|
||||||
|
if (!ok) return 1;
|
||||||
|
api->ConfigStreamRequest(request);
|
||||||
|
|
||||||
api->LogOptionInfos();
|
api->LogOptionInfos();
|
||||||
|
|
||||||
std::size_t left_count = 0;
|
std::size_t left_count = 0;
|
||||||
|
|
|
@ -144,8 +144,12 @@ MYNTEYE_USE_NAMESPACE
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
auto &&api = API::Create(argc, argv);
|
auto &&api = API::Create(argc, argv);
|
||||||
if (!api)
|
if (!api) return 1;
|
||||||
return 1;
|
|
||||||
|
bool ok;
|
||||||
|
auto &&request = api->SelectStreamRequest(&ok);
|
||||||
|
if (!ok) return 1;
|
||||||
|
api->ConfigStreamRequest(request);
|
||||||
|
|
||||||
api->SetOptionValue(Option::IR_CONTROL, 80);
|
api->SetOptionValue(Option::IR_CONTROL, 80);
|
||||||
|
|
||||||
|
|
|
@ -25,12 +25,14 @@ int main(int argc, char *argv[]) {
|
||||||
glog_init _(argc, argv);
|
glog_init _(argc, argv);
|
||||||
|
|
||||||
auto &&device = device::select();
|
auto &&device = device::select();
|
||||||
if (!device)
|
if (!device) return 1;
|
||||||
return 1;
|
|
||||||
|
bool ok;
|
||||||
|
auto &&request = device::select_request(device, &ok);
|
||||||
|
if (!ok) return 1;
|
||||||
|
device->ConfigStreamRequest(request);
|
||||||
|
|
||||||
std::size_t left_count = 0;
|
std::size_t left_count = 0;
|
||||||
device->InitResolution(Resolution::RES_1280x400);
|
|
||||||
device->SetStreamRequest(Format::BGR888, FrameRate::RATE_30_FPS);
|
|
||||||
device->SetStreamCallback(
|
device->SetStreamCallback(
|
||||||
Stream::LEFT, [&left_count](const device::StreamData &data) {
|
Stream::LEFT, [&left_count](const device::StreamData &data) {
|
||||||
CHECK_NOTNULL(data.img);
|
CHECK_NOTNULL(data.img);
|
||||||
|
@ -77,8 +79,8 @@ int main(int argc, char *argv[]) {
|
||||||
while (true) {
|
while (true) {
|
||||||
device->WaitForStreams();
|
device->WaitForStreams();
|
||||||
|
|
||||||
device::StreamData left_data = device->GetLatestStreamData(Stream::LEFT);
|
device::StreamData left_data = device->GetStreamData(Stream::LEFT);
|
||||||
device::StreamData right_data = device->GetLatestStreamData(Stream::RIGHT);
|
device::StreamData right_data = device->GetStreamData(Stream::RIGHT);
|
||||||
|
|
||||||
auto &&motion_datas = device->GetMotionDatas();
|
auto &&motion_datas = device->GetMotionDatas();
|
||||||
motion_count += motion_datas.size();
|
motion_count += motion_datas.size();
|
||||||
|
|
|
@ -22,9 +22,12 @@ MYNTEYE_USE_NAMESPACE
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
auto &&api = API::Create(argc, argv);
|
auto &&api = API::Create(argc, argv);
|
||||||
if (!api)
|
if (!api) return 1;
|
||||||
return 1;
|
|
||||||
api->SetStreamRequest(Format::BGR888, FrameRate::RATE_30_FPS);
|
bool ok;
|
||||||
|
auto &&request = api->SelectStreamRequest(&ok);
|
||||||
|
if (!ok) return 1;
|
||||||
|
api->ConfigStreamRequest(request);
|
||||||
|
|
||||||
// auto-exposure: 0
|
// auto-exposure: 0
|
||||||
api->SetOptionValue(Option::EXPOSURE_MODE, 0);
|
api->SetOptionValue(Option::EXPOSURE_MODE, 0);
|
||||||
|
|
|
@ -22,11 +22,14 @@
|
||||||
MYNTEYE_USE_NAMESPACE
|
MYNTEYE_USE_NAMESPACE
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
auto &&api = API::Create(Resolution::RES_1280x400);
|
auto &&api = API::Create(argc, argv);
|
||||||
// auto &&api = API::Create(argc, argv);
|
if (!api) return 1;
|
||||||
if (!api)
|
|
||||||
return 1;
|
bool ok;
|
||||||
api->SetStreamRequest(Format::BGR888, FrameRate::RATE_30_FPS);
|
auto &&request = api->SelectStreamRequest(&ok);
|
||||||
|
if (!ok) return 1;
|
||||||
|
api->ConfigStreamRequest(request);
|
||||||
|
|
||||||
// Count img
|
// Count img
|
||||||
std::atomic_uint img_count(0);
|
std::atomic_uint img_count(0);
|
||||||
api->SetStreamCallback(
|
api->SetStreamCallback(
|
||||||
|
|
|
@ -23,8 +23,12 @@ MYNTEYE_USE_NAMESPACE
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
auto &&api = API::Create(argc, argv);
|
auto &&api = API::Create(argc, argv);
|
||||||
if (!api)
|
if (!api) return 1;
|
||||||
return 1;
|
|
||||||
|
bool ok;
|
||||||
|
auto &&request = api->SelectStreamRequest(&ok);
|
||||||
|
if (!ok) return 1;
|
||||||
|
api->ConfigStreamRequest(request);
|
||||||
|
|
||||||
// ACCELEROMETER_RANGE values: 6, 12, 24, 32
|
// ACCELEROMETER_RANGE values: 6, 12, 24, 32
|
||||||
api->SetOptionValue(Option::ACCELEROMETER_RANGE, 6);
|
api->SetOptionValue(Option::ACCELEROMETER_RANGE, 6);
|
||||||
|
|
|
@ -22,9 +22,12 @@ MYNTEYE_USE_NAMESPACE
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
auto &&api = API::Create(argc, argv);
|
auto &&api = API::Create(argc, argv);
|
||||||
if (!api)
|
if (!api) return 1;
|
||||||
return 1;
|
|
||||||
api->SetStreamRequest(Format::BGR888, FrameRate::RATE_30_FPS);
|
bool ok;
|
||||||
|
auto &&request = api->SelectStreamRequest(&ok);
|
||||||
|
if (!ok) return 1;
|
||||||
|
api->ConfigStreamRequest(request);
|
||||||
|
|
||||||
// manual-exposure: 1
|
// manual-exposure: 1
|
||||||
api->SetOptionValue(Option::EXPOSURE_MODE, 1);
|
api->SetOptionValue(Option::EXPOSURE_MODE, 1);
|
||||||
|
|
|
@ -19,8 +19,12 @@ MYNTEYE_USE_NAMESPACE
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
auto &&api = API::Create(argc, argv);
|
auto &&api = API::Create(argc, argv);
|
||||||
if (!api)
|
if (!api) return 1;
|
||||||
return 1;
|
|
||||||
|
bool ok;
|
||||||
|
auto &&request = api->SelectStreamRequest(&ok);
|
||||||
|
if (!ok) return 1;
|
||||||
|
api->ConfigStreamRequest(request);
|
||||||
|
|
||||||
api->EnableStreamData(Stream::DEPTH);
|
api->EnableStreamData(Stream::DEPTH);
|
||||||
|
|
||||||
|
|
|
@ -18,8 +18,7 @@ MYNTEYE_USE_NAMESPACE
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
auto &&api = API::Create(argc, argv);
|
auto &&api = API::Create(argc, argv);
|
||||||
if (!api)
|
if (!api) return 1;
|
||||||
return 1;
|
|
||||||
|
|
||||||
LOG(INFO) << "Device name: " << api->GetInfo(Info::DEVICE_NAME);
|
LOG(INFO) << "Device name: " << api->GetInfo(Info::DEVICE_NAME);
|
||||||
LOG(INFO) << "Serial number: " << api->GetInfo(Info::SERIAL_NUMBER);
|
LOG(INFO) << "Serial number: " << api->GetInfo(Info::SERIAL_NUMBER);
|
||||||
|
|
|
@ -19,8 +19,12 @@ MYNTEYE_USE_NAMESPACE
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
auto &&api = API::Create(argc, argv);
|
auto &&api = API::Create(argc, argv);
|
||||||
if (!api)
|
if (!api) return 1;
|
||||||
return 1;
|
|
||||||
|
bool ok;
|
||||||
|
auto &&request = api->SelectStreamRequest(&ok);
|
||||||
|
if (!ok) return 1;
|
||||||
|
api->ConfigStreamRequest(request);
|
||||||
|
|
||||||
// api->EnableStreamData(Stream::DISPARITY);
|
// api->EnableStreamData(Stream::DISPARITY);
|
||||||
api->EnableStreamData(Stream::DISPARITY_NORMALIZED);
|
api->EnableStreamData(Stream::DISPARITY_NORMALIZED);
|
||||||
|
|
|
@ -27,8 +27,12 @@ MYNTEYE_USE_NAMESPACE
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
auto &&api = API::Create(argc, argv);
|
auto &&api = API::Create(argc, argv);
|
||||||
if (!api)
|
if (!api) return 1;
|
||||||
return 1;
|
|
||||||
|
bool ok;
|
||||||
|
auto &&request = api->SelectStreamRequest(&ok);
|
||||||
|
if (!ok) return 1;
|
||||||
|
api->ConfigStreamRequest(request);
|
||||||
|
|
||||||
// Attention: must not block the callbacks.
|
// Attention: must not block the callbacks.
|
||||||
|
|
||||||
|
|
|
@ -18,9 +18,13 @@ MYNTEYE_USE_NAMESPACE
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
auto &&api = API::Create(argc, argv);
|
auto &&api = API::Create(argc, argv);
|
||||||
if (!api)
|
if (!api) return 1;
|
||||||
return 1;
|
|
||||||
api->SetStreamRequest(Format::BGR888, FrameRate::RATE_30_FPS);
|
bool ok;
|
||||||
|
auto &&request = api->SelectStreamRequest(&ok);
|
||||||
|
if (!ok) return 1;
|
||||||
|
api->ConfigStreamRequest(request);
|
||||||
|
|
||||||
LOG(INFO) << "Intrinsics left: {" << api->GetIntrinsics(Stream::LEFT) << "}";
|
LOG(INFO) << "Intrinsics left: {" << api->GetIntrinsics(Stream::LEFT) << "}";
|
||||||
LOG(INFO) << "Intrinsics right: {" << api->GetIntrinsics(Stream::RIGHT)
|
LOG(INFO) << "Intrinsics right: {" << api->GetIntrinsics(Stream::RIGHT)
|
||||||
<< "}";
|
<< "}";
|
||||||
|
|
|
@ -22,8 +22,12 @@ MYNTEYE_USE_NAMESPACE
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
auto &&api = API::Create(argc, argv);
|
auto &&api = API::Create(argc, argv);
|
||||||
if (!api)
|
if (!api) return 1;
|
||||||
return 1;
|
|
||||||
|
bool ok;
|
||||||
|
auto &&request = api->SelectStreamRequest(&ok);
|
||||||
|
if (!ok) return 1;
|
||||||
|
api->ConfigStreamRequest(request);
|
||||||
|
|
||||||
// Enable this will cache the motion datas until you get them.
|
// Enable this will cache the motion datas until you get them.
|
||||||
api->EnableMotionDatas();
|
api->EnableMotionDatas();
|
||||||
|
|
|
@ -18,8 +18,7 @@ MYNTEYE_USE_NAMESPACE
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
auto &&api = API::Create(argc, argv);
|
auto &&api = API::Create(argc, argv);
|
||||||
if (!api)
|
if (!api) return 1;
|
||||||
return 1;
|
|
||||||
|
|
||||||
LOG(INFO) << "Motion intrinsics: {" << api->GetMotionIntrinsics() << "}";
|
LOG(INFO) << "Motion intrinsics: {" << api->GetMotionIntrinsics() << "}";
|
||||||
LOG(INFO) << "Motion extrinsics left to imu: {"
|
LOG(INFO) << "Motion extrinsics left to imu: {"
|
||||||
|
|
|
@ -21,8 +21,12 @@ MYNTEYE_USE_NAMESPACE
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
auto &&api = API::Create(argc, argv);
|
auto &&api = API::Create(argc, argv);
|
||||||
if (!api)
|
if (!api) return 1;
|
||||||
return 1;
|
|
||||||
|
bool ok;
|
||||||
|
auto &&request = api->SelectStreamRequest(&ok);
|
||||||
|
if (!ok) return 1;
|
||||||
|
api->ConfigStreamRequest(request);
|
||||||
|
|
||||||
api->EnableStreamData(Stream::POINTS);
|
api->EnableStreamData(Stream::POINTS);
|
||||||
|
|
||||||
|
|
|
@ -19,8 +19,12 @@ MYNTEYE_USE_NAMESPACE
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
auto &&api = API::Create(argc, argv);
|
auto &&api = API::Create(argc, argv);
|
||||||
if (!api)
|
if (!api) return 1;
|
||||||
return 1;
|
|
||||||
|
bool ok;
|
||||||
|
auto &&request = api->SelectStreamRequest(&ok);
|
||||||
|
if (!ok) return 1;
|
||||||
|
api->ConfigStreamRequest(request);
|
||||||
|
|
||||||
api->Start(Source::VIDEO_STREAMING);
|
api->Start(Source::VIDEO_STREAMING);
|
||||||
|
|
||||||
|
|
|
@ -19,8 +19,12 @@ MYNTEYE_USE_NAMESPACE
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
auto &&api = API::Create(argc, argv);
|
auto &&api = API::Create(argc, argv);
|
||||||
if (!api)
|
if (!api) return 1;
|
||||||
return 1;
|
|
||||||
|
bool ok;
|
||||||
|
auto &&request = api->SelectStreamRequest(&ok);
|
||||||
|
if (!ok) return 1;
|
||||||
|
api->ConfigStreamRequest(request);
|
||||||
|
|
||||||
api->EnableStreamData(Stream::LEFT_RECTIFIED);
|
api->EnableStreamData(Stream::LEFT_RECTIFIED);
|
||||||
api->EnableStreamData(Stream::RIGHT_RECTIFIED);
|
api->EnableStreamData(Stream::RIGHT_RECTIFIED);
|
||||||
|
|
|
@ -19,8 +19,12 @@ MYNTEYE_USE_NAMESPACE
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
auto &&api = API::Create(argc, argv);
|
auto &&api = API::Create(argc, argv);
|
||||||
if (!api)
|
if (!api) return 1;
|
||||||
return 1;
|
|
||||||
|
bool ok;
|
||||||
|
auto &&request = api->SelectStreamRequest(&ok);
|
||||||
|
if (!ok) return 1;
|
||||||
|
api->ConfigStreamRequest(request);
|
||||||
|
|
||||||
api->EnablePlugin("plugins/linux-x86_64/libplugin_g_cuda9.1_opencv3.4.0.so");
|
api->EnablePlugin("plugins/linux-x86_64/libplugin_g_cuda9.1_opencv3.4.0.so");
|
||||||
|
|
||||||
|
|
|
@ -148,8 +148,12 @@ MYNTEYE_USE_NAMESPACE
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
auto &&api = API::Create(argc, argv);
|
auto &&api = API::Create(argc, argv);
|
||||||
if (!api)
|
if (!api) return 1;
|
||||||
return 1;
|
|
||||||
|
bool ok;
|
||||||
|
auto &&request = api->SelectStreamRequest(&ok);
|
||||||
|
if (!ok) return 1;
|
||||||
|
api->ConfigStreamRequest(request);
|
||||||
|
|
||||||
api->SetOptionValue(Option::IR_CONTROL, 80);
|
api->SetOptionValue(Option::IR_CONTROL, 80);
|
||||||
|
|
||||||
|
|
|
@ -218,52 +218,15 @@ API::~API() {
|
||||||
VLOG(2) << __func__;
|
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[]) {
|
std::shared_ptr<API> API::Create(int argc, char *argv[]) {
|
||||||
auto &&device = device::select();
|
auto &&device = device::select();
|
||||||
|
if (!device) return nullptr;
|
||||||
return Create(argc, argv, device);
|
return Create(argc, argv, device);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(Kalman): Compatible with two generation
|
|
||||||
std::shared_ptr<API> API::Create(
|
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);
|
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);
|
return std::make_shared<API>(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -287,12 +250,8 @@ bool API::Supports(const AddOns &addon) const {
|
||||||
return device_->Supports(addon);
|
return device_->Supports(addon);
|
||||||
}
|
}
|
||||||
|
|
||||||
void API::InitResolution(const Resolution &res) {
|
StreamRequest API::SelectStreamRequest(bool *ok) const {
|
||||||
return device_->InitResolution(res);
|
return device::select_request(device_, ok);
|
||||||
}
|
|
||||||
|
|
||||||
void API::SetStreamRequest(const Format &format, const FrameRate &rate) {
|
|
||||||
device_->SetStreamRequest(format, rate);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<StreamRequest> &API::GetStreamRequests(
|
const std::vector<StreamRequest> &API::GetStreamRequests(
|
||||||
|
@ -305,6 +264,27 @@ void API::ConfigStreamRequest(
|
||||||
device_->ConfigStreamRequest(capability, request);
|
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 {
|
std::string API::GetInfo(const Info &info) const {
|
||||||
return device_->GetInfo(info);
|
return device_->GetInfo(info);
|
||||||
}
|
}
|
||||||
|
|
|
@ -161,7 +161,7 @@ api::StreamData Synthetic::GetStreamData(const Stream &stream) {
|
||||||
auto &&mode = GetStreamEnabledMode(stream);
|
auto &&mode = GetStreamEnabledMode(stream);
|
||||||
if (mode == MODE_NATIVE) {
|
if (mode == MODE_NATIVE) {
|
||||||
auto &&device = api_->device();
|
auto &&device = api_->device();
|
||||||
return data2api(device->GetLatestStreamData(stream));
|
return data2api(device->GetStreamData(stream));
|
||||||
} else if (mode == MODE_SYNTHETIC) {
|
} else if (mode == MODE_SYNTHETIC) {
|
||||||
if (stream == Stream::LEFT_RECTIFIED || stream == Stream::RIGHT_RECTIFIED) {
|
if (stream == Stream::LEFT_RECTIFIED || stream == Stream::RIGHT_RECTIFIED) {
|
||||||
static std::shared_ptr<ObjMat2> output = nullptr;
|
static std::shared_ptr<ObjMat2> output = nullptr;
|
||||||
|
|
|
@ -563,44 +563,43 @@ std::size_t from_data(
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(Kalman): Is there a more elegant way?
|
|
||||||
std::size_t from_data(
|
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) {
|
const Version *spec_version) {
|
||||||
std::size_t i = 0;
|
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->major() == 1) {
|
||||||
if (spec_version->minor() == 0) {
|
if (spec_version->minor() == 0) {
|
||||||
i += from_data(
|
i += from_data(&in_left, data + i, spec_version);
|
||||||
&img_params->in_left_map[Resolution::RES_752x480], data + i,
|
i += from_data(&in_right, data + i, spec_version);
|
||||||
spec_version);
|
i += from_data(&ex_right_to_left, data + i, spec_version);
|
||||||
i += from_data(
|
(*img_params)[{752, 480}] = {true, in_left, in_right, ex_right_to_left};
|
||||||
&img_params->in_right_map[Resolution::RES_752x480], data + i,
|
|
||||||
spec_version);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (spec_version->minor() == 1) {
|
if (spec_version->minor() == 1) {
|
||||||
i += from_data(
|
i += from_data(&in_left, data + i, spec_version);
|
||||||
&img_params->in_left_map[Resolution::RES_1280x400], data + i,
|
i += from_data(&in_right, data + i, spec_version);
|
||||||
spec_version);
|
(*img_params)[{1280, 400}] = {true, in_left, in_right, ex_right_to_left};
|
||||||
i += from_data(
|
|
||||||
&img_params->in_right_map[Resolution::RES_1280x400], data + i,
|
i += from_data(&in_left, data + i, spec_version);
|
||||||
spec_version);
|
i += from_data(&in_right, data + i, spec_version);
|
||||||
i += from_data(
|
(*img_params)[{2560, 800}] = {true, in_left, in_right, ex_right_to_left};
|
||||||
&img_params->in_left_map[Resolution::RES_2560x800], data + i,
|
|
||||||
spec_version);
|
i += from_data(&ex_right_to_left, data + i, spec_version);
|
||||||
i += from_data(
|
(*img_params)[{1280, 400}].ex_right_to_left = ex_right_to_left;
|
||||||
&img_params->in_right_map[Resolution::RES_2560x800], data + i,
|
(*img_params)[{2560, 800}].ex_right_to_left = ex_right_to_left;
|
||||||
spec_version);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
i += from_data(&img_params->ex_right_to_left, data + i, spec_version);
|
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::size_t from_data(
|
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) {
|
const Version *spec_version) {
|
||||||
std::size_t i = 0;
|
std::size_t i = 0;
|
||||||
i += from_data(&imu_params->in_accel, data + i, spec_version);
|
i += from_data(&imu_params->in_accel, data + i, spec_version);
|
||||||
|
@ -674,8 +673,7 @@ bool Channels::GetFiles(
|
||||||
CheckSpecVersion(spec_ver);
|
CheckSpecVersion(spec_ver);
|
||||||
} break;
|
} break;
|
||||||
case FID_IMG_PARAMS: {
|
case FID_IMG_PARAMS: {
|
||||||
img_params->ok = file_size > 0;
|
if (file_size > 0) {
|
||||||
if (img_params->ok) {
|
|
||||||
CheckSpecVersion(spec_ver);
|
CheckSpecVersion(spec_ver);
|
||||||
from_data(img_params, data + i, spec_ver);
|
from_data(img_params, data + i, spec_ver);
|
||||||
// Considering the upgrade, comment this
|
// Considering the upgrade, comment this
|
||||||
|
@ -864,38 +862,34 @@ std::size_t to_data(
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
const Version *spec_version) {
|
||||||
std::size_t i = 3; // skip id, size
|
std::size_t i = 3; // skip id, size
|
||||||
|
|
||||||
|
// TODO(JohnZhao)
|
||||||
if (spec_version->major() == 1) {
|
if (spec_version->major() == 1) {
|
||||||
if (spec_version->minor() == 0) {
|
if (spec_version->minor() == 0) {
|
||||||
i += to_data(
|
auto &¶ms = (*img_params).at({752, 480});
|
||||||
&img_params->in_left_map.at(Resolution::RES_752x480), data + i,
|
i += to_data(¶ms.in_left, data + i, spec_version);
|
||||||
spec_version);
|
i += to_data(¶ms.in_right, data + i, spec_version);
|
||||||
i += to_data(
|
i += to_data(¶ms.ex_right_to_left, data + i, spec_version);
|
||||||
&img_params->in_right_map.at(Resolution::RES_752x480), data + i,
|
|
||||||
spec_version);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (spec_version->minor() == 1) {
|
if (spec_version->minor() == 1) {
|
||||||
i += to_data(
|
{
|
||||||
&img_params->in_left_map.at(Resolution::RES_1280x400), data + i,
|
auto &¶ms = (*img_params).at({1280, 400});
|
||||||
spec_version);
|
i += to_data(¶ms.in_left, data + i, spec_version);
|
||||||
i += to_data(
|
i += to_data(¶ms.in_right, data + i, spec_version);
|
||||||
&img_params->in_right_map.at(Resolution::RES_1280x400), data + i,
|
}
|
||||||
spec_version);
|
{
|
||||||
|
auto &¶ms = (*img_params).at({2560, 800});
|
||||||
i += to_data(
|
i += to_data(¶ms.in_left, data + i, spec_version);
|
||||||
&img_params->in_left_map.at(Resolution::RES_2560x800), data + i,
|
i += to_data(¶ms.in_right, data + i, spec_version);
|
||||||
spec_version);
|
i += to_data(¶ms.ex_right_to_left, data + i, spec_version);
|
||||||
i += to_data(
|
}
|
||||||
&img_params->in_right_map.at(Resolution::RES_2560x800), data + i,
|
|
||||||
spec_version);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
i += to_data(&img_params->ex_right_to_left, data + i, spec_version);
|
|
||||||
// others
|
// others
|
||||||
std::size_t size = i - 3;
|
std::size_t size = i - 3;
|
||||||
data[0] = Channels::FID_IMG_PARAMS;
|
data[0] = Channels::FID_IMG_PARAMS;
|
||||||
|
|
|
@ -68,23 +68,9 @@ class MYNTEYE_API Channels {
|
||||||
|
|
||||||
using device_info_t = DeviceInfo;
|
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 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);
|
explicit Channels(std::shared_ptr<uvc::device> device);
|
||||||
~Channels();
|
~Channels();
|
||||||
|
|
||||||
|
|
|
@ -16,39 +16,65 @@
|
||||||
MYNTEYE_BEGIN_NAMESPACE
|
MYNTEYE_BEGIN_NAMESPACE
|
||||||
|
|
||||||
const std::map<Model, StreamSupports> stream_supports_map = {
|
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 = {
|
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 = {
|
const std::map<Model, OptionSupports> option_supports_map = {
|
||||||
{Model::STANDARD,
|
{Model::STANDARD, {
|
||||||
{Option::BRIGHTNESS, Option::EXPOSURE_MODE, Option::MAX_GAIN,
|
Option::GAIN, Option::BRIGHTNESS, Option::CONTRAST,
|
||||||
Option::MAX_EXPOSURE_TIME, Option::DESIRED_BRIGHTNESS,
|
Option::FRAME_RATE, Option::IMU_FREQUENCY,
|
||||||
Option::MIN_EXPOSURE_TIME, Option::ERASE_CHIP,
|
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::ACCELEROMETER_RANGE, Option::GYROSCOPE_RANGE,
|
||||||
Option::ACCELEROMETER_LOW_PASS_FILTER,
|
Option::ZERO_DRIFT_CALIBRATION,
|
||||||
Option::GYROSCOPE_LOW_PASS_FILTER}}};
|
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>>
|
const std::map<Model, std::map<Capabilities, StreamRequests>>
|
||||||
stream_requests_map = {
|
stream_requests_map = {
|
||||||
{Model::STANDARD,
|
{Model::STANDARD,
|
||||||
{{Capabilities::STEREO, {{480, 752, Format::YUYV, 25}}},
|
{{Capabilities::STEREO, {
|
||||||
{Capabilities::STEREO_COLOR,
|
{752, 480, Format::YUYV, 10},
|
||||||
{// {1280, 400, Format::YUYV, 10},
|
{752, 480, Format::YUYV, 15},
|
||||||
// {1280, 400, Format::YUYV, 20},
|
{752, 480, Format::YUYV, 20},
|
||||||
// {1280, 400, Format::YUYV, 30},
|
{752, 480, Format::YUYV, 25},
|
||||||
// {1280, 400, Format::YUYV, 60},
|
{752, 480, Format::YUYV, 30},
|
||||||
// {2560, 800, Format::YUYV, 10},
|
{752, 480, Format::YUYV, 35},
|
||||||
// {2560, 800, Format::YUYV, 20},
|
{752, 480, Format::YUYV, 40},
|
||||||
// {2560, 800, Format::YUYV, 30},
|
{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, 10},
|
||||||
{1280, 400, Format::BGR888, 20},
|
{1280, 400, Format::BGR888, 20},
|
||||||
{1280, 400, Format::BGR888, 30},
|
{1280, 400, Format::BGR888, 30},
|
||||||
{1280, 400, Format::BGR888, 60},
|
{1280, 400, Format::BGR888, 60},
|
||||||
{2560, 800, Format::BGR888, 10},
|
{2560, 800, Format::BGR888, 10},
|
||||||
{2560, 800, Format::BGR888, 20},
|
{2560, 800, Format::BGR888, 20},
|
||||||
{2560, 800, Format::BGR888, 30}}}}}};
|
{2560, 800, Format::BGR888, 30}}
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
MYNTEYE_END_NAMESPACE
|
MYNTEYE_END_NAMESPACE
|
||||||
|
|
|
@ -27,18 +27,13 @@ MYNTEYE_BEGIN_NAMESPACE
|
||||||
using StreamSupports = std::set<Stream>;
|
using StreamSupports = std::set<Stream>;
|
||||||
using CapabilitiesSupports = std::set<Capabilities>;
|
using CapabilitiesSupports = std::set<Capabilities>;
|
||||||
using OptionSupports = std::set<Option>;
|
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, StreamSupports> stream_supports_map;
|
||||||
extern const std::map<Model, CapabilitiesSupports> capabilities_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, OptionSupports> option_supports_map;
|
||||||
extern const std::map<Model, ResolutionSupports> resolution_supports_map;
|
|
||||||
|
|
||||||
using StreamRequests = std::vector<StreamRequest>;
|
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>>
|
extern const std::map<Model, std::map<Capabilities, StreamRequests>>
|
||||||
stream_requests_map;
|
stream_requests_map;
|
||||||
|
|
||||||
|
|
|
@ -172,6 +172,33 @@ void Device::ConfigStreamRequest(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
stream_config_requests_[capability] = request;
|
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 {
|
std::shared_ptr<DeviceInfo> Device::GetInfo() const {
|
||||||
|
@ -406,6 +433,14 @@ void Device::WaitForStreams() {
|
||||||
streams_->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) {
|
std::vector<device::StreamData> Device::GetStreamDatas(const Stream &stream) {
|
||||||
CHECK(video_streaming_);
|
CHECK(video_streaming_);
|
||||||
CHECK_NOTNULL(streams_);
|
CHECK_NOTNULL(streams_);
|
||||||
|
@ -414,14 +449,6 @@ std::vector<device::StreamData> Device::GetStreamDatas(const Stream &stream) {
|
||||||
return streams_->GetStreamDatas(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() {
|
void Device::EnableMotionDatas() {
|
||||||
EnableMotionDatas(std::numeric_limits<std::size_t>::max());
|
EnableMotionDatas(std::numeric_limits<std::size_t>::max());
|
||||||
}
|
}
|
||||||
|
@ -437,33 +464,6 @@ std::vector<device::MotionData> Device::GetMotionDatas() {
|
||||||
return motions_->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() {
|
void Device::StartVideoStreaming() {
|
||||||
if (video_streaming_) {
|
if (video_streaming_) {
|
||||||
LOG(WARNING) << "Cannot start video streaming without first stopping it";
|
LOG(WARNING) << "Cannot start video streaming without first stopping it";
|
||||||
|
@ -557,8 +557,9 @@ void Device::ReadAllInfos() {
|
||||||
device_info_ = std::make_shared<DeviceInfo>();
|
device_info_ = std::make_shared<DeviceInfo>();
|
||||||
|
|
||||||
CHECK_NOTNULL(channels_);
|
CHECK_NOTNULL(channels_);
|
||||||
|
all_img_params_.clear();
|
||||||
Device::imu_params_t imu_params;
|
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)
|
#if defined(WITH_DEVICE_INFO_REQUIRED)
|
||||||
LOG(FATAL)
|
LOG(FATAL)
|
||||||
#else
|
#else
|
||||||
|
@ -579,14 +580,28 @@ void Device::ReadAllInfos() {
|
||||||
<< ", nominal_baseline: " << device_info_->nominal_baseline << "}";
|
<< ", nominal_baseline: " << device_info_->nominal_baseline << "}";
|
||||||
|
|
||||||
device_info_->name = uvc::get_name(*device_);
|
device_info_->name = uvc::get_name(*device_);
|
||||||
if (img_params_.ok) {
|
|
||||||
SetExtrinsics(Stream::LEFT, Stream::RIGHT, img_params_.ex_right_to_left);
|
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: {"
|
VLOG(2) << "Extrinsics left to right: {"
|
||||||
<< GetExtrinsics(Stream::LEFT, Stream::RIGHT) << "}";
|
<< GetExtrinsics(Stream::LEFT, Stream::RIGHT) << "}";
|
||||||
} else {
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!img_params_ok) {
|
||||||
LOG(WARNING) << "Intrinsics & extrinsics not exist";
|
LOG(WARNING) << "Intrinsics & extrinsics not exist";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (imu_params.ok) {
|
if (imu_params.ok) {
|
||||||
|
imu_params_ = imu_params;
|
||||||
SetMotionIntrinsics({imu_params.in_accel, imu_params.in_gyro});
|
SetMotionIntrinsics({imu_params.in_accel, imu_params.in_gyro});
|
||||||
SetMotionExtrinsics(Stream::LEFT, imu_params.ex_left_to_imu);
|
SetMotionExtrinsics(Stream::LEFT, imu_params.ex_left_to_imu);
|
||||||
VLOG(2) << "Motion intrinsics: {" << GetMotionIntrinsics() << "}";
|
VLOG(2) << "Motion intrinsics: {" << GetMotionIntrinsics() << "}";
|
||||||
|
@ -597,12 +612,25 @@ void Device::ReadAllInfos() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Device::ConfigIntrinsics(const Resolution &res) {
|
void Device::UpdateStreamIntrinsics(
|
||||||
if (img_params_.ok) {
|
const Capabilities &capability, const StreamRequest &request) {
|
||||||
SetIntrinsics(Stream::LEFT, img_params_.in_left_map[res]);
|
if (capability != GetKeyStreamCapability()) {
|
||||||
SetIntrinsics(Stream::RIGHT, img_params_.in_right_map[res]);
|
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 left: {" << GetIntrinsics(Stream::LEFT) << "}";
|
||||||
VLOG(2) << "Intrinsics right: {" << GetIntrinsics(Stream::RIGHT) << "}";
|
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
|
MYNTEYE_END_NAMESPACE
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
MYNTEYE_BEGIN_NAMESPACE
|
MYNTEYE_BEGIN_NAMESPACE
|
||||||
|
|
||||||
StandardDevice::StandardDevice(std::shared_ptr<uvc::device> device)
|
StandardDevice::StandardDevice(std::shared_ptr<uvc::device> device)
|
||||||
: Device(Model::STANDARD, device) {
|
: Device(Model::STANDARD2, device) {
|
||||||
VLOG(2) << __func__;
|
VLOG(2) << __func__;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,6 +27,10 @@ StandardDevice::~StandardDevice() {
|
||||||
VLOG(2) << __func__;
|
VLOG(2) << __func__;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Capabilities StandardDevice::GetKeyStreamCapability() const {
|
||||||
|
return Capabilities::STEREO_COLOR;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<Stream> StandardDevice::GetKeyStreams() const {
|
std::vector<Stream> StandardDevice::GetKeyStreams() const {
|
||||||
return {Stream::LEFT, Stream::RIGHT};
|
return {Stream::LEFT, Stream::RIGHT};
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ class StandardDevice : public Device {
|
||||||
explicit StandardDevice(std::shared_ptr<uvc::device> device);
|
explicit StandardDevice(std::shared_ptr<uvc::device> device);
|
||||||
virtual ~StandardDevice();
|
virtual ~StandardDevice();
|
||||||
|
|
||||||
|
Capabilities GetKeyStreamCapability() const override;
|
||||||
std::vector<Stream> GetKeyStreams() const override;
|
std::vector<Stream> GetKeyStreams() const override;
|
||||||
|
|
||||||
void OnStereoStreamUpdate() override;
|
void OnStereoStreamUpdate() override;
|
||||||
|
|
|
@ -31,14 +31,14 @@ std::shared_ptr<Device> select() {
|
||||||
Context context;
|
Context context;
|
||||||
auto &&devices = context.devices();
|
auto &&devices = context.devices();
|
||||||
|
|
||||||
size_t n = devices.size();
|
std::size_t n = devices.size();
|
||||||
if (n <= 0) {
|
if (n <= 0) {
|
||||||
LOG(ERROR) << "No MYNT EYE devices :(";
|
LOG(ERROR) << "No MYNT EYE devices :(";
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG(INFO) << "MYNT EYE devices:";
|
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];
|
auto &&device = devices[i];
|
||||||
LOG(INFO) << " index: " << i
|
LOG(INFO) << " index: " << i
|
||||||
<< ", name: " << device->GetInfo(Info::DEVICE_NAME)
|
<< ", 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";
|
LOG(INFO) << "Only one MYNT EYE device, select index: 0";
|
||||||
} else {
|
} else {
|
||||||
while (true) {
|
while (true) {
|
||||||
size_t i;
|
std::size_t i;
|
||||||
LOG(INFO) << "There are " << n << " MYNT EYE devices, select index: ";
|
LOG(INFO) << "There are " << n << " MYNT EYE devices, select index: ";
|
||||||
std::cin >> i;
|
std::cin >> i;
|
||||||
if (i >= n) {
|
if (i >= n) {
|
||||||
|
@ -66,6 +66,42 @@ std::shared_ptr<Device> select() {
|
||||||
return device;
|
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 device
|
||||||
|
|
||||||
namespace utils {
|
namespace utils {
|
||||||
|
|
|
@ -29,6 +29,7 @@ const char *to_string(const Model &value) {
|
||||||
return "Model::" #X;
|
return "Model::" #X;
|
||||||
switch (value) {
|
switch (value) {
|
||||||
CASE(STANDARD)
|
CASE(STANDARD)
|
||||||
|
CASE(STANDARD2)
|
||||||
default:
|
default:
|
||||||
CHECK(is_valid(value));
|
CHECK(is_valid(value));
|
||||||
return "Model::UNKNOWN";
|
return "Model::UNKNOWN";
|
||||||
|
@ -62,6 +63,7 @@ const char *to_string(const Capabilities &value) {
|
||||||
return "Capabilities::" #X;
|
return "Capabilities::" #X;
|
||||||
switch (value) {
|
switch (value) {
|
||||||
CASE(STEREO)
|
CASE(STEREO)
|
||||||
|
CASE(STEREO_COLOR)
|
||||||
CASE(COLOR)
|
CASE(COLOR)
|
||||||
CASE(DEPTH)
|
CASE(DEPTH)
|
||||||
CASE(POINTS)
|
CASE(POINTS)
|
||||||
|
@ -109,16 +111,16 @@ const char *to_string(const Option &value) {
|
||||||
CASE(EXPOSURE_MODE)
|
CASE(EXPOSURE_MODE)
|
||||||
CASE(MAX_GAIN)
|
CASE(MAX_GAIN)
|
||||||
CASE(MAX_EXPOSURE_TIME)
|
CASE(MAX_EXPOSURE_TIME)
|
||||||
|
CASE(MIN_EXPOSURE_TIME)
|
||||||
CASE(DESIRED_BRIGHTNESS)
|
CASE(DESIRED_BRIGHTNESS)
|
||||||
CASE(IR_CONTROL)
|
CASE(IR_CONTROL)
|
||||||
CASE(HDR_MODE)
|
CASE(HDR_MODE)
|
||||||
CASE(ZERO_DRIFT_CALIBRATION)
|
|
||||||
CASE(ERASE_CHIP)
|
|
||||||
CASE(MIN_EXPOSURE_TIME)
|
|
||||||
CASE(ACCELEROMETER_RANGE)
|
CASE(ACCELEROMETER_RANGE)
|
||||||
CASE(GYROSCOPE_RANGE)
|
CASE(GYROSCOPE_RANGE)
|
||||||
CASE(ACCELEROMETER_LOW_PASS_FILTER)
|
CASE(ACCELEROMETER_LOW_PASS_FILTER)
|
||||||
CASE(GYROSCOPE_LOW_PASS_FILTER)
|
CASE(GYROSCOPE_LOW_PASS_FILTER)
|
||||||
|
CASE(ZERO_DRIFT_CALIBRATION)
|
||||||
|
CASE(ERASE_CHIP)
|
||||||
default:
|
default:
|
||||||
CHECK(is_valid(value));
|
CHECK(is_valid(value));
|
||||||
return "Option::UNKNOWN";
|
return "Option::UNKNOWN";
|
||||||
|
@ -160,6 +162,7 @@ const char *to_string(const Format &value) {
|
||||||
switch (value) {
|
switch (value) {
|
||||||
CASE(GREY)
|
CASE(GREY)
|
||||||
CASE(YUYV)
|
CASE(YUYV)
|
||||||
|
CASE(BGR888)
|
||||||
default:
|
default:
|
||||||
return "Format::UNKNOWN";
|
return "Format::UNKNOWN";
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,10 +24,13 @@ MYNTEYE_USE_NAMESPACE
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
auto &&api = API::Create(argc, argv);
|
auto &&api = API::Create(argc, argv);
|
||||||
if (!api)
|
if (!api) return 1;
|
||||||
return 1;
|
|
||||||
api->InitResolution(Resolution::RES_1280x400);
|
bool ok;
|
||||||
api->SetStreamRequest(Format::BGR888, FrameRate::RATE_30_FPS);
|
auto &&request = api->SelectStreamRequest(&ok);
|
||||||
|
if (!ok) return 1;
|
||||||
|
api->ConfigStreamRequest(request);
|
||||||
|
|
||||||
api->LogOptionInfos();
|
api->LogOptionInfos();
|
||||||
|
|
||||||
// Enable this will cache the motion datas until you get them.
|
// Enable this will cache the motion datas until you get them.
|
||||||
|
|
|
@ -27,10 +27,13 @@ int main(int argc, char *argv[]) {
|
||||||
glog_init _(argc, argv);
|
glog_init _(argc, argv);
|
||||||
|
|
||||||
auto &&device = device::select();
|
auto &&device = device::select();
|
||||||
if (!device)
|
if (!device) return 1;
|
||||||
return 1;
|
|
||||||
device->InitResolution(Resolution::RES_1280x400);
|
bool ok;
|
||||||
device->SetStreamRequest(Format::BGR888, FrameRate::RATE_30_FPS);
|
auto &&request = device::select_request(device, &ok);
|
||||||
|
if (!ok) return 1;
|
||||||
|
device->ConfigStreamRequest(request);
|
||||||
|
|
||||||
device->LogOptionInfos();
|
device->LogOptionInfos();
|
||||||
|
|
||||||
// Enable this will cache the motion datas until you get them.
|
// Enable this will cache the motion datas until you get them.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user