mirror of
https://github.com/opencv/opencv.git
synced 2026-07-31 00:03:03 +04:00
Merge branch 4.x
This commit is contained in:
@@ -563,7 +563,7 @@ public:
|
||||
CV_WRAP static Ptr<GFTTDetector> create( int maxCorners=1000, double qualityLevel=0.01, double minDistance=1,
|
||||
int blockSize=3, bool useHarrisDetector=false, double k=0.04 );
|
||||
CV_WRAP static Ptr<GFTTDetector> create( int maxCorners, double qualityLevel, double minDistance,
|
||||
int blockSize, int gradiantSize, bool useHarrisDetector=false, double k=0.04 );
|
||||
int blockSize, int gradientSize, bool useHarrisDetector=false, double k=0.04 );
|
||||
CV_WRAP virtual void setMaxFeatures(int maxFeatures) = 0;
|
||||
CV_WRAP virtual int getMaxFeatures() const = 0;
|
||||
|
||||
@@ -645,6 +645,11 @@ public:
|
||||
CV_PROP_RW bool filterByConvexity;
|
||||
CV_PROP_RW float minConvexity, maxConvexity;
|
||||
|
||||
/** @brief Flag to enable contour collection.
|
||||
If set to true, the detector will store the contours of the detected blobs in memory,
|
||||
which can be retrieved after the detect() call using getBlobContours().
|
||||
@note Default value is false.
|
||||
*/
|
||||
CV_PROP_RW bool collectContours;
|
||||
|
||||
void read( const FileNode& fn );
|
||||
@@ -658,6 +663,11 @@ public:
|
||||
CV_WRAP virtual SimpleBlobDetector::Params getParams() const = 0;
|
||||
|
||||
CV_WRAP virtual String getDefaultName() const CV_OVERRIDE;
|
||||
|
||||
/** @brief Returns the contours of the blobs detected during the last call to detect().
|
||||
@note The @ref Params::collectContours parameter must be set to true before calling
|
||||
detect() for this method to return any data.
|
||||
*/
|
||||
CV_WRAP virtual const std::vector<std::vector<cv::Point> >& getBlobContours() const = 0;
|
||||
};
|
||||
|
||||
|
||||
@@ -1036,7 +1036,11 @@ void ORB_Impl::detectAndCompute( InputArray _image, InputArray _mask,
|
||||
bool useOCL = false;
|
||||
#endif
|
||||
|
||||
Mat image = _image.getMat(), mask = _mask.getMat();
|
||||
Mat image = _image.getMat(), mask;
|
||||
if (!_mask.empty())
|
||||
{
|
||||
threshold(_mask, mask, 0, 255, THRESH_BINARY);
|
||||
}
|
||||
if( image.type() != CV_8UC1 )
|
||||
cvtColor(_image, image, COLOR_BGR2GRAY);
|
||||
|
||||
@@ -1134,7 +1138,7 @@ void ORB_Impl::detectAndCompute( InputArray _image, InputArray _mask,
|
||||
}
|
||||
|
||||
copyMakeBorder(currImg, extImg, border, border, border, border,
|
||||
BORDER_REFLECT_101+BORDER_ISOLATED);
|
||||
BORDER_REFLECT_101 + BORDER_ISOLATED);
|
||||
if (!mask.empty())
|
||||
copyMakeBorder(currMask, extMask, border, border, border, border,
|
||||
BORDER_CONSTANT+BORDER_ISOLATED);
|
||||
|
||||
@@ -168,4 +168,31 @@ BIGDATA_TEST(Features2D_ORB, regression_opencv_python_537) // memory usage: ~3
|
||||
ASSERT_NO_THROW(orbPtr->detectAndCompute(img, noArray(), kps, fv));
|
||||
}
|
||||
|
||||
TEST(Features2D_ORB, MaskValue)
|
||||
{
|
||||
Mat gray = imread(cvtest::findDataFile("features2d/tsukuba.png"), IMREAD_GRAYSCALE);
|
||||
ASSERT_FALSE(gray.empty());
|
||||
|
||||
cv::Rect roi(gray.cols/4, gray.rows/4, gray.cols/2, gray.rows/2);
|
||||
|
||||
Mat mask255 = Mat::zeros(gray.size(), CV_8UC1);
|
||||
Mat mask1 = Mat::zeros(gray.size(), CV_8UC1);
|
||||
mask255(roi).setTo(255);
|
||||
mask1(roi).setTo(1);
|
||||
|
||||
Ptr<ORB> orb = cv::ORB::create();
|
||||
|
||||
vector<KeyPoint> keypoints_mask255, keypoints_mask1;
|
||||
Mat descriptors_mask255, descriptors_mask1;
|
||||
|
||||
orb->detectAndCompute(gray, mask255, keypoints_mask255, descriptors_mask255, false);
|
||||
orb->detectAndCompute(gray, mask1, keypoints_mask1, descriptors_mask1, false);
|
||||
|
||||
ASSERT_EQ(keypoints_mask255.size(), keypoints_mask1.size())
|
||||
<< "Number of keypoints differs between mask values 255 and 1";
|
||||
|
||||
Mat diff = descriptors_mask255 != descriptors_mask1;
|
||||
ASSERT_EQ(countNonZero(diff), 0);
|
||||
}
|
||||
|
||||
}} // namespace
|
||||
|
||||
Reference in New Issue
Block a user