Merge branch 'develop' into feature/android
* develop: build(makefile): do small change fix(option.cmake): find boost quiet docs(doc): update version fix(ros): add mutex_data_ in mono fix(disable order): fix disable order DISPARITY before RECTIFIED fix(synthetic): disable order fix(ros): publish order fix(ros): fix imu count bug fix(tools): compatible avatar and s fix(samples): delete get all info sample fix(ros): set publish_imu_by_sync true fix(ros): add default intrinsics in ros node docs(readme): modified temp to temperature fix(process): opencv2 and remove some useless include fix(enum) fix DisparityProcessorType enum comment fix(bm matcher): add complie switch
This commit is contained in:
@@ -51,7 +51,7 @@ bool DepthProcessor::OnProcess(
|
||||
ObjMat *output = Object::Cast<ObjMat>(out);
|
||||
int rows = input->value.rows;
|
||||
int cols = input->value.cols;
|
||||
std::cout << calib_infos_->T_mul_f << std::endl;
|
||||
// std::cout << calib_infos_->T_mul_f << std::endl;
|
||||
// 0.0793434
|
||||
cv::Mat depth_mat = cv::Mat::zeros(rows, cols, CV_16U);
|
||||
for (int i = 0; i < rows; i++) {
|
||||
|
||||
@@ -17,9 +17,14 @@
|
||||
|
||||
#include <opencv2/calib3d/calib3d.hpp>
|
||||
#include <opencv2/imgproc/imgproc.hpp>
|
||||
#ifdef WITH_BM_SOBEL_FILTER
|
||||
#include <opencv2/ximgproc/disparity_filter.hpp>
|
||||
#endif
|
||||
|
||||
#include "mynteye/logger.h"
|
||||
|
||||
#define WITH_BM_SOBEL_FILTER
|
||||
|
||||
MYNTEYE_BEGIN_NAMESPACE
|
||||
|
||||
const char DisparityProcessor::NAME[] = "DisparityProcessor";
|
||||
@@ -62,7 +67,9 @@ DisparityProcessor::DisparityProcessor(DisparityProcessorType type,
|
||||
sgbm_matcher->setSpeckleRange(32);
|
||||
sgbm_matcher->setDisp12MaxDiff(1);
|
||||
#endif
|
||||
#ifdef WITH_BM_SOBEL_FILTER
|
||||
} else if (type_ == DisparityProcessorType::BM) {
|
||||
int bmWinSize = 3;
|
||||
#ifdef WITH_OPENCV2
|
||||
int bmWinSize = 3;
|
||||
// StereoBM
|
||||
@@ -82,7 +89,7 @@ DisparityProcessor::DisparityProcessor(DisparityProcessorType type,
|
||||
bm_matcher = cv::StereoBM::create(0, 3);
|
||||
bm_matcher->setPreFilterSize(9);
|
||||
bm_matcher->setPreFilterCap(31);
|
||||
bm_matcher->setBlockSize(15);
|
||||
bm_matcher->setBlockSize(bmWinSize);
|
||||
bm_matcher->setMinDisparity(0);
|
||||
bm_matcher->setNumDisparities(64);
|
||||
bm_matcher->setUniquenessRatio(15);
|
||||
@@ -90,9 +97,42 @@ DisparityProcessor::DisparityProcessor(DisparityProcessorType type,
|
||||
bm_matcher->setSpeckleWindowSize(100);
|
||||
bm_matcher->setSpeckleRange(4);
|
||||
bm_matcher->setPreFilterType(cv::StereoBM::PREFILTER_XSOBEL);
|
||||
#endif
|
||||
#endif
|
||||
} else {
|
||||
LOG(ERROR) << "no enum DisparityProcessorType" << static_cast<int>(type);
|
||||
LOG(ERROR) << "no enum DisparityProcessorType,use default sgbm";
|
||||
int sgbmWinSize = 3;
|
||||
int numberOfDisparities = 64;
|
||||
|
||||
#ifdef WITH_OPENCV2
|
||||
// StereoSGBM
|
||||
// http://docs.opencv.org/2.4/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html?#stereosgbm
|
||||
sgbm_matcher = cv::Ptr<cv::StereoSGBM>(
|
||||
new cv::StereoSGBM(
|
||||
0, // minDisparity
|
||||
numberOfDisparities, // numDisparities
|
||||
sgbmWinSize, // SADWindowSize
|
||||
8 * sgbmWinSize * sgbmWinSize, // P1
|
||||
32 * sgbmWinSize * sgbmWinSize, // P2
|
||||
1, // disp12MaxDiff
|
||||
63, // preFilterCap
|
||||
10, // uniquenessRatio
|
||||
100, // speckleWindowSize
|
||||
32, // speckleRange
|
||||
false)); // fullDP
|
||||
#else
|
||||
sgbm_matcher = cv::StereoSGBM::create(0, 16, 3);
|
||||
sgbm_matcher->setPreFilterCap(63);
|
||||
sgbm_matcher->setBlockSize(sgbmWinSize);
|
||||
sgbm_matcher->setP1(8 * sgbmWinSize * sgbmWinSize);
|
||||
sgbm_matcher->setP2(32 * sgbmWinSize * sgbmWinSize);
|
||||
sgbm_matcher->setMinDisparity(0);
|
||||
sgbm_matcher->setNumDisparities(numberOfDisparities);
|
||||
sgbm_matcher->setUniquenessRatio(10);
|
||||
sgbm_matcher->setSpeckleWindowSize(100);
|
||||
sgbm_matcher->setSpeckleRange(32);
|
||||
sgbm_matcher->setDisp12MaxDiff(1);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,10 +163,15 @@ bool DisparityProcessor::OnProcess(
|
||||
// It contains disparity values scaled by 16. So, to get the floating-point
|
||||
// disparity map,
|
||||
// you need to divide each disp element by 16.
|
||||
if (type_ == SGBM) {
|
||||
if (type_ == DisparityProcessorType::SGBM) {
|
||||
(*sgbm_matcher)(input->first, input->second, disparity);
|
||||
} else if (type_ == BM) {
|
||||
(*bm_matcher)(input->first, input->second, disparity);
|
||||
#ifdef WITH_BM_SOBEL_FILTER
|
||||
} else if (type_ == DisparityProcessorType::BM) {
|
||||
cv::Mat tmp1, tmp2;
|
||||
cv::cvtColor(input->first, tmp1, CV_RGB2GRAY);
|
||||
cv::cvtColor(input->second, tmp2, CV_RGB2GRAY);
|
||||
(*bm_matcher)(tmp1, tmp2, disparity);
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
// compute()
|
||||
@@ -138,12 +183,21 @@ bool DisparityProcessor::OnProcess(
|
||||
// whereas other algorithms output 32-bit floating-point disparity map.
|
||||
if (type_ == DisparityProcessorType::SGBM) {
|
||||
sgbm_matcher->compute(input->first, input->second, disparity);
|
||||
#ifdef WITH_BM_SOBEL_FILTER
|
||||
} else if (type_ == DisparityProcessorType::BM) {
|
||||
CvSize size = input->first.size();
|
||||
cv::Mat tmp1, tmp2;
|
||||
cv::cvtColor(input->first, tmp1, CV_RGB2GRAY);
|
||||
cv::cvtColor(input->second, tmp2, CV_RGB2GRAY);
|
||||
if (input->first.channels() == 1) {
|
||||
// s1030
|
||||
} else if (input->first.channels() == 3) {
|
||||
// s210
|
||||
cv::cvtColor(input->first, tmp1, CV_RGB2GRAY);
|
||||
cv::cvtColor(input->second, tmp2, CV_RGB2GRAY);
|
||||
}
|
||||
bm_matcher->compute(tmp1, tmp2, disparity);
|
||||
#endif
|
||||
} else {
|
||||
// default
|
||||
sgbm_matcher->compute(input->first, input->second, disparity);
|
||||
}
|
||||
#endif
|
||||
disparity.convertTo(output->value, CV_32F, 1./16, 1);
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <opencv2/ximgproc/disparity_filter.hpp>
|
||||
#include "mynteye/api/processor.h"
|
||||
|
||||
namespace cv {
|
||||
@@ -28,9 +27,9 @@ class StereoBM;
|
||||
enum class DisparityProcessorType : std::uint8_t {
|
||||
/** bm */
|
||||
SGBM = 0,
|
||||
/** Equidistant: KANNALA_BRANDT */
|
||||
/** sgbm */
|
||||
BM = 1,
|
||||
/** Unknow */
|
||||
/** unknow */
|
||||
UNKNOW
|
||||
};
|
||||
|
||||
|
||||
@@ -25,9 +25,6 @@
|
||||
#include "mynteye/device/device.h"
|
||||
#include <camodocal/camera_models/EquidistantCamera.h>
|
||||
#include <opencv2/core/eigen.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/program_options.hpp>
|
||||
#include <opencv2/highgui/highgui.hpp>
|
||||
#include <opencv2/opencv.hpp>
|
||||
#include <opencv2/core/core.hpp>
|
||||
|
||||
@@ -496,12 +496,12 @@ void Synthetic::DisableStreamData(const Stream &stream, std::uint32_t depth) {
|
||||
stream_enabled_mode_.erase(stream);
|
||||
switch (stream) {
|
||||
case Stream::LEFT_RECTIFIED: {
|
||||
if (IsStreamEnabledSynthetic(Stream::RIGHT_RECTIFIED)) {
|
||||
DisableStreamData(Stream::RIGHT_RECTIFIED, depth + 1);
|
||||
}
|
||||
if (IsStreamEnabledSynthetic(Stream::DISPARITY)) {
|
||||
DisableStreamData(Stream::DISPARITY, depth + 1);
|
||||
}
|
||||
if (IsStreamEnabledSynthetic(Stream::RIGHT_RECTIFIED)) {
|
||||
DisableStreamData(Stream::RIGHT_RECTIFIED, depth + 1);
|
||||
}
|
||||
if (calib_model_ == CalibrationModel::PINHOLE) {
|
||||
DeactivateProcessor<RectifyProcessorOCV>();
|
||||
#ifdef WITH_CAM_MODELS
|
||||
@@ -515,12 +515,12 @@ void Synthetic::DisableStreamData(const Stream &stream, std::uint32_t depth) {
|
||||
}
|
||||
} break;
|
||||
case Stream::RIGHT_RECTIFIED: {
|
||||
if (IsStreamEnabledSynthetic(Stream::LEFT_RECTIFIED)) {
|
||||
DisableStreamData(Stream::LEFT_RECTIFIED, depth + 1);
|
||||
}
|
||||
if (IsStreamEnabledSynthetic(Stream::DISPARITY)) {
|
||||
DisableStreamData(Stream::DISPARITY, depth + 1);
|
||||
}
|
||||
if (IsStreamEnabledSynthetic(Stream::LEFT_RECTIFIED)) {
|
||||
DisableStreamData(Stream::LEFT_RECTIFIED, depth + 1);
|
||||
}
|
||||
if (calib_model_ == CalibrationModel::PINHOLE) {
|
||||
DeactivateProcessor<RectifyProcessorOCV>();
|
||||
#ifdef WITH_CAM_MODELS
|
||||
@@ -534,13 +534,28 @@ void Synthetic::DisableStreamData(const Stream &stream, std::uint32_t depth) {
|
||||
}
|
||||
} break;
|
||||
case Stream::DISPARITY: {
|
||||
if (IsStreamEnabledSynthetic(Stream::DISPARITY_NORMALIZED)) {
|
||||
DisableStreamData(Stream::DISPARITY_NORMALIZED, depth + 1);
|
||||
if (calib_model_ == CalibrationModel::PINHOLE) {
|
||||
if (IsStreamEnabledSynthetic(Stream::DISPARITY_NORMALIZED)) {
|
||||
DisableStreamData(Stream::DISPARITY_NORMALIZED, depth + 1);
|
||||
}
|
||||
if (IsStreamEnabledSynthetic(Stream::POINTS)) {
|
||||
DisableStreamData(Stream::POINTS, depth + 1);
|
||||
}
|
||||
DeactivateProcessor<DisparityProcessor>();
|
||||
#ifdef WITH_CAM_MODELS
|
||||
} else if (calib_model_ == CalibrationModel::KANNALA_BRANDT) {
|
||||
if (IsStreamEnabledSynthetic(Stream::DISPARITY_NORMALIZED)) {
|
||||
DisableStreamData(Stream::DISPARITY_NORMALIZED, depth + 1);
|
||||
}
|
||||
if (IsStreamEnabledSynthetic(Stream::DEPTH)) {
|
||||
DisableStreamData(Stream::DEPTH, depth + 1);
|
||||
}
|
||||
DeactivateProcessor<DisparityProcessor>();
|
||||
#endif
|
||||
} else {
|
||||
LOG(ERROR) << "Unknow calib model type in device: "
|
||||
<< calib_model_;
|
||||
}
|
||||
if (IsStreamEnabledSynthetic(Stream::POINTS)) {
|
||||
DisableStreamData(Stream::POINTS, depth + 1);
|
||||
}
|
||||
DeactivateProcessor<DisparityProcessor>();
|
||||
} break;
|
||||
case Stream::DISPARITY_NORMALIZED: {
|
||||
DeactivateProcessor<DisparityNormalizedProcessor>();
|
||||
@@ -565,7 +580,7 @@ void Synthetic::DisableStreamData(const Stream &stream, std::uint32_t depth) {
|
||||
DeactivateProcessor<DepthProcessorOCV>();
|
||||
#ifdef WITH_CAM_MODELS
|
||||
} else if (calib_model_ == CalibrationModel::KANNALA_BRANDT) {
|
||||
if (IsStreamEnabledSynthetic(Stream::DEPTH)) {
|
||||
if (IsStreamEnabledSynthetic(Stream::POINTS)) {
|
||||
DisableStreamData(Stream::POINTS, depth + 1);
|
||||
}
|
||||
DeactivateProcessor<DepthProcessor>();
|
||||
@@ -613,7 +628,7 @@ void Synthetic::InitProcessors() {
|
||||
rectify_processor = rectify_processor_ocv;
|
||||
}
|
||||
auto &&disparity_processor =
|
||||
std::make_shared<DisparityProcessor>(DisparityProcessorType::BM,
|
||||
std::make_shared<DisparityProcessor>(DisparityProcessorType::SGBM,
|
||||
DISPARITY_PROC_PERIOD);
|
||||
auto &&disparitynormalized_processor =
|
||||
std::make_shared<DisparityNormalizedProcessor>(
|
||||
|
||||
Reference in New Issue
Block a user