Commit 03730e1e authored by Alexander Alekhin's avatar Alexander Alekhin

Merge remote-tracking branch 'upstream/3.4' into merge-3.4

parents 79b71ec9 de774825
......@@ -297,8 +297,8 @@ public:
/** @brief Implementation of the Zach, Pock and Bischof Dual TV-L1 Optical Flow method.
*
* @sa C. Zach, T. Pock and H. Bischof, "A Duality Based Approach for Realtime TV-L1 Optical Flow".
* @sa Javier Sanchez, Enric Meinhardt-Llopis and Gabriele Facciolo. "TV-L1 Optical Flow Estimation".
* @note C. Zach, T. Pock and H. Bischof, "A Duality Based Approach for Realtime TV-L1 Optical Flow".
* @note Javier Sanchez, Enric Meinhardt-Llopis and Gabriele Facciolo. "TV-L1 Optical Flow Estimation".
*/
class CV_EXPORTS_W OpticalFlowDual_TVL1 : public DenseOpticalFlow
{
......
set(the_description "Stereo Correspondence")
ocv_define_module(stereo opencv_imgproc opencv_features2d opencv_core opencv_calib3d opencv_tracking opencv_video)
ocv_define_module(stereo opencv_imgproc opencv_features2d opencv_core opencv_tracking)
......@@ -45,10 +45,7 @@
#define __OPENCV_STEREO_HPP__
#include "opencv2/core.hpp"
#include "opencv2/features2d.hpp"
#include "opencv2/core/affine.hpp"
#include "opencv2/stereo/descriptor.hpp"
#include "opencv2/stereo/matching.hpp"
#include <opencv2/stereo/quasi_dense_stereo.hpp>
/**
......@@ -62,8 +59,6 @@ namespace cv
{
//! @addtogroup stereo
//! @{
// void correctMatches( InputArray F, InputArray points1, InputArray points2,
// OutputArray newPoints1, OutputArray newPoints2 );
/** @brief Filters off small noise blobs (speckles) in the disparity map
@param img The input 16-bit signed disparity image
@param newVal The disparity value used to paint-off the speckles
......
......@@ -64,7 +64,9 @@ PERF_TEST_P( s_bm, sgm_perf,
Mat out1(sz, sdepth);
Ptr<StereoBinarySGBM> sgbm = StereoBinarySGBM::create(0, 16, 5);
sgbm->setBinaryKernelType(CV_DENSE_CENSUS);
declare.in(left, WARMUP_RNG)
declare
.in(left, WARMUP_RNG)
.in(right, WARMUP_RNG)
.out(out1)
.time(0.1)
.iterations(20);
......@@ -72,7 +74,7 @@ PERF_TEST_P( s_bm, sgm_perf,
{
sgbm->compute(left, right, out1);
}
SANITY_CHECK(out1);
SANITY_CHECK_NOTHING();
}
PERF_TEST_P( s_bm, bm_perf,
testing::Combine(
......@@ -103,7 +105,9 @@ PERF_TEST_P( s_bm, bm_perf,
sbm->setSpekleRemovalTechnique(CV_SPECKLE_REMOVAL_AVG_ALGORITHM);
sbm->setUsePrefilter(false);
declare.in(left, WARMUP_RNG)
declare
.in(left, WARMUP_RNG)
.in(right, WARMUP_RNG)
.out(out1)
.time(0.1)
.iterations(20);
......@@ -111,7 +115,7 @@ PERF_TEST_P( s_bm, bm_perf,
{
sbm->compute(left, right, out1);
}
SANITY_CHECK(out1);
SANITY_CHECK_NOTHING();
}
......
......@@ -66,7 +66,7 @@ PERF_TEST_P( descript_params, census_sparse_descriptor,
{
censusTransform(left,9,out1,CV_SPARSE_CENSUS);
}
SANITY_CHECK(out1);
SANITY_CHECK_NOTHING();
}
PERF_TEST_P( descript_params, star_census_transform,
testing::Combine(
......@@ -88,7 +88,7 @@ PERF_TEST_P( descript_params, star_census_transform,
{
starCensusTransform(left,9,out1);
}
SANITY_CHECK(out1);
SANITY_CHECK_NOTHING();
}
PERF_TEST_P( descript_params, modified_census_transform,
testing::Combine(
......@@ -112,7 +112,7 @@ PERF_TEST_P( descript_params, modified_census_transform,
{
modifiedCensusTransform(left,9,out1,CV_MODIFIED_CENSUS_TRANSFORM);
}
SANITY_CHECK(out1);
SANITY_CHECK_NOTHING();
}
PERF_TEST_P( descript_params, center_symetric_census,
testing::Combine(
......@@ -136,7 +136,7 @@ PERF_TEST_P( descript_params, center_symetric_census,
{
symetricCensusTransform(left,7,out1,CV_CS_CENSUS);
}
SANITY_CHECK(out1);
SANITY_CHECK_NOTHING();
}
......
......@@ -6,9 +6,6 @@
#include "opencv2/ts.hpp"
#include "opencv2/stereo.hpp"
#include "opencv2/features2d.hpp"
#include "opencv2/core/utility.hpp"
#include "opencv2/calib3d.hpp"
namespace opencv_test {
using namespace cv::stereo;
......
......@@ -64,12 +64,12 @@ namespace cv
int stride = (int)image1.step;
if(type == CV_DENSE_CENSUS)
{
parallel_for_( Range(n2, image1.rows - n2),
parallel_for_(Range(0, image1.rows),
CombinedDescriptor<1,1,1,2,CensusKernel<2> >(image1.cols, image1.rows,stride,n2,costs,CensusKernel<2>(images),n2));
}
else if(type == CV_SPARSE_CENSUS)
{
parallel_for_( Range(n2, image1.rows - n2),
parallel_for_(Range(0, image1.rows),
CombinedDescriptor<2,2,1,2,CensusKernel<2> >(image1.cols, image1.rows, stride,n2,costs,CensusKernel<2>(images),n2));
}
}
......@@ -87,12 +87,12 @@ namespace cv
int stride = (int)image1.step;
if(type == CV_DENSE_CENSUS)
{
parallel_for_( Range(n2, image1.rows - n2),
parallel_for_(Range(0, image1.rows),
CombinedDescriptor<1,1,1,1,CensusKernel<1> >(image1.cols, image1.rows,stride,n2,costs,CensusKernel<1>(images),n2));
}
else if(type == CV_SPARSE_CENSUS)
{
parallel_for_( Range(n2, image1.rows - n2),
parallel_for_(Range(0, image1.rows),
CombinedDescriptor<2,2,1,1,CensusKernel<1> >(image1.cols, image1.rows,stride,n2,costs,CensusKernel<1>(images),n2));
}
}
......@@ -106,7 +106,7 @@ namespace cv
int n2 = (kernelSize) >> 1;
Mat images[] = {img1, img2};
int *date[] = { (int *)dist1.data, (int *)dist2.data};
parallel_for_(Range(n2, img1.rows - n2), StarKernelCensus<2>(images, n2,date));
parallel_for_(Range(0, img1.rows), StarKernelCensus<2>(images, n2,date));
}
//single version of star census
CV_EXPORTS void starCensusTransform(const Mat &img1, int kernelSize, Mat &dist)
......@@ -118,14 +118,14 @@ namespace cv
int n2 = (kernelSize) >> 1;
Mat images[] = {img1};
int *date[] = { (int *)dist.data};
parallel_for_(Range(n2, img1.rows - n2), StarKernelCensus<1>(images, n2,date));
parallel_for_(Range(0, img1.rows), StarKernelCensus<1>(images, n2,date));
}
//Modified census transforms
//the first one deals with small illumination changes
//the sencond modified census transform is invariant to noise; i.e.
//if the current pixel with whom we are dooing the comparison is a noise, this descriptor will provide a better result by comparing with the mean of the window
//otherwise if the pixel is not noise the information is strengthend
CV_EXPORTS void modifiedCensusTransform(const Mat &img1, const Mat &img2, int kernelSize, Mat &dist1,Mat &dist2, const int type, int t, const Mat &IntegralImage1, const Mat &IntegralImage2 )
CV_EXPORTS void modifiedCensusTransform(const Mat &img1, const Mat &img2, int kernelSize, Mat &dist1,Mat &dist2, const int type, int t, const Mat& integralImage1, const Mat& integralImage2)
{
CV_Assert(img1.size() == img2.size());
CV_Assert(kernelSize % 2 != 0);
......@@ -139,20 +139,31 @@ namespace cv
if(type == CV_MODIFIED_CENSUS_TRANSFORM)
{
//MCT
parallel_for_( Range(n2, img1.rows - n2),
parallel_for_(Range(0, img1.rows),
CombinedDescriptor<2,4,2, 2,MCTKernel<2> >(img1.cols, img1.rows,stride,n2,date,MCTKernel<2>(images,t),n2));
}
else if(type == CV_MEAN_VARIATION)
{
//MV
int *integral[2];
integral[0] = (int *)IntegralImage1.data;
integral[1] = (int *)IntegralImage2.data;
parallel_for_( Range(n2, img1.rows - n2),
CV_Assert(!integralImage1.empty());
CV_Assert(!integralImage1.isContinuous());
CV_CheckTypeEQ(integralImage1.type(), CV_32SC1, "");
CV_CheckGE(integralImage1.cols, img1.cols, "");
CV_CheckGE(integralImage1.rows, img1.rows, "");
CV_Assert(!integralImage2.empty());
CV_Assert(!integralImage2.isContinuous());
CV_CheckTypeEQ(integralImage2.type(), CV_32SC1, "");
CV_CheckGE(integralImage2.cols, img2.cols, "");
CV_CheckGE(integralImage2.rows, img2.rows, "");
int *integral[2] = {
(int *)integralImage1.data,
(int *)integralImage2.data
};
parallel_for_(Range(0, img1.rows),
CombinedDescriptor<2,3,2,2, MVKernel<2> >(img1.cols, img1.rows,stride,n2,date,MVKernel<2>(images,integral),n2));
}
}
CV_EXPORTS void modifiedCensusTransform(const Mat &img1, int kernelSize, Mat &dist, const int type, int t , Mat const &IntegralImage)
CV_EXPORTS void modifiedCensusTransform(const Mat &img1, int kernelSize, Mat &dist, const int type, int t , Mat const &integralImage)
{
CV_Assert(img1.size() == dist.size());
CV_Assert(kernelSize % 2 != 0);
......@@ -166,14 +177,19 @@ namespace cv
if(type == CV_MODIFIED_CENSUS_TRANSFORM)
{
//MCT
parallel_for_(Range(n2, img1.rows - n2),
parallel_for_(Range(0, img1.rows),
CombinedDescriptor<2,4,2, 1,MCTKernel<1> >(img1.cols, img1.rows,stride,n2,date,MCTKernel<1>(images,t),n2));
}
else if(type == CV_MEAN_VARIATION)
{
//MV
int *integral[] = { (int *)IntegralImage.data};
parallel_for_(Range(n2, img1.rows - n2),
CV_Assert(!integralImage.empty());
CV_Assert(!integralImage.isContinuous());
CV_CheckTypeEQ(integralImage.type(), CV_32SC1, "");
CV_CheckGE(integralImage.cols, img1.cols, "");
CV_CheckGE(integralImage.rows, img1.rows, "");
int *integral[] = { (int *)integralImage.data};
parallel_for_(Range(0, img1.rows),
CombinedDescriptor<2,3,2,1, MVKernel<1> >(img1.cols, img1.rows,stride,n2,date,MVKernel<1>(images,integral),n2));
}
}
......@@ -193,11 +209,11 @@ namespace cv
int stride = (int)img1.step;
if(type == CV_CS_CENSUS)
{
parallel_for_(Range(n2, img1.rows - n2), SymetricCensus<2>(imag, n2,date));
parallel_for_(Range(0, img1.rows), SymetricCensus<2>(imag, n2,date));
}
else if(type == CV_MODIFIED_CS_CENSUS)
{
parallel_for_(Range(n2, img1.rows - n2),
parallel_for_(Range(0, img1.rows),
CombinedDescriptor<1,1,1,2,ModifiedCsCensus<2> >(img1.cols, img1.rows,stride,n2,date,ModifiedCsCensus<2>(images,n2),1));
}
}
......@@ -215,26 +231,13 @@ namespace cv
int stride = (int)img1.step;
if(type == CV_CS_CENSUS)
{
parallel_for_( Range(n2, img1.rows - n2), SymetricCensus<1>(imag, n2,date));
parallel_for_(Range(0, img1.rows), SymetricCensus<1>(imag, n2,date));
}
else if(type == CV_MODIFIED_CS_CENSUS)
{
parallel_for_( Range(n2, img1.rows - n2),
parallel_for_( Range(0, img1.rows),
CombinedDescriptor<1,1,1,1,ModifiedCsCensus<1> >(img1.cols, img1.rows,stride,n2,date,ModifiedCsCensus<1>(images,n2),1));
}
}
//integral image computation used in the Mean Variation Census Transform
void imageMeanKernelSize(const Mat &image, int windowSize, Mat &cost)
{
CV_Assert(!image.empty());
CV_Assert(!cost.empty());
CV_Assert(windowSize % 2 != 0);
int win = windowSize / 2;
float scalling = ((float) 1) / (windowSize * windowSize);
int height = image.rows;
cost.setTo(0);
int *c = (int *)cost.data;
parallel_for_(Range(win + 1, height - win - 1),MeanKernelIntegralImage(image,win,scalling,c));
}
}
}
This diff is collapsed.
......@@ -42,16 +42,13 @@
#ifndef __OPENCV_STEREO_PRECOMP_H__
#define __OPENCV_STEREO_PRECOMP_H__
#include "opencv2/stereo.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/features2d.hpp"
#include "opencv2/core.hpp"
#include "opencv2/core/utility.hpp"
#include "opencv2/core/private.hpp"
#include "opencv2/core/cvdef.h"
#include "opencv2/imgproc.hpp"
#include "opencv2/calib3d.hpp"
#include <algorithm>
#include <cmath>
#include "opencv2/stereo.hpp"
#include "descriptor.hpp"
#include "matching.hpp"
#endif
......@@ -384,15 +384,10 @@ namespace cv
}
else if(params.kernelType == CV_MEAN_VARIATION)
{
parSumsIntensityImage[0].create(left0.rows, left0.cols,CV_32SC4);
parSumsIntensityImage[1].create(left0.rows, left0.cols,CV_32SC4);
Integral[0].create(left0.rows,left0.cols,CV_32SC4);
Integral[1].create(left0.rows,left0.cols,CV_32SC4);
integral(left, parSumsIntensityImage[0],CV_32S);
integral(right, parSumsIntensityImage[1],CV_32S);
imageMeanKernelSize(parSumsIntensityImage[0], params.kernelSize,Integral[0]);
imageMeanKernelSize(parSumsIntensityImage[1], params.kernelSize, Integral[1]);
modifiedCensusTransform(left,right,params.kernelSize,censusImage[0],censusImage[1],CV_MEAN_VARIATION,0,Integral[0], Integral[1]);
Mat blurLeft; blur(left, blurLeft, Size(params.kernelSize, params.kernelSize));
Mat blurRight; blur(right, blurRight, Size(params.kernelSize, params.kernelSize));
modifiedCensusTransform(left, right, params.kernelSize, censusImage[0], censusImage[1], CV_MEAN_VARIATION, 0,
blurLeft, blurRight);
}
else if(params.kernelType == CV_STAR_KERNEL)
{
......@@ -407,7 +402,7 @@ namespace cv
if(params.regionRemoval == CV_SPECKLE_REMOVAL_AVG_ALGORITHM)
{
smallRegionRemoval<uint8_t>(disp0,params.speckleWindowSize,disp0);
smallRegionRemoval<uint8_t>(disp0.clone(),params.speckleWindowSize,disp0);
}
else if(params.regionRemoval == CV_SPECKLE_REMOVAL_ALGORITHM)
{
......@@ -502,8 +497,6 @@ namespace cv
StereoBinaryBMParams params;
Mat preFilteredImg0, preFilteredImg1, cost, dispbuf;
Mat slidingSumBuf;
Mat parSumsIntensityImage[2];
Mat Integral[2];
Mat censusImage[2];
Mat hammingDistance;
Mat partialSumsLR;
......
......@@ -669,15 +669,10 @@ namespace cv
}
else if(params.kernelType == CV_MEAN_VARIATION)
{
parSumsIntensityImage[0].create(left.rows, left.cols,CV_32SC4);
parSumsIntensityImage[1].create(left.rows, left.cols,CV_32SC4);
Integral[0].create(left.rows,left.cols,CV_32SC4);
Integral[1].create(left.rows,left.cols,CV_32SC4);
integral(left, parSumsIntensityImage[0],CV_32S);
integral(right, parSumsIntensityImage[1],CV_32S);
imageMeanKernelSize(parSumsIntensityImage[0], params.kernelSize,Integral[0]);
imageMeanKernelSize(parSumsIntensityImage[1], params.kernelSize, Integral[1]);
modifiedCensusTransform(left,right,params.kernelSize,censusImageLeft,censusImageRight,CV_MEAN_VARIATION,0,Integral[0], Integral[1]);
Mat blurLeft; blur(left, blurLeft, Size(params.kernelSize, params.kernelSize));
Mat blurRight; blur(right, blurRight, Size(params.kernelSize, params.kernelSize));
modifiedCensusTransform(left, right, params.kernelSize, censusImageLeft, censusImageRight, CV_MEAN_VARIATION, 0,
blurLeft, blurRight);
}
else if(params.kernelType == CV_STAR_KERNEL)
{
......@@ -702,7 +697,7 @@ namespace cv
aux.create(height,width,CV_16S);
Median1x9Filter<short>(disp, aux);
Median9x1Filter<short>(aux,disp);
smallRegionRemoval<short>(disp, params.speckleWindowSize, disp);
smallRegionRemoval<short>(disp.clone(), params.speckleWindowSize, disp);
}
else if(params.regionRemoval == CV_SPECKLE_REMOVAL_ALGORITHM)
{
......@@ -800,8 +795,6 @@ namespace cv
Mat partialSumsLR;
Mat agregatedHammingLRCost;
Mat hamDist;
Mat parSumsIntensityImage[2];
Mat Integral[2];
};
const char* StereoBinarySGBMImpl::name_ = "StereoBinaryMatcher.SGBM";
......
......@@ -6,8 +6,6 @@
#include "opencv2/ts.hpp"
#include "opencv2/stereo.hpp"
#include "opencv2/features2d.hpp"
#include "opencv2/calib3d.hpp"
namespace opencv_test {
using namespace cv::stereo;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment