Merge remote-tracking branch 'upstream/3.4' into merge-3.4
This commit is contained in:
@@ -257,7 +257,7 @@ void SimpleBlobDetectorImpl::findBlobs(InputArray _image, InputArray _binaryImag
|
||||
{
|
||||
std::vector < Point > hull;
|
||||
convexHull(contours[contourIdx], hull);
|
||||
double area = contourArea(contours[contourIdx]);
|
||||
double area = moms.m00;
|
||||
double hullArea = contourArea(hull);
|
||||
if (fabs(hullArea) < DBL_EPSILON)
|
||||
continue;
|
||||
|
||||
@@ -625,15 +625,20 @@ void DescriptorMatcher::checkMasks( InputArrayOfArrays _masks, int queryDescript
|
||||
if( isMaskSupported() && !masks.empty() )
|
||||
{
|
||||
// Check masks
|
||||
size_t imageCount = std::max(trainDescCollection.size(), utrainDescCollection.size() );
|
||||
const size_t imageCount = std::max(trainDescCollection.size(), utrainDescCollection.size() );
|
||||
CV_Assert( masks.size() == imageCount );
|
||||
for( size_t i = 0; i < imageCount; i++ )
|
||||
{
|
||||
if( !masks[i].empty() && (!trainDescCollection[i].empty() || !utrainDescCollection[i].empty() ) )
|
||||
if (masks[i].empty())
|
||||
continue;
|
||||
const bool hasTrainDesc = !trainDescCollection.empty() && !trainDescCollection[i].empty();
|
||||
const bool hasUTrainDesc = !utrainDescCollection.empty() && !utrainDescCollection[i].empty();
|
||||
if (hasTrainDesc || hasUTrainDesc)
|
||||
{
|
||||
int rows = trainDescCollection[i].empty() ? utrainDescCollection[i].rows : trainDescCollection[i].rows;
|
||||
CV_Assert( masks[i].rows == queryDescriptorsCount &&
|
||||
masks[i].cols == rows && masks[i].type() == CV_8UC1);
|
||||
const int rows = hasTrainDesc ? trainDescCollection[i].rows : utrainDescCollection[i].rows;
|
||||
CV_Assert(masks[i].type() == CV_8UC1
|
||||
&& masks[i].rows == queryDescriptorsCount
|
||||
&& masks[i].cols == rows);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,6 +73,7 @@
|
||||
|
||||
#include <opencv2/core/hal/hal.hpp>
|
||||
#include "opencv2/core/hal/intrin.hpp"
|
||||
#include <opencv2/core/utils/buffer_area.private.hpp>
|
||||
|
||||
namespace cv {
|
||||
|
||||
@@ -167,23 +168,17 @@ float calcOrientationHist(
|
||||
int i, j, k, len = (radius*2+1)*(radius*2+1);
|
||||
|
||||
float expf_scale = -1.f/(2.f * sigma * sigma);
|
||||
#if CV_SIMD
|
||||
AutoBuffer<float> bufX(len + v_float32::nlanes);
|
||||
AutoBuffer<float> bufY(len + v_float32::nlanes);
|
||||
AutoBuffer<float> bufO(len + v_float32::nlanes);
|
||||
AutoBuffer<float> bufW(len + v_float32::nlanes);
|
||||
AutoBuffer<float> bufT(n+4 + v_float32::nlanes);
|
||||
float *X = alignPtr(bufX.data(), CV_SIMD_WIDTH);
|
||||
float *Y = alignPtr(bufY.data(), CV_SIMD_WIDTH);
|
||||
float *Mag = X;
|
||||
float *Ori = alignPtr(bufO.data(), CV_SIMD_WIDTH);
|
||||
float *W = alignPtr(bufW.data(), CV_SIMD_WIDTH);
|
||||
float *temphist = alignPtr(bufT.data(), CV_SIMD_WIDTH)+2;
|
||||
#else
|
||||
AutoBuffer<float> buf(len*4 + n+4);
|
||||
float *X = buf.data(), *Y = X + len, *Mag = X, *Ori = Y + len, *W = Ori + len;
|
||||
float* temphist = W + len + 2;
|
||||
#endif
|
||||
|
||||
cv::utils::BufferArea area;
|
||||
float *X = 0, *Y = 0, *Mag, *Ori = 0, *W = 0, *temphist = 0;
|
||||
area.allocate(X, len, CV_SIMD_WIDTH);
|
||||
area.allocate(Y, len, CV_SIMD_WIDTH);
|
||||
area.allocate(Ori, len, CV_SIMD_WIDTH);
|
||||
area.allocate(W, len, CV_SIMD_WIDTH);
|
||||
area.allocate(temphist, n+4, CV_SIMD_WIDTH);
|
||||
area.commit();
|
||||
temphist += 2;
|
||||
Mag = X;
|
||||
|
||||
for( i = 0; i < n; i++ )
|
||||
temphist[i] = 0.f;
|
||||
@@ -656,7 +651,7 @@ void calcSIFTDescriptor(
|
||||
v_float32 v_rco011 = v_rc01*obin, v_rco010 = v_rc01 - v_rco011;
|
||||
v_float32 v_rco001 = v_rc00*obin, v_rco000 = v_rc00 - v_rco001;
|
||||
|
||||
v_int32 idx = v_fma(v_fma(r0+__1, __d_plus_2, c0+__1), __n_plus_2, o0);
|
||||
v_int32 idx = v_muladd(v_muladd(r0+__1, __d_plus_2, c0+__1), __n_plus_2, o0);
|
||||
v_store_aligned(idx_buf, idx);
|
||||
|
||||
v_store_aligned(rco_buf, v_rco000);
|
||||
|
||||
@@ -603,7 +603,6 @@ TEST(Features2d_DMatch, issue_11855)
|
||||
1, 1, 1);
|
||||
Mat targets = (Mat_<uchar>(2, 3) << 1, 1, 1,
|
||||
0, 0, 0);
|
||||
|
||||
Ptr<BFMatcher> bf = BFMatcher::create(NORM_HAMMING, true);
|
||||
vector<vector<DMatch> > match;
|
||||
bf->knnMatch(sources, targets, match, 1, noArray(), true);
|
||||
@@ -615,4 +614,18 @@ TEST(Features2d_DMatch, issue_11855)
|
||||
EXPECT_EQ(0.0f, match[0][0].distance);
|
||||
}
|
||||
|
||||
TEST(Features2d_DMatch, issue_17771)
|
||||
{
|
||||
Mat sources = (Mat_<uchar>(2, 3) << 1, 1, 0,
|
||||
1, 1, 1);
|
||||
Mat targets = (Mat_<uchar>(2, 3) << 1, 1, 1,
|
||||
0, 0, 0);
|
||||
UMat usources = sources.getUMat(ACCESS_READ);
|
||||
UMat utargets = targets.getUMat(ACCESS_READ);
|
||||
vector<vector<DMatch> > match;
|
||||
Ptr<BFMatcher> ubf = BFMatcher::create(NORM_HAMMING);
|
||||
Mat mask = (Mat_<uchar>(2, 2) << 1, 0, 0, 1);
|
||||
EXPECT_NO_THROW(ubf->knnMatch(usources, utargets, match, 1, mask, true));
|
||||
}
|
||||
|
||||
}} // namespace
|
||||
|
||||
Reference in New Issue
Block a user