mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 15:53:03 +04:00
Merge remote-tracking branch 'upstream/3.4' into merge-3.4
Revert "documentation: avoid links to 'master' branch from 3.4 maintenance branch" This reverts commit9ba9358ecb. Revert "documentation: avoid links to 'master' branch from 3.4 maintenance branch (2)" This reverts commitf185802489.
This commit is contained in:
@@ -76,13 +76,17 @@
|
||||
#include <stdarg.h>
|
||||
#include <vector>
|
||||
|
||||
using namespace cv;
|
||||
using namespace std;
|
||||
#include "opencv2/core/utility.hpp"
|
||||
#include <opencv2/core/utils/logger.defines.hpp>
|
||||
|
||||
//#define ENABLE_TRIM_COL_ROW
|
||||
|
||||
//#define DEBUG_CHESSBOARD
|
||||
|
||||
//#undef CV_LOG_STRIP_LEVEL
|
||||
//#define CV_LOG_STRIP_LEVEL CV_LOG_LEVEL_VERBOSE + 1
|
||||
#include <opencv2/core/utils/logger.hpp>
|
||||
|
||||
#ifdef DEBUG_CHESSBOARD
|
||||
static int PRINTF( const char* fmt, ... )
|
||||
{
|
||||
@@ -94,17 +98,34 @@ static int PRINTF( const char* fmt, ... )
|
||||
#define PRINTF(...)
|
||||
#endif
|
||||
|
||||
using namespace cv;
|
||||
using namespace std;
|
||||
|
||||
//=====================================================================================
|
||||
// Implementation for the enhanced calibration object detection
|
||||
//=====================================================================================
|
||||
|
||||
#define MAX_CONTOUR_APPROX 7
|
||||
|
||||
#define USE_CV_FINDCONTOURS // switch between cv::findContours() and legacy C API
|
||||
#ifdef USE_CV_FINDCONTOURS
|
||||
struct QuadCountour {
|
||||
Point pt[4];
|
||||
int parent_contour;
|
||||
|
||||
QuadCountour(const Point pt_[4], int parent_contour_) :
|
||||
parent_contour(parent_contour_)
|
||||
{
|
||||
pt[0] = pt_[0]; pt[1] = pt_[1]; pt[2] = pt_[2]; pt[3] = pt_[3];
|
||||
}
|
||||
};
|
||||
#else
|
||||
struct CvContourEx
|
||||
{
|
||||
CV_CONTOUR_FIELDS()
|
||||
int counter;
|
||||
};
|
||||
#endif
|
||||
|
||||
//=====================================================================================
|
||||
|
||||
@@ -517,7 +538,11 @@ int cvFindChessboardCorners( const void* arr, CvSize pattern_size,
|
||||
int max_quad_buf_size = 0;
|
||||
cvFree(&quads);
|
||||
cvFree(&corners);
|
||||
#ifdef USE_CV_FINDCONTOURS
|
||||
Mat binarized_img = thresh_img_new;
|
||||
#else
|
||||
Mat binarized_img = thresh_img_new.clone(); // make clone because cvFindContours modifies the source image
|
||||
#endif
|
||||
int quad_count = icvGenerateQuads( &quads, &corners, storage, binarized_img, flags, &max_quad_buf_size );
|
||||
PRINTF("Quad count: %d/%d\n", quad_count, (pattern_size.width/2+1)*(pattern_size.height/2+1));
|
||||
SHOW_QUADS("New quads", thresh_img_new, quads, quad_count);
|
||||
@@ -583,7 +608,11 @@ int cvFindChessboardCorners( const void* arr, CvSize pattern_size,
|
||||
int max_quad_buf_size = 0;
|
||||
cvFree(&quads);
|
||||
cvFree(&corners);
|
||||
#ifdef USE_CV_FINDCONTOURS
|
||||
Mat binarized_img = thresh_img;
|
||||
#else
|
||||
Mat binarized_img = (useAdaptive) ? thresh_img : thresh_img.clone(); // make clone because cvFindContours modifies the source image
|
||||
#endif
|
||||
int quad_count = icvGenerateQuads( &quads, &corners, storage, binarized_img, flags, &max_quad_buf_size);
|
||||
PRINTF("Quad count: %d/%d\n", quad_count, (pattern_size.width/2+1)*(pattern_size.height/2+1));
|
||||
SHOW_QUADS("Old quads", thresh_img, quads, quad_count);
|
||||
@@ -1736,7 +1765,6 @@ static int
|
||||
icvGenerateQuads( CvCBQuad **out_quads, CvCBCorner **out_corners,
|
||||
CvMemStorage *storage, const cv::Mat & image_, int flags, int *max_quad_buf_size )
|
||||
{
|
||||
CvMat image_old(image_), *image = &image_old;
|
||||
int quad_count = 0;
|
||||
cv::Ptr<CvMemStorage> temp_storage;
|
||||
|
||||
@@ -1746,17 +1774,144 @@ icvGenerateQuads( CvCBQuad **out_quads, CvCBCorner **out_corners,
|
||||
if( out_corners )
|
||||
*out_corners = 0;
|
||||
|
||||
// empiric bound for minimal allowed perimeter for squares
|
||||
int min_size = 25; //cvRound( image->cols * image->rows * .03 * 0.01 * 0.92 );
|
||||
|
||||
bool filterQuads = (flags & CALIB_CB_FILTER_QUADS) != 0;
|
||||
#ifdef USE_CV_FINDCONTOURS // use cv::findContours
|
||||
CV_UNUSED(storage);
|
||||
|
||||
std::vector<std::vector<Point> > contours;
|
||||
std::vector<Vec4i> hierarchy;
|
||||
|
||||
cv::findContours(image_, contours, hierarchy, RETR_CCOMP, CHAIN_APPROX_SIMPLE);
|
||||
|
||||
if (contours.empty())
|
||||
{
|
||||
CV_LOG_DEBUG(NULL, "calib3d(chessboard): cv::findContours() returns no contours");
|
||||
*max_quad_buf_size = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::vector<int> contour_child_counter(contours.size(), 0);
|
||||
int boardIdx = -1;
|
||||
|
||||
std::vector<QuadCountour> contour_quads;
|
||||
|
||||
for (int idx = (int)(contours.size() - 1); idx >= 0; --idx)
|
||||
{
|
||||
int parentIdx = hierarchy[idx][3];
|
||||
if (hierarchy[idx][2] != -1 || parentIdx == -1) // holes only (no child contours and with parent)
|
||||
continue;
|
||||
const std::vector<Point>& contour = contours[idx];
|
||||
|
||||
Rect contour_rect = boundingRect(contour);
|
||||
if (contour_rect.area() < min_size)
|
||||
continue;
|
||||
|
||||
std::vector<Point> approx_contour;
|
||||
|
||||
const int min_approx_level = 1, max_approx_level = MAX_CONTOUR_APPROX;
|
||||
for (int approx_level = min_approx_level; approx_level <= max_approx_level; approx_level++ )
|
||||
{
|
||||
approxPolyDP(contour, approx_contour, (float)approx_level, true);
|
||||
if (approx_contour.size() == 4)
|
||||
break;
|
||||
|
||||
// we call this again on its own output, because sometimes
|
||||
// approxPoly() does not simplify as much as it should.
|
||||
std::vector<Point> approx_contour_tmp;
|
||||
std::swap(approx_contour, approx_contour_tmp);
|
||||
approxPolyDP(approx_contour_tmp, approx_contour, (float)approx_level, true);
|
||||
if (approx_contour.size() == 4)
|
||||
break;
|
||||
}
|
||||
|
||||
// reject non-quadrangles
|
||||
if (approx_contour.size() != 4)
|
||||
continue;
|
||||
if (!cv::isContourConvex(approx_contour))
|
||||
continue;
|
||||
|
||||
cv::Point pt[4];
|
||||
for (int i = 0; i < 4; ++i)
|
||||
pt[i] = approx_contour[i];
|
||||
CV_LOG_VERBOSE(NULL, 9, "... contours(" << contour_quads.size() << " added):" << pt[0] << " " << pt[1] << " " << pt[2] << " " << pt[3]);
|
||||
|
||||
if (filterQuads)
|
||||
{
|
||||
double p = cv::arcLength(approx_contour, true);
|
||||
double area = cv::contourArea(approx_contour, false);
|
||||
|
||||
double d1 = sqrt(normL2Sqr<double>(pt[0] - pt[2]));
|
||||
double d2 = sqrt(normL2Sqr<double>(pt[1] - pt[3]));
|
||||
|
||||
// philipg. Only accept those quadrangles which are more square
|
||||
// than rectangular and which are big enough
|
||||
double d3 = sqrt(normL2Sqr<double>(pt[0] - pt[1]));
|
||||
double d4 = sqrt(normL2Sqr<double>(pt[1] - pt[2]));
|
||||
if (!(d3*4 > d4 && d4*4 > d3 && d3*d4 < area*1.5 && area > min_size &&
|
||||
d1 >= 0.15 * p && d2 >= 0.15 * p))
|
||||
continue;
|
||||
}
|
||||
|
||||
contour_child_counter[parentIdx]++;
|
||||
if (boardIdx != parentIdx && (boardIdx < 0 || contour_child_counter[boardIdx] < contour_child_counter[parentIdx]))
|
||||
boardIdx = parentIdx;
|
||||
|
||||
contour_quads.push_back(QuadCountour(pt, parentIdx));
|
||||
}
|
||||
|
||||
size_t total = contour_quads.size();
|
||||
*max_quad_buf_size = (int)std::max((size_t)2, total * 3);
|
||||
*out_quads = (CvCBQuad*)cvAlloc(*max_quad_buf_size * sizeof((*out_quads)[0]));
|
||||
*out_corners = (CvCBCorner*)cvAlloc(*max_quad_buf_size * 4 * sizeof((*out_corners)[0]));
|
||||
|
||||
// Create array of quads structures
|
||||
for(int idx = 0; idx < (int)contour_quads.size(); idx++ )
|
||||
{
|
||||
CvCBQuad* q = &(*out_quads)[quad_count];
|
||||
|
||||
QuadCountour& qc = contour_quads[idx];
|
||||
if (filterQuads && qc.parent_contour != boardIdx)
|
||||
continue;
|
||||
|
||||
// reset group ID
|
||||
memset(q, 0, sizeof(*q));
|
||||
q->group_idx = -1;
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
CvCBCorner* corner = &(*out_corners)[quad_count*4 + i];
|
||||
|
||||
memset(corner, 0, sizeof(*corner));
|
||||
corner->pt = qc.pt[i];
|
||||
q->corners[i] = corner;
|
||||
}
|
||||
q->edge_len = FLT_MAX;
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
// TODO simplify with normL2Sqr<float>()
|
||||
float dx = q->corners[i]->pt.x - q->corners[(i+1)&3]->pt.x;
|
||||
float dy = q->corners[i]->pt.y - q->corners[(i+1)&3]->pt.y;
|
||||
float d = dx*dx + dy*dy;
|
||||
if (q->edge_len > d)
|
||||
q->edge_len = d;
|
||||
}
|
||||
quad_count++;
|
||||
}
|
||||
|
||||
#else // use legacy API: cvStartFindContours / cvFindNextContour / cvEndFindContours
|
||||
|
||||
CvMat image_old(image_), *image = &image_old;
|
||||
|
||||
CvSeq *src_contour = 0;
|
||||
CvSeq *root;
|
||||
CvContourEx* board = 0;
|
||||
CvContourScanner scanner;
|
||||
int i, idx, min_size;
|
||||
int i, idx;
|
||||
|
||||
CV_Assert( out_corners && out_quads );
|
||||
|
||||
// empiric bound for minimal allowed perimeter for squares
|
||||
min_size = 25; //cvRound( image->cols * image->rows * .03 * 0.01 * 0.92 );
|
||||
|
||||
// create temporary storage for contours and the sequence of pointers to found quadrangles
|
||||
temp_storage.reset(cvCreateChildMemStorage( storage ));
|
||||
root = cvCreateSeq( 0, sizeof(CvSeq), sizeof(CvSeq*), temp_storage );
|
||||
@@ -1820,9 +1975,9 @@ icvGenerateQuads( CvCBQuad **out_quads, CvCBCorner **out_corners,
|
||||
dx = pt[1].x - pt[2].x;
|
||||
dy = pt[1].y - pt[2].y;
|
||||
d4 = sqrt(dx*dx + dy*dy);
|
||||
if( !(flags & CV_CALIB_CB_FILTER_QUADS) ||
|
||||
if (!filterQuads ||
|
||||
(d3*4 > d4 && d4*4 > d3 && d3*d4 < area*1.5 && area > min_size &&
|
||||
d1 >= 0.15 * p && d2 >= 0.15 * p) )
|
||||
d1 >= 0.15 * p && d2 >= 0.15 * p))
|
||||
{
|
||||
CvContourEx* parent = (CvContourEx*)(src_contour->v_prev);
|
||||
parent->counter++;
|
||||
@@ -1840,7 +1995,8 @@ icvGenerateQuads( CvCBQuad **out_quads, CvCBCorner **out_corners,
|
||||
cvEndFindContours( &scanner );
|
||||
|
||||
// allocate quad & corner buffers
|
||||
*max_quad_buf_size = MAX(1, (root->total+root->total / 2)) * 2;
|
||||
int total = root->total;
|
||||
*max_quad_buf_size = MAX(1, (total + total / 2)) * 2;
|
||||
*out_quads = (CvCBQuad*)cvAlloc(*max_quad_buf_size * sizeof((*out_quads)[0]));
|
||||
*out_corners = (CvCBCorner*)cvAlloc(*max_quad_buf_size * 4 * sizeof((*out_corners)[0]));
|
||||
|
||||
@@ -1849,7 +2005,7 @@ icvGenerateQuads( CvCBQuad **out_quads, CvCBCorner **out_corners,
|
||||
{
|
||||
CvCBQuad* q = &(*out_quads)[quad_count];
|
||||
src_contour = *(CvSeq**)cvGetSeqElem( root, idx );
|
||||
if( (flags & CV_CALIB_CB_FILTER_QUADS) && src_contour->v_prev != (CvSeq*)board )
|
||||
if (filterQuads && src_contour->v_prev != (CvSeq*)board)
|
||||
continue;
|
||||
|
||||
// reset group ID
|
||||
@@ -1878,6 +2034,11 @@ icvGenerateQuads( CvCBQuad **out_quads, CvCBCorner **out_corners,
|
||||
}
|
||||
quad_count++;
|
||||
}
|
||||
#endif
|
||||
|
||||
CV_LOG_VERBOSE(NULL, 3, "Total quad contours: " << total);
|
||||
CV_LOG_VERBOSE(NULL, 3, "max_quad_buf_size=" << *max_quad_buf_size);
|
||||
CV_LOG_VERBOSE(NULL, 3, "filtered quad_count=" << quad_count);
|
||||
|
||||
return quad_count;
|
||||
}
|
||||
|
||||
@@ -78,10 +78,7 @@ class RANSACPointSetRegistrator : public PointSetRegistrator
|
||||
public:
|
||||
RANSACPointSetRegistrator(const Ptr<PointSetRegistrator::Callback>& _cb=Ptr<PointSetRegistrator::Callback>(),
|
||||
int _modelPoints=0, double _threshold=0, double _confidence=0.99, int _maxIters=1000)
|
||||
: cb(_cb), modelPoints(_modelPoints), threshold(_threshold), confidence(_confidence), maxIters(_maxIters)
|
||||
{
|
||||
checkPartialSubsets = false;
|
||||
}
|
||||
: cb(_cb), modelPoints(_modelPoints), threshold(_threshold), confidence(_confidence), maxIters(_maxIters) {}
|
||||
|
||||
int findInliers( const Mat& m1, const Mat& m2, const Mat& model, Mat& err, Mat& mask, double thresh ) const
|
||||
{
|
||||
@@ -143,17 +140,9 @@ public:
|
||||
ms1ptr[i*esz1 + k] = m1ptr[idx_i*esz1 + k];
|
||||
for( k = 0; k < esz2; k++ )
|
||||
ms2ptr[i*esz2 + k] = m2ptr[idx_i*esz2 + k];
|
||||
if( checkPartialSubsets && !cb->checkSubset( ms1, ms2, i+1 ))
|
||||
{
|
||||
// we may have selected some bad points;
|
||||
// so, let's remove some of them randomly
|
||||
i = rng.uniform(0, i+1);
|
||||
iters++;
|
||||
continue;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if( !checkPartialSubsets && i == modelPoints && !cb->checkSubset(ms1, ms2, i))
|
||||
if( i == modelPoints && !cb->checkSubset(ms1, ms2, i) )
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
@@ -261,7 +250,6 @@ public:
|
||||
|
||||
Ptr<PointSetRegistrator::Callback> cb;
|
||||
int modelPoints;
|
||||
bool checkPartialSubsets;
|
||||
double threshold;
|
||||
double confidence;
|
||||
int maxIters;
|
||||
|
||||
@@ -284,7 +284,39 @@ prefilterXSobel( const Mat& src, Mat& dst, int ftzero )
|
||||
static const int DISPARITY_SHIFT_16S = 4;
|
||||
static const int DISPARITY_SHIFT_32S = 8;
|
||||
|
||||
template <typename T>
|
||||
struct dispShiftTemplate
|
||||
{ };
|
||||
|
||||
template<>
|
||||
struct dispShiftTemplate<short>
|
||||
{
|
||||
enum { value = DISPARITY_SHIFT_16S };
|
||||
};
|
||||
|
||||
template<>
|
||||
struct dispShiftTemplate<int>
|
||||
{
|
||||
enum { value = DISPARITY_SHIFT_32S };
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
inline T dispDescale(int /*v1*/, int /*v2*/, int /*d*/);
|
||||
|
||||
template<>
|
||||
inline short dispDescale(int v1, int v2, int d)
|
||||
{
|
||||
return (short)((v1*256 + (d != 0 ? v2*256/d : 0) + 15) >> 4);
|
||||
}
|
||||
|
||||
template <>
|
||||
inline int dispDescale(int v1, int v2, int d)
|
||||
{
|
||||
return (int)(v1*256 + (d != 0 ? v2*256/d : 0)); // no need to add 127, this will be converted to float
|
||||
}
|
||||
|
||||
#if CV_SIMD128
|
||||
template <typename dType>
|
||||
static void findStereoCorrespondenceBM_SIMD( const Mat& left, const Mat& right,
|
||||
Mat& disp, Mat& cost, StereoBMParams& state,
|
||||
uchar* buf, int _dy0, int _dy1 )
|
||||
@@ -302,7 +334,8 @@ static void findStereoCorrespondenceBM_SIMD( const Mat& left, const Mat& right,
|
||||
int ftzero = state.preFilterCap;
|
||||
int textureThreshold = state.textureThreshold;
|
||||
int uniquenessRatio = state.uniquenessRatio;
|
||||
short FILTERED = (short)((mindisp - 1) << DISPARITY_SHIFT_16S);
|
||||
const int disp_shift = dispShiftTemplate<dType>::value;
|
||||
dType FILTERED = (dType)((mindisp - 1) << disp_shift);
|
||||
|
||||
ushort *sad, *hsad0, *hsad, *hsad_sub;
|
||||
int *htext;
|
||||
@@ -310,7 +343,7 @@ static void findStereoCorrespondenceBM_SIMD( const Mat& left, const Mat& right,
|
||||
const uchar* lptr0 = left.ptr() + lofs;
|
||||
const uchar* rptr0 = right.ptr() + rofs;
|
||||
const uchar *lptr, *lptr_sub, *rptr;
|
||||
short* dptr = disp.ptr<short>();
|
||||
dType* dptr = disp.ptr<dType>();
|
||||
int sstep = (int)left.step;
|
||||
int dstep = (int)(disp.step/sizeof(dptr[0]));
|
||||
int cstep = (height + dy0 + dy1)*ndisp;
|
||||
@@ -527,10 +560,10 @@ static void findStereoCorrespondenceBM_SIMD( const Mat& left, const Mat& right,
|
||||
{
|
||||
int p = sad[mind+1], n = sad[mind-1];
|
||||
d = p + n - 2*sad[mind] + std::abs(p - n);
|
||||
dptr[y*dstep] = (short)(((ndisp - mind - 1 + mindisp)*256 + (d != 0 ? (p-n)*256/d : 0) + 15) >> 4);
|
||||
dptr[y*dstep] = dispDescale<dType>(ndisp - mind - 1 + mindisp, p-n, d);
|
||||
}
|
||||
else
|
||||
dptr[y*dstep] = (short)((ndisp - mind - 1 + mindisp)*16);
|
||||
dptr[y*dstep] = dispDescale<dType>(ndisp - mind - 1 + mindisp, 0, 0);
|
||||
costptr[y*coststep] = sad[mind];
|
||||
}
|
||||
}
|
||||
@@ -540,8 +573,8 @@ static void findStereoCorrespondenceBM_SIMD( const Mat& left, const Mat& right,
|
||||
template <typename mType>
|
||||
static void
|
||||
findStereoCorrespondenceBM( const Mat& left, const Mat& right,
|
||||
Mat& disp, Mat& cost, const StereoBMParams& state,
|
||||
uchar* buf, int _dy0, int _dy1, const int disp_shift )
|
||||
Mat& disp, Mat& cost, const StereoBMParams& state,
|
||||
uchar* buf, int _dy0, int _dy1 )
|
||||
{
|
||||
|
||||
const int ALIGN = 16;
|
||||
@@ -557,6 +590,7 @@ findStereoCorrespondenceBM( const Mat& left, const Mat& right,
|
||||
int ftzero = state.preFilterCap;
|
||||
int textureThreshold = state.textureThreshold;
|
||||
int uniquenessRatio = state.uniquenessRatio;
|
||||
const int disp_shift = dispShiftTemplate<mType>::value;
|
||||
mType FILTERED = (mType)((mindisp - 1) << disp_shift);
|
||||
|
||||
#if CV_SIMD128
|
||||
@@ -849,8 +883,8 @@ findStereoCorrespondenceBM( const Mat& left, const Mat& right,
|
||||
sad[ndisp] = sad[ndisp-2];
|
||||
int p = sad[mind+1], n = sad[mind-1];
|
||||
d = p + n - 2*sad[mind] + std::abs(p - n);
|
||||
dptr[y*dstep] = (mType)(((ndisp - mind - 1 + mindisp)*256 + (d != 0 ? (p-n)*256/d : 0) + 15)
|
||||
>> (DISPARITY_SHIFT_32S - disp_shift));
|
||||
dptr[y*dstep] = dispDescale<mType>(ndisp - mind - 1 + mindisp, p-n, d);
|
||||
|
||||
costptr[y*coststep] = sad[mind];
|
||||
}
|
||||
}
|
||||
@@ -980,7 +1014,10 @@ struct FindStereoCorrespInvoker : public ParallelLoopBody
|
||||
int _row0 = std::min(cvRound(range.start * rows / nstripes), rows);
|
||||
int _row1 = std::min(cvRound(range.end * rows / nstripes), rows);
|
||||
uchar *ptr = slidingSumBuf->ptr() + range.start * stripeBufSize;
|
||||
int FILTERED = (state->minDisparity - 1)*16;
|
||||
|
||||
int dispShift = disp->type() == CV_16S ? DISPARITY_SHIFT_16S :
|
||||
DISPARITY_SHIFT_32S;
|
||||
int FILTERED = (state->minDisparity - 1) << dispShift;
|
||||
|
||||
Rect roi = validDisparityRect & Rect(0, _row0, cols, _row1 - _row0);
|
||||
if( roi.height == 0 )
|
||||
@@ -1008,15 +1045,18 @@ struct FindStereoCorrespInvoker : public ParallelLoopBody
|
||||
#if CV_SIMD128
|
||||
if( useSIMD && useShorts )
|
||||
{
|
||||
findStereoCorrespondenceBM_SIMD( left_i, right_i, disp_i, cost_i, *state, ptr, row0, rows - row1 );
|
||||
if( disp_i.type() == CV_16S)
|
||||
findStereoCorrespondenceBM_SIMD<short>( left_i, right_i, disp_i, cost_i, *state, ptr, row0, rows - row1 );
|
||||
else
|
||||
findStereoCorrespondenceBM_SIMD<int>( left_i, right_i, disp_i, cost_i, *state, ptr, row0, rows - row1);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
if( disp_i.type() == CV_16S )
|
||||
findStereoCorrespondenceBM<short>( left_i, right_i, disp_i, cost_i, *state, ptr, row0, rows - row1, DISPARITY_SHIFT_16S );
|
||||
findStereoCorrespondenceBM<short>( left_i, right_i, disp_i, cost_i, *state, ptr, row0, rows - row1 );
|
||||
else
|
||||
findStereoCorrespondenceBM<int>( left_i, right_i, disp_i, cost_i, *state, ptr, row0, rows - row1, DISPARITY_SHIFT_32S );
|
||||
findStereoCorrespondenceBM<int>( left_i, right_i, disp_i, cost_i, *state, ptr, row0, rows - row1 );
|
||||
}
|
||||
|
||||
if( state->disp12MaxDiff >= 0 )
|
||||
@@ -1104,7 +1144,6 @@ public:
|
||||
else
|
||||
disp_shift = DISPARITY_SHIFT_32S;
|
||||
|
||||
|
||||
int FILTERED = (params.minDisparity - 1) << disp_shift;
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
@@ -1115,6 +1154,9 @@ public:
|
||||
{
|
||||
if(ocl_stereobm(left, right, disparr, ¶ms))
|
||||
{
|
||||
disp_shift = DISPARITY_SHIFT_16S;
|
||||
FILTERED = (params.minDisparity - 1) << disp_shift;
|
||||
|
||||
if( params.speckleRange >= 0 && params.speckleWindowSize > 0 )
|
||||
filterSpeckles(disparr.getMat(), FILTERED, params.speckleWindowSize, params.speckleRange, slidingSumBuf);
|
||||
if (dtype == CV_32F)
|
||||
|
||||
@@ -556,7 +556,7 @@ int CV_StereoMatchingTest::processStereoMatchingResults( FileStorage& fs, int ca
|
||||
assert( fs.isOpened() );
|
||||
assert( trueLeftDisp.type() == CV_32FC1 );
|
||||
assert( trueRightDisp.empty() || trueRightDisp.type() == CV_32FC1 );
|
||||
assert( leftDisp.type() == CV_32FC1 && rightDisp.type() == CV_32FC1 );
|
||||
assert( leftDisp.type() == CV_32FC1 && (rightDisp.empty() || rightDisp.type() == CV_32FC1) );
|
||||
|
||||
// get masks for unknown ground truth disparity values
|
||||
Mat leftUnknMask, rightUnknMask;
|
||||
@@ -791,6 +791,12 @@ protected:
|
||||
bm->compute( leftImg, rightImg, tempDisp );
|
||||
tempDisp.convertTo(leftDisp, CV_32F, 1./StereoMatcher::DISP_SCALE);
|
||||
|
||||
//check for fixed-type disparity data type
|
||||
Mat_<float> fixedFloatDisp;
|
||||
bm->compute( leftImg, rightImg, fixedFloatDisp );
|
||||
EXPECT_LT(cvtest::norm(fixedFloatDisp, leftDisp, cv::NORM_L2 | cv::NORM_RELATIVE),
|
||||
0.005 + DBL_EPSILON);
|
||||
|
||||
if (params.mindisp != 0)
|
||||
for (int y = 0; y < leftDisp.rows; y++)
|
||||
for (int x = 0; x < leftDisp.cols; x++)
|
||||
|
||||
Reference in New Issue
Block a user