feat(process): add rectify slpha api.

This commit is contained in:
TinyO 2019-07-23 16:46:25 +08:00
parent 0881a70922
commit 636471b1cf
7 changed files with 49 additions and 2 deletions

View File

@ -237,6 +237,11 @@ class MYNTEYE_API API {
void SetDisparityComputingMethodType(
const DisparityComputingMethod &MethodType);
/**
* Set the rectify bord cut alpha.
*/
void SetRectifyAlpha(const double &alpha);
/**
* Set if the duplicate frames is enable.
*/

View File

@ -30,6 +30,11 @@ int main(int argc, char *argv[]) {
api->EnableStreamData(Stream::LEFT_RECTIFIED);
api->EnableStreamData(Stream::RIGHT_RECTIFIED);
/** SetRectifyAlpha
-1 is default
*/
// api->SetRectifyAlpha(0.5);
api->Start(Source::VIDEO_STREAMING);
double fps;

View File

@ -562,6 +562,10 @@ void API::SetDisparityComputingMethodType(
synthetic_->SetDisparityComputingMethodType(MethodType);
}
void API::SetRectifyAlpha(const double &alpha) {
synthetic_->SetRectifyAlpha(alpha);
}
std::shared_ptr<Device> API::device() {
return device_;
}

View File

@ -43,6 +43,8 @@ void RectifyProcessor::stereoRectify(models::CameraPtr leftOdo,
const CvMat* matR, const CvMat* matT,
CvMat* _R1, CvMat* _R2, CvMat* _P1, CvMat* _P2, double* T_mul_f,
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 _ww[3], _wr[3][3], _z[3] = {0, 0, 0}, _ri[3][3], _w3[3];
cv::Rect_<float> inner1, inner2, outer1, outer2;
@ -351,6 +353,9 @@ void RectifyProcessor::InitParams(
IntrinsicsEquidistant in_left,
IntrinsicsEquidistant in_right,
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;
in_left.ResizeIntrinsics();
in_right.ResizeIntrinsics();
@ -398,7 +403,8 @@ RectifyProcessor::RectifyProcessor(
std::shared_ptr<Extrinsics> extr,
std::int32_t proc_period)
: Processor(std::move(proc_period)),
calib_model(CalibrationModel::UNKNOW) {
calib_model(CalibrationModel::UNKNOW),
_alpha(-1) {
calib_infos = std::make_shared<struct CameraROSMsgInfoPair>();
InitParams(
*std::dynamic_pointer_cast<IntrinsicsEquidistant>(intr_left),
@ -428,6 +434,11 @@ Object *RectifyProcessor::OnCreateOutput() {
return new ObjMat2();
}
bool RectifyProcessor::SetRectifyAlpha(float alpha) {
_alpha = alpha;
ReloadImageParams();
}
bool RectifyProcessor::OnProcess(
Object *const in, Object *const out,
std::shared_ptr<Processor> const parent) {

View File

@ -52,6 +52,9 @@ class RectifyProcessor : public Processor {
std::shared_ptr<IntrinsicsBase> intr_left,
std::shared_ptr<IntrinsicsBase> intr_right,
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 map11, map12, map21, map22;
@ -59,6 +62,7 @@ class RectifyProcessor : public Processor {
getCameraROSMsgInfoPair() {
return calib_infos;
}
bool SetRectifyAlpha(float alpha);
protected:
Object *OnCreateOutput() override;
@ -106,6 +110,10 @@ class RectifyProcessor : public Processor {
CalibrationModel calib_model;
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

View File

@ -555,7 +555,7 @@ void Synthetic::OnDepthPostProcess(Object *const out) {
}
void Synthetic::SetDisparityComputingMethodType(
const DisparityComputingMethod &MethodType) {
const DisparityComputingMethod &MethodType) {
if (checkControlDateWithStream(Stream::LEFT_RECTIFIED)) {
auto processor = find_processor<DisparityProcessor>(processor_);
if (processor)
@ -565,6 +565,19 @@ void Synthetic::SetDisparityComputingMethodType(
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(
const Stream &stream, const api::StreamData &data) {
if (stream_data_listener_) {

View File

@ -95,6 +95,7 @@ class Synthetic {
const DisparityComputingMethod &MethoType);
std::shared_ptr<struct CameraROSMsgInfoPair> GetCameraROSMsgInfoPair();
bool ConfigDisparityFromFile(const std::string& config_file);
bool SetRectifyAlpha(const double &alpha);
private:
void InitCalibInfo();