Merge branch 'local' into develop

This commit is contained in:
TinyOh 2019-01-04 10:37:17 +08:00
commit 2d77b6ba79
4 changed files with 132 additions and 1 deletions

View File

@ -25,6 +25,7 @@
#include "mynteye/mynteye.h" #include "mynteye/mynteye.h"
#include "mynteye/types.h" #include "mynteye/types.h"
#include "mynteye/device.h"
MYNTEYE_BEGIN_NAMESPACE MYNTEYE_BEGIN_NAMESPACE
@ -201,6 +202,11 @@ class MYNTEYE_API API {
* Get the extrinsics from one stream to motion. * Get the extrinsics from one stream to motion.
*/ */
Extrinsics GetMotionExtrinsics(const Stream &from) const; Extrinsics GetMotionExtrinsics(const Stream &from) const;
/**
* Get the intrinsics of stream.
*/
template<typename T>
T GetIntrinsics(const Stream &from) const;
/** /**
* Log all option infos. * Log all option infos.
@ -304,6 +310,18 @@ class MYNTEYE_API API {
void CheckImageParams(); void CheckImageParams();
}; };
template <typename T>
T API::GetIntrinsics(const Stream &from) const {
return device_->GetIntrinsics<T>(from);
}
template <typename T>
T Device::GetIntrinsics(const Stream &from) const {
T res;
printf("type %d\n", res.calib_model_);
return res;
}
MYNTEYE_END_NAMESPACE MYNTEYE_END_NAMESPACE
#endif // MYNTEYE_API_API_H_ #endif // MYNTEYE_API_API_H_

View File

@ -203,6 +203,12 @@ class MYNTEYE_API Device {
*/ */
void SetMotionExtrinsics(const Stream &from, const Extrinsics &ex); void SetMotionExtrinsics(const Stream &from, const Extrinsics &ex);
/**
* Get the intrinsics of stream.
*/
template<typename T>
T GetIntrinsics(const Stream &from) const;
/** /**
* Log all option infos. * Log all option infos.
*/ */

View File

@ -15,6 +15,8 @@
#define MYNTEYE_TYPES_H_ #define MYNTEYE_TYPES_H_
#pragma once #pragma once
#include <memory.h>
#include <cstdint> #include <cstdint>
#include <algorithm> #include <algorithm>
@ -393,11 +395,33 @@ std::ostream &operator<<(std::ostream &os, const StreamRequest &request);
* @brief Intrinsic and extrinsic properties. * @brief Intrinsic and extrinsic properties.
*/ */
/** different model of camera calibration */
typedef enum CalibrationModel {
/** pinhole camera */
CALIB_MODEL_PINHOLE = 0,
/** equidistant camera */
CALIB_MODEL_KANNALA_BRANDT = 1,
CALIB_MODEL_UNKNOW,
// CALIB_MODEL_SCARAMUZZA,
// CALIB_MODEL_MEI
}CALIB_MODEL;
/** /**
* @ingroup calibration * @ingroup calibration
* Stream intrinsics, * Stream intrinsics,
*/ */
struct MYNTEYE_API Intrinsics { struct MYNTEYE_API IntrinsicsBase {
IntrinsicsBase() {
calib_model_ = CALIB_MODEL_UNKNOW;
}
CALIB_MODEL calib_model_;
};
struct MYNTEYE_API Intrinsics : public IntrinsicsBase {
Intrinsics() {
calib_model_ = CALIB_MODEL_PINHOLE;
}
/** The width of the image in pixels */ /** The width of the image in pixels */
std::uint16_t width; std::uint16_t width;
/** The height of the image in pixels */ /** The height of the image in pixels */
@ -416,6 +440,66 @@ struct MYNTEYE_API Intrinsics {
double coeffs[5]; double coeffs[5];
}; };
/*
model_type: KANNALA_BRANDT
camera_name: KANNALA_BRANDT
image_width: 640
image_height: 400
projection_parameters:
k2: 4.9972342319338209e-01
k3: 4.3314206872885375e-01
k4: -9.2064699153680563e-01
k5: 4.1211925379358533e-01
mu: 2.0077513040612871e+02
mv: 2.0099851605062454e+02
u0: 3.1079403134153824e+02
v0: 2.1225649273618896e+02
*/
struct MYNTEYE_API Intrinsics2 : public IntrinsicsBase {
Intrinsics2() {
calib_model_ = CALIB_MODEL_KANNALA_BRANDT;
}
/** The width of the image in pixels */
std::uint16_t width;
/** The height of the image in pixels */
std::uint16_t height;
/** The distortion coefficients */
double k2;
double k3;
double k4;
double k5;
double mu;
double mv;
double u0;
double v0;
};
// union MYNTEYE_API CameraParameters {
// struct IntrinsicsBase intrinsics_base;
// struct Intrinsics intrinsics10;
// struct Intrinsics2 intrinsics20;
// unsigned char raw[];
// CameraParameters(struct IntrinsicsBase& base) {
// memset(raw, 0, sizeof(union CameraParameters));
// switch (base.calib_model_) {
// case CALIB_MODEL_10:
// intrinsics10 = static_cast<struct Intrinsics&>(base);
// break;
// case CALIB_MODEL_20:
// intrinsics20 = static_cast<struct Intrinsics2&>(base);
// break;
// default:
// // warning!!! no impl!!!
// intrinsics_base = base;
// return;
// }
// }
// CALIB_MODEL getModelType() {return intrinsics_base.calib_model_;}
// };
// MYNTEYE_API
// std::ostream &operator<<(std::ostream &os, const CameraParameters &in);
MYNTEYE_API MYNTEYE_API
std::ostream &operator<<(std::ostream &os, const Intrinsics &in); std::ostream &operator<<(std::ostream &os, const Intrinsics &in);

View File

@ -13,6 +13,7 @@
// limitations under the License. // limitations under the License.
#include "mynteye/logger.h" #include "mynteye/logger.h"
#include "mynteye/api/api.h" #include "mynteye/api/api.h"
#include "mynteye/types.h"
MYNTEYE_USE_NAMESPACE MYNTEYE_USE_NAMESPACE
@ -30,6 +31,28 @@ int main(int argc, char *argv[]) {
<< "}"; << "}";
LOG(INFO) << "Extrinsics right to left: {" LOG(INFO) << "Extrinsics right to left: {"
<< api->GetExtrinsics(Stream::RIGHT, Stream::LEFT) << "}"; << api->GetExtrinsics(Stream::RIGHT, Stream::LEFT) << "}";
auto inr = api->GetIntrinsics(Stream::LEFT);
// CameraParameters cmm(inr);
// for (int i = 0;i< sizeof(cmm) ; i++) {
// printf(" %x ",cmm.raw[i]);
// }
// printf("end: %d\n", (int)(cmm.getModelType()));
// Intrinsics2 xxx2;
// CameraParameters cmm2(xxx2);
// for (int i = 0;i< sizeof(cmm2) ; i++) {
// printf(" %x ",cmm2.raw[i]);
// }
// printf("end: %d\n", (int)(cmm2.getModelType()));
// IntrinsicsBase xxx3;
// CameraParameters cmm3(xxx3);
// for (int i = 0;i< sizeof(cmm3) ; i++) {
// printf(" %x ",cmm3.raw[i]);
// }
// printf("end: %d\n", (int)(cmm3.getModelType()));
api->GetIntrinsics<Intrinsics>(Stream::LEFT);
return 0; return 0;
} }