feat(process): add rectify slpha api.
This commit is contained in:
parent
0881a70922
commit
636471b1cf
|
@ -237,6 +237,11 @@ class MYNTEYE_API API {
|
||||||
void SetDisparityComputingMethodType(
|
void SetDisparityComputingMethodType(
|
||||||
const DisparityComputingMethod &MethodType);
|
const DisparityComputingMethod &MethodType);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the rectify bord cut alpha.
|
||||||
|
*/
|
||||||
|
void SetRectifyAlpha(const double &alpha);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set if the duplicate frames is enable.
|
* Set if the duplicate frames is enable.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -30,6 +30,11 @@ int main(int argc, char *argv[]) {
|
||||||
api->EnableStreamData(Stream::LEFT_RECTIFIED);
|
api->EnableStreamData(Stream::LEFT_RECTIFIED);
|
||||||
api->EnableStreamData(Stream::RIGHT_RECTIFIED);
|
api->EnableStreamData(Stream::RIGHT_RECTIFIED);
|
||||||
|
|
||||||
|
/** SetRectifyAlpha
|
||||||
|
-1 is default
|
||||||
|
*/
|
||||||
|
// api->SetRectifyAlpha(0.5);
|
||||||
|
|
||||||
api->Start(Source::VIDEO_STREAMING);
|
api->Start(Source::VIDEO_STREAMING);
|
||||||
|
|
||||||
double fps;
|
double fps;
|
||||||
|
|
|
@ -562,6 +562,10 @@ void API::SetDisparityComputingMethodType(
|
||||||
synthetic_->SetDisparityComputingMethodType(MethodType);
|
synthetic_->SetDisparityComputingMethodType(MethodType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void API::SetRectifyAlpha(const double &alpha) {
|
||||||
|
synthetic_->SetRectifyAlpha(alpha);
|
||||||
|
}
|
||||||
|
|
||||||
std::shared_ptr<Device> API::device() {
|
std::shared_ptr<Device> API::device() {
|
||||||
return device_;
|
return device_;
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,8 @@ void RectifyProcessor::stereoRectify(models::CameraPtr leftOdo,
|
||||||
const CvMat* matR, const CvMat* matT,
|
const CvMat* matR, const CvMat* matT,
|
||||||
CvMat* _R1, CvMat* _R2, CvMat* _P1, CvMat* _P2, double* T_mul_f,
|
CvMat* _R1, CvMat* _R2, CvMat* _P1, CvMat* _P2, double* T_mul_f,
|
||||||
int flags, double alpha, CvSize newImgSize) {
|
int flags, double alpha, CvSize newImgSize) {
|
||||||
|
// std::cout << _alpha << std::endl;
|
||||||
|
alpha = _alpha;
|
||||||
double _om[3], _t[3] = {0}, _uu[3]={0, 0, 0}, _r_r[3][3], _pp[3][4];
|
double _om[3], _t[3] = {0}, _uu[3]={0, 0, 0}, _r_r[3][3], _pp[3][4];
|
||||||
double _ww[3], _wr[3][3], _z[3] = {0, 0, 0}, _ri[3][3], _w3[3];
|
double _ww[3], _wr[3][3], _z[3] = {0, 0, 0}, _ri[3][3], _w3[3];
|
||||||
cv::Rect_<float> inner1, inner2, outer1, outer2;
|
cv::Rect_<float> inner1, inner2, outer1, outer2;
|
||||||
|
@ -351,6 +353,9 @@ void RectifyProcessor::InitParams(
|
||||||
IntrinsicsEquidistant in_left,
|
IntrinsicsEquidistant in_left,
|
||||||
IntrinsicsEquidistant in_right,
|
IntrinsicsEquidistant in_right,
|
||||||
Extrinsics ex_right_to_left) {
|
Extrinsics ex_right_to_left) {
|
||||||
|
in_left_cur = in_left;
|
||||||
|
in_right_cur = in_right;
|
||||||
|
ex_right_to_left_cur = ex_right_to_left;
|
||||||
calib_model = CalibrationModel::KANNALA_BRANDT;
|
calib_model = CalibrationModel::KANNALA_BRANDT;
|
||||||
in_left.ResizeIntrinsics();
|
in_left.ResizeIntrinsics();
|
||||||
in_right.ResizeIntrinsics();
|
in_right.ResizeIntrinsics();
|
||||||
|
@ -398,7 +403,8 @@ RectifyProcessor::RectifyProcessor(
|
||||||
std::shared_ptr<Extrinsics> extr,
|
std::shared_ptr<Extrinsics> extr,
|
||||||
std::int32_t proc_period)
|
std::int32_t proc_period)
|
||||||
: Processor(std::move(proc_period)),
|
: Processor(std::move(proc_period)),
|
||||||
calib_model(CalibrationModel::UNKNOW) {
|
calib_model(CalibrationModel::UNKNOW),
|
||||||
|
_alpha(-1) {
|
||||||
calib_infos = std::make_shared<struct CameraROSMsgInfoPair>();
|
calib_infos = std::make_shared<struct CameraROSMsgInfoPair>();
|
||||||
InitParams(
|
InitParams(
|
||||||
*std::dynamic_pointer_cast<IntrinsicsEquidistant>(intr_left),
|
*std::dynamic_pointer_cast<IntrinsicsEquidistant>(intr_left),
|
||||||
|
@ -428,6 +434,11 @@ Object *RectifyProcessor::OnCreateOutput() {
|
||||||
return new ObjMat2();
|
return new ObjMat2();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool RectifyProcessor::SetRectifyAlpha(float alpha) {
|
||||||
|
_alpha = alpha;
|
||||||
|
ReloadImageParams();
|
||||||
|
}
|
||||||
|
|
||||||
bool RectifyProcessor::OnProcess(
|
bool RectifyProcessor::OnProcess(
|
||||||
Object *const in, Object *const out,
|
Object *const in, Object *const out,
|
||||||
std::shared_ptr<Processor> const parent) {
|
std::shared_ptr<Processor> const parent) {
|
||||||
|
|
|
@ -52,6 +52,9 @@ class RectifyProcessor : public Processor {
|
||||||
std::shared_ptr<IntrinsicsBase> intr_left,
|
std::shared_ptr<IntrinsicsBase> intr_left,
|
||||||
std::shared_ptr<IntrinsicsBase> intr_right,
|
std::shared_ptr<IntrinsicsBase> intr_right,
|
||||||
std::shared_ptr<Extrinsics> extr);
|
std::shared_ptr<Extrinsics> extr);
|
||||||
|
void ReloadImageParams() {
|
||||||
|
InitParams(in_left_cur, in_right_cur, ex_right_to_left_cur);
|
||||||
|
}
|
||||||
|
|
||||||
cv::Mat R1, P1, R2, P2, Q;
|
cv::Mat R1, P1, R2, P2, Q;
|
||||||
cv::Mat map11, map12, map21, map22;
|
cv::Mat map11, map12, map21, map22;
|
||||||
|
@ -59,6 +62,7 @@ class RectifyProcessor : public Processor {
|
||||||
getCameraROSMsgInfoPair() {
|
getCameraROSMsgInfoPair() {
|
||||||
return calib_infos;
|
return calib_infos;
|
||||||
}
|
}
|
||||||
|
bool SetRectifyAlpha(float alpha);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Object *OnCreateOutput() override;
|
Object *OnCreateOutput() override;
|
||||||
|
@ -106,6 +110,10 @@ class RectifyProcessor : public Processor {
|
||||||
|
|
||||||
CalibrationModel calib_model;
|
CalibrationModel calib_model;
|
||||||
std::shared_ptr<struct CameraROSMsgInfoPair> calib_infos;
|
std::shared_ptr<struct CameraROSMsgInfoPair> calib_infos;
|
||||||
|
double _alpha;
|
||||||
|
IntrinsicsEquidistant in_left_cur;
|
||||||
|
IntrinsicsEquidistant in_right_cur;
|
||||||
|
Extrinsics ex_right_to_left_cur;
|
||||||
};
|
};
|
||||||
|
|
||||||
MYNTEYE_END_NAMESPACE
|
MYNTEYE_END_NAMESPACE
|
||||||
|
|
|
@ -565,6 +565,19 @@ void Synthetic::SetDisparityComputingMethodType(
|
||||||
LOG(ERROR) << "ERROR: no suited processor for disparity computing.";
|
LOG(ERROR) << "ERROR: no suited processor for disparity computing.";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Synthetic::SetRectifyAlpha(const double &alpha) {
|
||||||
|
if (checkControlDateWithStream(Stream::LEFT_RECTIFIED)) {
|
||||||
|
#ifdef WITH_CAM_MODELS
|
||||||
|
auto processor = find_processor<RectifyProcessor>(processor_);
|
||||||
|
if (processor)
|
||||||
|
processor->SetRectifyAlpha(alpha);
|
||||||
|
return true;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
LOG(ERROR) << "ERROR: no suited processor for rectify.";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void Synthetic::NotifyStreamData(
|
void Synthetic::NotifyStreamData(
|
||||||
const Stream &stream, const api::StreamData &data) {
|
const Stream &stream, const api::StreamData &data) {
|
||||||
if (stream_data_listener_) {
|
if (stream_data_listener_) {
|
||||||
|
|
|
@ -95,6 +95,7 @@ class Synthetic {
|
||||||
const DisparityComputingMethod &MethoType);
|
const DisparityComputingMethod &MethoType);
|
||||||
std::shared_ptr<struct CameraROSMsgInfoPair> GetCameraROSMsgInfoPair();
|
std::shared_ptr<struct CameraROSMsgInfoPair> GetCameraROSMsgInfoPair();
|
||||||
bool ConfigDisparityFromFile(const std::string& config_file);
|
bool ConfigDisparityFromFile(const std::string& config_file);
|
||||||
|
bool SetRectifyAlpha(const double &alpha);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void InitCalibInfo();
|
void InitCalibInfo();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user