diff --git a/CMakeLists.txt b/CMakeLists.txt index 9386eb6..10eaa68 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -213,8 +213,6 @@ if(WITH_API) src/mynteye/api/processor/disparity_processor.cc src/mynteye/api/processor/disparity_normalized_processor.cc src/mynteye/api/processor/root_camera_processor.cc - src/mynteye/api/processor/points_processor_ocv.cc - src/mynteye/api/processor/depth_processor_ocv.cc src/mynteye/api/processor/rectify_processor_ocv.cc src/mynteye/api/correspondence.cc src/mynteye/api/version_checker.cc diff --git a/src/mynteye/api/processor/depth_processor.h b/src/mynteye/api/processor/depth_processor.h index beff7cc..609caa9 100644 --- a/src/mynteye/api/processor/depth_processor.h +++ b/src/mynteye/api/processor/depth_processor.h @@ -45,6 +45,7 @@ class DepthProcessor : public Processor { bool OnProcess( Object *const in, Object *const out, std::shared_ptr const parent) override; + private: std::shared_ptr calib_infos_; std::shared_ptr min_disp_; diff --git a/src/mynteye/api/processor/depth_processor_ocv.cc b/src/mynteye/api/processor/depth_processor_ocv.cc deleted file mode 100644 index 0afb381..0000000 --- a/src/mynteye/api/processor/depth_processor_ocv.cc +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2018 Slightech Co., Ltd. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#include "mynteye/api/processor/depth_processor_ocv.h" - -#include - -#include "mynteye/logger.h" - -MYNTEYE_BEGIN_NAMESPACE - -const char DepthProcessorOCV::NAME[] = "DepthProcessorOCV"; - -DepthProcessorOCV::DepthProcessorOCV(std::int32_t proc_period) - : Processor(std::move(proc_period)) { - VLOG(2) << __func__ << ": proc_period=" << proc_period; -} - -DepthProcessorOCV::~DepthProcessorOCV() { - VLOG(2) << __func__; -} - -std::string DepthProcessorOCV::Name() { - return NAME; -} - -Object *DepthProcessorOCV::OnCreateOutput() { - return new ObjMat(); -} - -bool DepthProcessorOCV::OnProcess( - Object *const in, Object *const out, - std::shared_ptr const parent) { - MYNTEYE_UNUSED(parent) - const ObjMat *input = Object::Cast(in); - ObjMat *output = Object::Cast(out); - cv::Mat channels[3 /*input->value.channels()*/]; - cv::split(input->value, channels); - channels[2].convertTo(output->value, CV_16UC1); - output->id = input->id; - output->data = input->data; - return true; -} - -MYNTEYE_END_NAMESPACE diff --git a/src/mynteye/api/processor/depth_processor_ocv.h b/src/mynteye/api/processor/depth_processor_ocv.h deleted file mode 100644 index 38a54ec..0000000 --- a/src/mynteye/api/processor/depth_processor_ocv.h +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2018 Slightech Co., Ltd. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#ifndef MYNTEYE_API_PROCESSOR_DEPTH_PROCESSOR_OCV_H_ -#define MYNTEYE_API_PROCESSOR_DEPTH_PROCESSOR_OCV_H_ -#pragma once -#include -#include - -#include "mynteye/api/processor.h" - -MYNTEYE_BEGIN_NAMESPACE - -class DepthProcessorOCV : public Processor { - public: - static const char NAME[]; - - explicit DepthProcessorOCV(std::int32_t proc_period = 0); - virtual ~DepthProcessorOCV(); - - std::string Name() override; - - protected: - Object *OnCreateOutput() override; - bool OnProcess( - Object *const in, Object *const out, - std::shared_ptr const parent) override; -}; - -MYNTEYE_END_NAMESPACE - -#endif // MYNTEYE_API_PROCESSOR_DEPTH_PROCESSOR_OCV_H_ diff --git a/src/mynteye/api/processor/points_processor_ocv.cc b/src/mynteye/api/processor/points_processor_ocv.cc deleted file mode 100644 index e0b4391..0000000 --- a/src/mynteye/api/processor/points_processor_ocv.cc +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2018 Slightech Co., Ltd. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#include "mynteye/api/processor/points_processor_ocv.h" - -#include - -#include - -#include "mynteye/logger.h" - -MYNTEYE_BEGIN_NAMESPACE - -const char PointsProcessorOCV::NAME[] = "PointsProcessorOCV"; - -PointsProcessorOCV::PointsProcessorOCV(cv::Mat Q, std::int32_t proc_period) - : Processor(std::move(proc_period)), Q_(std::move(Q)) { - VLOG(2) << __func__ << ": proc_period=" << proc_period; -} - -PointsProcessorOCV::~PointsProcessorOCV() { - VLOG(2) << __func__; -} - -std::string PointsProcessorOCV::Name() { - return NAME; -} - -Object *PointsProcessorOCV::OnCreateOutput() { - return new ObjMat(); -} - -bool PointsProcessorOCV::OnProcess( - Object *const in, Object *const out, - std::shared_ptr const parent) { - MYNTEYE_UNUSED(parent) - const ObjMat *input = Object::Cast(in); - ObjMat *output = Object::Cast(out); - cv::reprojectImageTo3D(input->value, output->value, Q_, true); - output->id = input->id; - output->data = input->data; - return true; -} - -MYNTEYE_END_NAMESPACE diff --git a/src/mynteye/api/processor/points_processor_ocv.h b/src/mynteye/api/processor/points_processor_ocv.h deleted file mode 100644 index 9e9b762..0000000 --- a/src/mynteye/api/processor/points_processor_ocv.h +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2018 Slightech Co., Ltd. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#ifndef MYNTEYE_API_PROCESSOR_POINTS_PROCESSOR_OCV_H_ -#define MYNTEYE_API_PROCESSOR_POINTS_PROCESSOR_OCV_H_ -#pragma once - -#include -#include -#include - -#include "mynteye/api/processor.h" - -MYNTEYE_BEGIN_NAMESPACE - -class PointsProcessorOCV : public Processor { - public: - static const char NAME[]; - - explicit PointsProcessorOCV(cv::Mat Q, std::int32_t proc_period = 0); - virtual ~PointsProcessorOCV(); - - std::string Name() override; - - protected: - Object *OnCreateOutput() override; - bool OnProcess( - Object *const in, Object *const out, - std::shared_ptr const parent) override; - // inline Processor::process_type ProcessOutputConnection() override { - // return Processor::WITHOUT_CLONE; - // } - // inline Processor::process_type ProcessInputConnection() override { - // return Processor::WITHOUT_CLONE; - // } - - private: - cv::Mat Q_; -}; - -MYNTEYE_END_NAMESPACE - -#endif // MYNTEYE_API_PROCESSOR_POINTS_PROCESSOR_OCV_H_ diff --git a/src/mynteye/api/processor/rectify_processor.cc b/src/mynteye/api/processor/rectify_processor.cc index 242df4f..379debb 100644 --- a/src/mynteye/api/processor/rectify_processor.cc +++ b/src/mynteye/api/processor/rectify_processor.cc @@ -228,6 +228,8 @@ void RectifyProcessor::stereoRectify(models::CameraPtr leftOdo, cvmSet(_P2, idx, 3, s*cvmGet(_P2, idx, 3)); *cx1_min_cx2 = -(cx1 - cx2); + // std::cout << "info_pair.T_mul_f :" << *T_mul_f << std::endl; + // std::cout << "info_pair.cx1_minus_cx2 :" << *cx1_min_cx2 << std::endl; } } diff --git a/src/mynteye/api/processor/rectify_processor_ocv.cc b/src/mynteye/api/processor/rectify_processor_ocv.cc index c2c6496..4e5a9ae 100644 --- a/src/mynteye/api/processor/rectify_processor_ocv.cc +++ b/src/mynteye/api/processor/rectify_processor_ocv.cc @@ -164,6 +164,10 @@ void RectifyProcessorOCV::InitParams( info_pair.P[i] = info_pair.left.P[i]; } + info_pair.T_mul_f = -1.f * in_left.fx * ex_right_to_left.translation[0]; + info_pair.cx1_minus_cx2 = 0.-(in_left.cx - in_right.cx); + // std::cout << "info_pair.T_mul_f :" << info_pair.T_mul_f << std::endl; + // std::cout << "info_pair.cx1_minus_cx2 :" << info_pair.cx1_minus_cx2 << std::endl; *calib_infos = info_pair; cv::initUndistortRectifyMap(M1, D1, R1, P1, size, CV_16SC2, map11, map12); diff --git a/src/mynteye/api/synthetic.cc b/src/mynteye/api/synthetic.cc index 168be88..5beebc7 100644 --- a/src/mynteye/api/synthetic.cc +++ b/src/mynteye/api/synthetic.cc @@ -27,8 +27,6 @@ #include "mynteye/api/processor/disparity_processor.h" #include "mynteye/api/processor/root_camera_processor.h" #include "mynteye/api/processor/rectify_processor_ocv.h" -#include "mynteye/api/processor/depth_processor_ocv.h" -#include "mynteye/api/processor/points_processor_ocv.h" #ifdef WITH_CAM_MODELS #include "mynteye/api/processor/depth_processor.h" #include "mynteye/api/processor/points_processor.h" @@ -328,19 +326,25 @@ void Synthetic::InitProcessors() { std::make_shared(intr_left_, intr_right_, extr_, RECTIFY_PROC_PERIOD); rectify_processor = rectify_processor_ocv; - points_processor = std::make_shared( - rectify_processor_ocv->Q, POINTS_PROC_PERIOD); - disparity_processor = + points_processor = std::make_shared( + rectify_processor_ocv -> getCameraROSMsgInfoPair(), + POINTS_PROC_PERIOD); + auto disparity_processor_imp = std::make_shared(DisparityComputingMethod::BM, nullptr, DISPARITY_PROC_PERIOD); - depth_processor = std::make_shared(DEPTH_PROC_PERIOD); + depth_processor = std::make_shared( + rectify_processor_ocv -> getCameraROSMsgInfoPair(), + disparity_processor_imp->GetMinDisparity(), + disparity_processor_imp->GetMaxDisparity(), + DEPTH_PROC_PERIOD); + disparity_processor = disparity_processor_imp; root_processor->AddChild(rectify_processor); rectify_processor->AddChild(disparity_processor); disparity_processor->AddChild(disparitynormalized_processor); - disparity_processor->AddChild(points_processor); - points_processor->AddChild(depth_processor); + disparity_processor->AddChild(depth_processor); + depth_processor->AddChild(points_processor); #ifdef WITH_CAM_MODELS } else if (calib_model_ == CalibrationModel::KANNALA_BRANDT) { // KANNALA_BRANDT