diff --git a/include/mynteye/api/api.h b/include/mynteye/api/api.h index c86e9e8..3accde8 100644 --- a/include/mynteye/api/api.h +++ b/include/mynteye/api/api.h @@ -213,6 +213,11 @@ class MYNTEYE_API API { */ bool RunOptionAction(const Option &option) const; + /** + * Init device resolution. + */ + void InitResolution(const Resolution &res); + /** * Set the callback of stream. */ diff --git a/include/mynteye/device/callbacks.h b/include/mynteye/device/callbacks.h index f1775ce..0019433 100644 --- a/include/mynteye/device/callbacks.h +++ b/include/mynteye/device/callbacks.h @@ -19,6 +19,7 @@ #include #include +#include #include #include @@ -29,6 +30,20 @@ MYNTEYE_BEGIN_NAMESPACE namespace device { +typedef struct ImgParams { + bool ok; + std::map in_left_map; + std::map 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; + /** * @ingroup datatypes * Frame with raw data. diff --git a/include/mynteye/device/device.h b/include/mynteye/device/device.h index 46c7b1a..4e9b6f3 100644 --- a/include/mynteye/device/device.h +++ b/include/mynteye/device/device.h @@ -66,6 +66,9 @@ class MYNTEYE_API Device { using stream_async_callback_ptr_t = std::shared_ptr; using motion_async_callback_ptr_t = std::shared_ptr; + using img_params_t = device::img_params_t; + using imu_params_t = device::imu_params_t; + Device(const Model &model, std::shared_ptr device); virtual ~Device(); @@ -263,7 +266,7 @@ class MYNTEYE_API Device { /** * Get the device img params */ - Channels::img_params_t GetImgParams(); + img_params_t GetImgParams(); protected: std::shared_ptr device() const { @@ -310,7 +313,7 @@ class MYNTEYE_API Device { std::shared_ptr motion_intrinsics_; std::map motion_from_extrinsics_; - Channels::img_params_t img_params_; + img_params_t img_params_; stream_callbacks_t stream_callbacks_; motion_callback_t motion_callback_; diff --git a/src/mynteye/api/api.cc b/src/mynteye/api/api.cc index b839500..a74df26 100644 --- a/src/mynteye/api/api.cc +++ b/src/mynteye/api/api.cc @@ -287,6 +287,10 @@ 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); } diff --git a/src/mynteye/api/synthetic.cc b/src/mynteye/api/synthetic.cc index ebac2ee..35ab9a5 100644 --- a/src/mynteye/api/synthetic.cc +++ b/src/mynteye/api/synthetic.cc @@ -17,6 +17,8 @@ #include #include +#include + #include "mynteye/logger.h" #include "mynteye/api/object.h" #include "mynteye/api/plugin.h" diff --git a/src/mynteye/device/channels.cc b/src/mynteye/device/channels.cc index d6188e9..48a0998 100644 --- a/src/mynteye/device/channels.cc +++ b/src/mynteye/device/channels.cc @@ -565,7 +565,7 @@ std::size_t from_data( // TODO(Kalman): Is there a more elegant way? std::size_t from_data( - Channels::img_params_t *img_params, const std::uint8_t *data, + device::img_params_t *img_params, const std::uint8_t *data, const Version *spec_version) { std::size_t i = 0; @@ -600,7 +600,7 @@ std::size_t from_data( } std::size_t from_data( - Channels::imu_params_t *imu_params, const std::uint8_t *data, + device::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); @@ -864,7 +864,7 @@ std::size_t to_data( } std::size_t to_data( - const Channels::img_params_t *img_params, std::uint8_t *data, + const device::img_params_t *img_params, std::uint8_t *data, const Version *spec_version) { std::size_t i = 3; // skip id, size diff --git a/src/mynteye/device/channels.h b/src/mynteye/device/channels.h index 881fca9..86dccdb 100644 --- a/src/mynteye/device/channels.h +++ b/src/mynteye/device/channels.h @@ -21,6 +21,7 @@ #include "mynteye/mynteye.h" #include "mynteye/types.h" +#include "mynteye/device/device.h" #include "mynteye/device/types.h" #include "mynteye/uvc/uvc.h" @@ -67,6 +68,9 @@ class MYNTEYE_API Channels { using device_info_t = DeviceInfo; + using imu_params_t = device::imu_params_t; + using img_params_t = device::img_params_t; +/* typedef struct ImgParams { bool ok; std::map in_left_map; @@ -80,7 +84,7 @@ class MYNTEYE_API Channels { ImuIntrinsics in_gyro; Extrinsics ex_left_to_imu; } imu_params_t; - +*/ explicit Channels(std::shared_ptr device); ~Channels(); diff --git a/src/mynteye/device/device.cc b/src/mynteye/device/device.cc index 5c3c9dd..7041168 100644 --- a/src/mynteye/device/device.cc +++ b/src/mynteye/device/device.cc @@ -557,8 +557,8 @@ void Device::ReadAllInfos() { device_info_ = std::make_shared(); CHECK_NOTNULL(channels_); - Channels::imu_params_t imu_params; - if (!channels_->GetFiles(device_info_.get(), &img_params, &imu_params)) { + Device::imu_params_t imu_params; + if (!channels_->GetFiles(device_info_.get(), &img_params_, &imu_params)) { #if defined(WITH_DEVICE_INFO_REQUIRED) LOG(FATAL) #else @@ -629,7 +629,7 @@ void Device::CallbackMotionData(const device::MotionData &data) { } } -Channels::img_params_t Device::GetImgParams() { +Device::img_params_t Device::GetImgParams() { return img_params_; } diff --git a/tools/dataset/CMakeLists.txt b/tools/dataset/CMakeLists.txt index b6bb217..54399da 100644 --- a/tools/dataset/CMakeLists.txt +++ b/tools/dataset/CMakeLists.txt @@ -26,11 +26,11 @@ include_directories( ## record -make_executable(record - SRCS record.cc dataset.cc - LINK_LIBS mynteye ${OpenCV_LIBS} - DLL_SEARCH_PATHS ${PRO_DIR}/_install/bin ${OpenCV_LIB_SEARCH_PATH} -) +# make_executable(record +# SRCS record.cc dataset.cc +# LINK_LIBS mynteye ${OpenCV_LIBS} +# DLL_SEARCH_PATHS ${PRO_DIR}/_install/bin ${OpenCV_LIB_SEARCH_PATH} +#) make_executable(record2 SRCS record2.cc dataset.cc diff --git a/tools/dataset/dataset.cc b/tools/dataset/dataset.cc index 5b63475..407b6b9 100644 --- a/tools/dataset/dataset.cc +++ b/tools/dataset/dataset.cc @@ -13,11 +13,8 @@ // limitations under the License. #include "dataset/dataset.h" -#ifdef WITH_OPENCV2 #include -#else -#include -#endif +#include #include #include @@ -135,14 +132,24 @@ void Dataset::SaveStreamData( void Dataset::SaveMotionData(const api::MotionData &data) { auto &&writer = GetMotionWriter(); + // auto seq = data.imu->serial_number; auto seq = motion_count_; - writer->ofs << seq << ", " << data.imu->frame_id << ", " - << data.imu->timestamp << ", " << data.imu->accel[0] << ", " - << data.imu->accel[1] << ", " << data.imu->accel[2] << ", " - << data.imu->gyro[0] << ", " << data.imu->gyro[1] << ", " - << data.imu->gyro[2] << ", " << data.imu->temperature - << std::endl; - ++motion_count_; + if (data.imu->flag == 1 || data.imu->flag == 2) { + writer->ofs << seq << ", " << static_cast(data.imu->flag) << ", " + << data.imu->timestamp << ", " << data.imu->accel[0] << ", " + << data.imu->accel[1] << ", " << data.imu->accel[2] << ", " + << data.imu->gyro[0] << ", " << data.imu->gyro[1] << ", " + << data.imu->gyro[2] << ", " << data.imu->temperature + << std::endl; + ++motion_count_; + } + /* + if(motion_count_ != seq) { + LOG(INFO) << "motion_count_ != seq !" << " motion_count_: " << motion_count_ + << " seq: " << seq; + motion_count_ = seq; + } + */ } Dataset::writer_t Dataset::GetStreamWriter(const Stream &stream) { diff --git a/tools/writer/device_writer.h b/tools/writer/device_writer.h index f15130f..5e443e0 100644 --- a/tools/writer/device_writer.h +++ b/tools/writer/device_writer.h @@ -31,8 +31,8 @@ namespace tools { class DeviceWriter { public: using dev_info_t = DeviceInfo; - using img_params_t = Channels::img_params_t; - using imu_params_t = Channels::imu_params_t; + using img_params_t = device::img_params_t; + using imu_params_t = device::imu_params_t; explicit DeviceWriter(std::shared_ptr device); ~DeviceWriter(); diff --git a/wrappers/ros/src/mynt_eye_ros_wrapper/src/wrapper_nodelet.cc b/wrappers/ros/src/mynt_eye_ros_wrapper/src/wrapper_nodelet.cc index 81bcd72..aac3965 100644 --- a/wrappers/ros/src/mynt_eye_ros_wrapper/src/wrapper_nodelet.cc +++ b/wrappers/ros/src/mynt_eye_ros_wrapper/src/wrapper_nodelet.cc @@ -72,11 +72,14 @@ class ROSWrapperNodelet : public nodelet::Nodelet { } if (imu_time_beg_ != -1) { if (publish_imu_by_sync_) { - LOG(INFO) << "imu_sync_count: " << imu_sync_count_ - << ", hz: " << (imu_sync_count_ / time_elapsed); + LOG(INFO) << "imu_sync_count: " << imu_sync_count_ << ", hz: " + << (imu_sync_count_ / + compute_time(time_end, imu_time_beg_)); } else { - LOG(INFO) << "Imu count: " << imu_count_ - << ", hz: " << (imu_count_ / time_elapsed); + LOG(INFO) << "Imu count: " << imu_count_ << ", hz: " + << (imu_count_ / + compute_time(time_end, imu_time_beg_)); + } } // ROS messages could not be reliably printed here, using glog instead :( @@ -208,7 +211,7 @@ class ROSWrapperNodelet : public nodelet::Nodelet { } camera_encodings_ = {{Stream::LEFT, enc::BGR8}, - {Stream::RIGHT, enc::BGR8} + {Stream::RIGHT, enc::BGR8}, {Stream::LEFT_RECTIFIED, enc::BGR8}, {Stream::RIGHT_RECTIFIED, enc::BGR8}, {Stream::DISPARITY, enc::MONO8}, // float