1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 07:43:03 +04:00

Merge branch 4.x

This commit is contained in:
Alexander Alekhin
2021-04-09 10:30:38 +00:00
1114 changed files with 64039 additions and 14611 deletions
@@ -481,8 +481,7 @@ article](http://en.wikipedia.org/wiki/Maximally_stable_extremal_regions)).
than union-find method; it actually get 1.5~2m/s on my centrino L7200 1.2GHz laptop.
- the color image algorithm is taken from: @cite forssen2007maximally ; it should be much slower
than grey image method ( 3~4 times ); the chi_table.h file is taken directly from paper's source
code which is distributed under GPL.
than grey image method ( 3~4 times )
- (Python) A complete example showing the use of the %MSER detector can be found at samples/python/mser.py
*/
+7 -1
View File
@@ -325,13 +325,19 @@ void SimpleBlobDetectorImpl::detect(InputArray image, std::vector<cv::KeyPoint>&
std::vector < Center > curCenters;
findBlobs(grayscaleImage, binarizedImage, curCenters);
if(params.maxThreshold - params.minThreshold <= params.thresholdStep) {
// if the difference between min and max threshold is less than the threshold step
// we're only going to enter the loop once, so we need to add curCenters
// to ensure we still use minDistBetweenBlobs
centers.push_back(curCenters);
}
std::vector < std::vector<Center> > newCenters;
for (size_t i = 0; i < curCenters.size(); i++)
{
bool isNew = true;
for (size_t j = 0; j < centers.size(); j++)
{
double dist = norm(centers[j][ centers[j].size() / 2 ].location - curCenters[i].location);
double dist = norm(centers[j][centers[j].size() / 2 ].location - curCenters[i].location);
isNew = dist >= params.minDistBetweenBlobs && dist >= centers[j][ centers[j].size() / 2 ].radius && dist >= curCenters[i].radius;
if (!isNew)
{
+7 -6
View File
@@ -87,6 +87,7 @@ public:
}
std::vector<Point2f> corners;
std::vector<float> cornersQuality;
if (_image.isUMat())
{
@@ -97,7 +98,7 @@ public:
ugrayImage = _image.getUMat();
goodFeaturesToTrack( ugrayImage, corners, nfeatures, qualityLevel, minDistance, _mask,
blockSize, gradSize, useHarrisDetector, k );
cornersQuality, blockSize, gradSize, useHarrisDetector, k );
}
else
{
@@ -106,14 +107,14 @@ public:
cvtColor( image, grayImage, COLOR_BGR2GRAY );
goodFeaturesToTrack( grayImage, corners, nfeatures, qualityLevel, minDistance, _mask,
blockSize, gradSize, useHarrisDetector, k );
cornersQuality, blockSize, gradSize, useHarrisDetector, k );
}
CV_Assert(corners.size() == cornersQuality.size());
keypoints.resize(corners.size());
std::vector<Point2f>::const_iterator corner_it = corners.begin();
std::vector<KeyPoint>::iterator keypoint_it = keypoints.begin();
for( ; corner_it != corners.end() && keypoint_it != keypoints.end(); ++corner_it, ++keypoint_it )
*keypoint_it = KeyPoint( *corner_it, (float)blockSize );
for (size_t i = 0; i < corners.size(); i++)
keypoints[i] = KeyPoint(corners[i], (float)blockSize, -1, cornersQuality[i]);
}
+1 -1
View File
@@ -35,7 +35,7 @@
* it actually get 1.5~2m/s on my centrino L7200 1.2GHz laptop.
* 3. the color image algorithm is taken from: Maximally Stable Colour Regions for Recognition and Match;
* it should be much slower than gray image method ( 3~4 times );
* the chi_table.h file is taken directly from paper's source code which is distributed under GPL.
* the chi_table.h file is taken directly from paper's source code which is distributed under permissive BSD-like license: http://users.isy.liu.se/cvl/perfo/software/chi_table.h
* 4. though the name is *contours*, the result actually is a list of point set.
*/
+9 -4
View File
@@ -1025,15 +1025,20 @@ void ORB_Impl::detectAndCompute( InputArray _image, InputArray _mask,
Mat imagePyramid, maskPyramid;
UMat uimagePyramid, ulayerInfo;
int level_dy = image.rows + border*2;
Point level_ofs(0,0);
Size bufSize((cvRound(image.cols/getScale(0, firstLevel, scaleFactor)) + border*2 + 15) & -16, 0);
float level0_inv_scale = 1.0f / getScale(0, firstLevel, scaleFactor);
size_t level0_width = (size_t)cvRound(image.cols * level0_inv_scale);
size_t level0_height = (size_t)cvRound(image.rows * level0_inv_scale);
Size bufSize((int)alignSize(level0_width + border*2, 16), 0); // TODO change alignment to 64
int level_dy = (int)level0_height + border*2;
Point level_ofs(0, 0);
for( level = 0; level < nLevels; level++ )
{
float scale = getScale(level, firstLevel, scaleFactor);
layerScale[level] = scale;
Size sz(cvRound(image.cols/scale), cvRound(image.rows/scale));
float inv_scale = 1.0f / scale;
Size sz(cvRound(image.cols * inv_scale), cvRound(image.rows * inv_scale));
Size wholeSize(sz.width + border*2, sz.height + border*2);
if( level_ofs.x + wholeSize.width > bufSize.width )
{
@@ -0,0 +1,21 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#include "test_precomp.hpp"
namespace opencv_test { namespace {
TEST(Features2d_BlobDetector, bug_6667)
{
cv::Mat image = cv::Mat(cv::Size(100, 100), CV_8UC1, cv::Scalar(255, 255, 255));
cv::circle(image, Point(50, 50), 20, cv::Scalar(0), -1);
SimpleBlobDetector::Params params;
params.minThreshold = 250;
params.maxThreshold = 260;
std::vector<KeyPoint> keypoints;
Ptr<SimpleBlobDetector> detector = SimpleBlobDetector::create(params);
detector->detect(image, keypoints);
ASSERT_NE((int) keypoints.size(), 0);
}
}} // namespace
@@ -123,7 +123,7 @@ void NearestNeighborTest::run( int /*start_from*/ ) {
Mat desc( featuresCount, dims, CV_32FC1 );
ts->get_rng().fill( desc, RNG::UNIFORM, minValue, maxValue );
createModel( desc );
createModel( desc.clone() ); // .clone() is used to simulate dangling pointers problem: https://github.com/opencv/opencv/issues/17553
tempCode = checkGetPoints( desc );
if( tempCode != cvtest::TS::OK )
+20 -1
View File
@@ -90,7 +90,7 @@ TEST(Features2D_ORB, _1996)
ASSERT_EQ(0, roiViolations);
}
TEST(Features2D_ORB, crash)
TEST(Features2D_ORB, crash_5031)
{
cv::Mat image = cv::Mat::zeros(cv::Size(1920, 1080), CV_8UC3);
@@ -123,4 +123,23 @@ TEST(Features2D_ORB, crash)
ASSERT_NO_THROW(orb->compute(image, keypoints, descriptors));
}
TEST(Features2D_ORB, regression_16197)
{
Mat img(Size(72, 72), CV_8UC1, Scalar::all(0));
Ptr<ORB> orbPtr = ORB::create();
orbPtr->setNLevels(5);
orbPtr->setFirstLevel(3);
orbPtr->setScaleFactor(1.8);
orbPtr->setPatchSize(8);
orbPtr->setEdgeThreshold(8);
std::vector<KeyPoint> kps;
Mat fv;
// exception in debug mode, crash in release
ASSERT_NO_THROW(orbPtr->detectAndCompute(img, noArray(), kps, fv));
}
}} // namespace