mirror of
https://github.com/opencv/opencv.git
synced 2024-11-27 20:50:25 +08:00
Merge pull request #9618 from vipinanand4:goodFeaturesToTrack_added_gradiantSize
Added gradiantSize param into goodFeaturesToTrack API (#9618) * Added gradiantSize param into goodFeaturesToTrack API Removed hardcode value 3 in goodFeaturesToTrack API, and added new param 'gradinatSize' in this API so that user can pass any gradiant size as 3, 5 or 7. Signed-off-by: Vipin Anand <anand.vipin@gmail.com> Signed-off-by: Nilaykumar Patel<nilay.nilpat@gmail.com> Signed-off-by: Prashanth Voora <prashanthx85@gmail.com> * fixed compilation error for java test Signed-off-by: Vipin Anand <anand.vipin@gmail.com> * Modifying code for previous binary compatibility and fixing other warnings fixed ABI break issue resolved merged conflict compilation error fix Signed-off-by: Vipin Anand <anand.vipin@gmail.com> Signed-off-by: Patel, Nilaykumar K <nilay.nilpat@gmail.com>
This commit is contained in:
parent
50aa4f8887
commit
39e742765a
@ -527,6 +527,8 @@ class CV_EXPORTS_W GFTTDetector : public Feature2D
|
||||
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 );
|
||||
CV_WRAP virtual void setMaxFeatures(int maxFeatures) = 0;
|
||||
CV_WRAP virtual int getMaxFeatures() const = 0;
|
||||
|
||||
|
@ -48,10 +48,10 @@ class GFTTDetector_Impl : public GFTTDetector
|
||||
{
|
||||
public:
|
||||
GFTTDetector_Impl( int _nfeatures, double _qualityLevel,
|
||||
double _minDistance, int _blockSize,
|
||||
double _minDistance, int _blockSize, int _gradientSize,
|
||||
bool _useHarrisDetector, double _k )
|
||||
: nfeatures(_nfeatures), qualityLevel(_qualityLevel), minDistance(_minDistance),
|
||||
blockSize(_blockSize), useHarrisDetector(_useHarrisDetector), k(_k)
|
||||
blockSize(_blockSize), gradSize(_gradientSize), useHarrisDetector(_useHarrisDetector), k(_k)
|
||||
{
|
||||
}
|
||||
|
||||
@ -67,6 +67,9 @@ public:
|
||||
void setBlockSize(int blockSize_) { blockSize = blockSize_; }
|
||||
int getBlockSize() const { return blockSize; }
|
||||
|
||||
void setGradientSize(int gradientSize_) { gradSize = gradientSize_; }
|
||||
int getGradientSize() { return gradSize; }
|
||||
|
||||
void setHarrisDetector(bool val) { useHarrisDetector = val; }
|
||||
bool getHarrisDetector() const { return useHarrisDetector; }
|
||||
|
||||
@ -88,7 +91,7 @@ public:
|
||||
ugrayImage = _image.getUMat();
|
||||
|
||||
goodFeaturesToTrack( ugrayImage, corners, nfeatures, qualityLevel, minDistance, _mask,
|
||||
blockSize, useHarrisDetector, k );
|
||||
blockSize, gradSize, useHarrisDetector, k );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -97,7 +100,7 @@ public:
|
||||
cvtColor( image, grayImage, COLOR_BGR2GRAY );
|
||||
|
||||
goodFeaturesToTrack( grayImage, corners, nfeatures, qualityLevel, minDistance, _mask,
|
||||
blockSize, useHarrisDetector, k );
|
||||
blockSize, gradSize, useHarrisDetector, k );
|
||||
}
|
||||
|
||||
keypoints.resize(corners.size());
|
||||
@ -112,17 +115,26 @@ public:
|
||||
double qualityLevel;
|
||||
double minDistance;
|
||||
int blockSize;
|
||||
int gradSize;
|
||||
bool useHarrisDetector;
|
||||
double k;
|
||||
};
|
||||
|
||||
|
||||
Ptr<GFTTDetector> GFTTDetector::create( int _nfeatures, double _qualityLevel,
|
||||
double _minDistance, int _blockSize, int _gradientSize,
|
||||
bool _useHarrisDetector, double _k )
|
||||
{
|
||||
return makePtr<GFTTDetector_Impl>(_nfeatures, _qualityLevel,
|
||||
_minDistance, _blockSize, _gradientSize, _useHarrisDetector, _k);
|
||||
}
|
||||
|
||||
Ptr<GFTTDetector> GFTTDetector::create( int _nfeatures, double _qualityLevel,
|
||||
double _minDistance, int _blockSize,
|
||||
bool _useHarrisDetector, double _k )
|
||||
{
|
||||
return makePtr<GFTTDetector_Impl>(_nfeatures, _qualityLevel,
|
||||
_minDistance, _blockSize, _useHarrisDetector, _k);
|
||||
_minDistance, _blockSize, 3, _useHarrisDetector, _k);
|
||||
}
|
||||
|
||||
String GFTTDetector::getDefaultName() const
|
||||
|
@ -139,7 +139,7 @@ TEST(Features2d_Detector_Keypoints_AGAST, validation)
|
||||
TEST(Features2d_Detector_Keypoints_HARRIS, validation)
|
||||
{
|
||||
|
||||
CV_FeatureDetectorKeypointsTest test(GFTTDetector::create(1000, 0.01, 1, 3, true, 0.04));
|
||||
CV_FeatureDetectorKeypointsTest test(GFTTDetector::create(1000, 0.01, 1, 3, 3, true, 0.04));
|
||||
test.safe_run();
|
||||
}
|
||||
|
||||
|
@ -1914,11 +1914,17 @@ or cornerMinEigenVal.
|
||||
|
||||
@sa cornerMinEigenVal, cornerHarris, calcOpticalFlowPyrLK, estimateRigidTransform,
|
||||
*/
|
||||
|
||||
CV_EXPORTS_W void goodFeaturesToTrack( InputArray image, OutputArray corners,
|
||||
int maxCorners, double qualityLevel, double minDistance,
|
||||
InputArray mask = noArray(), int blockSize = 3,
|
||||
bool useHarrisDetector = false, double k = 0.04 );
|
||||
|
||||
CV_EXPORTS_W void goodFeaturesToTrack( InputArray image, OutputArray corners,
|
||||
int maxCorners, double qualityLevel, double minDistance,
|
||||
InputArray mask, int blockSize,
|
||||
int gradientSize, bool useHarrisDetector = false,
|
||||
double k = 0.04 );
|
||||
/** @example houghlines.cpp
|
||||
An example using the Hough line detector
|
||||
![Sample input image](Hough_Lines_Tutorial_Original_Image.jpg) ![Output image](Hough_Lines_Tutorial_Result.jpg)
|
||||
|
@ -1033,7 +1033,7 @@ public class ImgprocTest extends OpenCVTestCase {
|
||||
Imgproc.rectangle(src, new Point(2, 2), new Point(8, 8), new Scalar(100), -1);
|
||||
MatOfPoint lp = new MatOfPoint();
|
||||
|
||||
Imgproc.goodFeaturesToTrack(src, lp, 100, 0.01, 3, gray1, 4, true, 0);
|
||||
Imgproc.goodFeaturesToTrack(src, lp, 100, 0.01, 3, gray1, 4, 3, true, 0);
|
||||
|
||||
assertEquals(4, lp.total());
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ OCL_PERF_TEST_P(GoodFeaturesToTrackFixture, GoodFeaturesToTrack,
|
||||
declare.in(src, WARMUP_READ).out(dst);
|
||||
|
||||
OCL_TEST_CYCLE() cv::goodFeaturesToTrack(src, dst, maxCorners, qualityLevel,
|
||||
minDistance, noArray(), 3, harrisDetector, 0.04);
|
||||
minDistance, noArray(), 3, 3, harrisDetector, 0.04);
|
||||
|
||||
SANITY_CHECK(dst);
|
||||
}
|
||||
|
@ -6,15 +6,16 @@ using namespace perf;
|
||||
using std::tr1::make_tuple;
|
||||
using std::tr1::get;
|
||||
|
||||
typedef std::tr1::tuple<string, int, double, int, bool> Image_MaxCorners_QualityLevel_MinDistance_BlockSize_UseHarris_t;
|
||||
typedef perf::TestBaseWithParam<Image_MaxCorners_QualityLevel_MinDistance_BlockSize_UseHarris_t> Image_MaxCorners_QualityLevel_MinDistance_BlockSize_UseHarris;
|
||||
typedef std::tr1::tuple<string, int, double, int, int, bool> Image_MaxCorners_QualityLevel_MinDistance_BlockSize_gradientSize_UseHarris_t;
|
||||
typedef perf::TestBaseWithParam<Image_MaxCorners_QualityLevel_MinDistance_BlockSize_gradientSize_UseHarris_t> Image_MaxCorners_QualityLevel_MinDistance_BlockSize_gradientSize_UseHarris;
|
||||
|
||||
PERF_TEST_P(Image_MaxCorners_QualityLevel_MinDistance_BlockSize_UseHarris, goodFeaturesToTrack,
|
||||
PERF_TEST_P(Image_MaxCorners_QualityLevel_MinDistance_BlockSize_gradientSize_UseHarris, goodFeaturesToTrack,
|
||||
testing::Combine(
|
||||
testing::Values( "stitching/a1.png", "cv/shared/pic5.png"),
|
||||
testing::Values( 100, 500 ),
|
||||
testing::Values( 0.1, 0.01 ),
|
||||
testing::Values( 3, 5 ),
|
||||
testing::Values( 3, 5 ),
|
||||
testing::Bool()
|
||||
)
|
||||
)
|
||||
@ -23,7 +24,8 @@ PERF_TEST_P(Image_MaxCorners_QualityLevel_MinDistance_BlockSize_UseHarris, goodF
|
||||
int maxCorners = get<1>(GetParam());
|
||||
double qualityLevel = get<2>(GetParam());
|
||||
int blockSize = get<3>(GetParam());
|
||||
bool useHarrisDetector = get<4>(GetParam());
|
||||
int gradientSize = get<4>(GetParam());
|
||||
bool useHarrisDetector = get<5>(GetParam());
|
||||
|
||||
Mat image = imread(filename, IMREAD_GRAYSCALE);
|
||||
if (image.empty())
|
||||
@ -32,7 +34,7 @@ PERF_TEST_P(Image_MaxCorners_QualityLevel_MinDistance_BlockSize_UseHarris, goodF
|
||||
std::vector<Point2f> corners;
|
||||
|
||||
double minDistance = 1;
|
||||
TEST_CYCLE() goodFeaturesToTrack(image, corners, maxCorners, qualityLevel, minDistance, noArray(), blockSize, useHarrisDetector);
|
||||
TEST_CYCLE() goodFeaturesToTrack(image, corners, maxCorners, qualityLevel, minDistance, noArray(), blockSize, gradientSize, useHarrisDetector);
|
||||
|
||||
if (corners.size() > 50)
|
||||
corners.erase(corners.begin() + 50, corners.end());
|
||||
|
@ -75,14 +75,14 @@ struct Corner
|
||||
|
||||
static bool ocl_goodFeaturesToTrack( InputArray _image, OutputArray _corners,
|
||||
int maxCorners, double qualityLevel, double minDistance,
|
||||
InputArray _mask, int blockSize,
|
||||
InputArray _mask, int blockSize, int gradientSize,
|
||||
bool useHarrisDetector, double harrisK )
|
||||
{
|
||||
UMat eig, maxEigenValue;
|
||||
if( useHarrisDetector )
|
||||
cornerHarris( _image, eig, blockSize, 3, harrisK );
|
||||
cornerHarris( _image, eig, blockSize, gradientSize, harrisK );
|
||||
else
|
||||
cornerMinEigenVal( _image, eig, blockSize, 3 );
|
||||
cornerMinEigenVal( _image, eig, blockSize, gradientSize );
|
||||
|
||||
Size imgsize = _image.size();
|
||||
size_t total, i, j, ncorners = 0, possibleCornersCount =
|
||||
@ -275,7 +275,7 @@ struct VxKeypointsComparator
|
||||
|
||||
static bool openvx_harris(Mat image, OutputArray _corners,
|
||||
int _maxCorners, double _qualityLevel, double _minDistance,
|
||||
int _blockSize, double _harrisK)
|
||||
int _blockSize, int gradiantSize, double _harrisK)
|
||||
{
|
||||
using namespace ivx;
|
||||
|
||||
@ -357,7 +357,7 @@ static bool openvx_harris(Mat image, OutputArray _corners,
|
||||
|
||||
void cv::goodFeaturesToTrack( InputArray _image, OutputArray _corners,
|
||||
int maxCorners, double qualityLevel, double minDistance,
|
||||
InputArray _mask, int blockSize,
|
||||
InputArray _mask, int blockSize, int gradientSize,
|
||||
bool useHarrisDetector, double harrisK )
|
||||
{
|
||||
CV_INSTRUMENT_REGION()
|
||||
@ -367,7 +367,7 @@ void cv::goodFeaturesToTrack( InputArray _image, OutputArray _corners,
|
||||
|
||||
CV_OCL_RUN(_image.dims() <= 2 && _image.isUMat(),
|
||||
ocl_goodFeaturesToTrack(_image, _corners, maxCorners, qualityLevel, minDistance,
|
||||
_mask, blockSize, useHarrisDetector, harrisK))
|
||||
_mask, blockSize, gradientSize, useHarrisDetector, harrisK))
|
||||
|
||||
Mat image = _image.getMat(), eig, tmp;
|
||||
if (image.empty())
|
||||
@ -379,12 +379,12 @@ void cv::goodFeaturesToTrack( InputArray _image, OutputArray _corners,
|
||||
// Disabled due to bad accuracy
|
||||
CV_OVX_RUN(false && useHarrisDetector && _mask.empty() &&
|
||||
!ovx::skipSmallImages<VX_KERNEL_HARRIS_CORNERS>(image.cols, image.rows),
|
||||
openvx_harris(image, _corners, maxCorners, qualityLevel, minDistance, blockSize, harrisK))
|
||||
openvx_harris(image, _corners, maxCorners, qualityLevel, minDistance, blockSize, gradiantSize, harrisK))
|
||||
|
||||
if( useHarrisDetector )
|
||||
cornerHarris( image, eig, blockSize, 3, harrisK );
|
||||
cornerHarris( image, eig, blockSize, gradientSize, harrisK );
|
||||
else
|
||||
cornerMinEigenVal( image, eig, blockSize, 3 );
|
||||
cornerMinEigenVal( image, eig, blockSize, gradientSize );
|
||||
|
||||
double maxVal = 0;
|
||||
minMaxLoc( eig, 0, &maxVal, 0, 0, _mask );
|
||||
@ -535,4 +535,12 @@ cvGoodFeaturesToTrack( const void* _image, void*, void*,
|
||||
*_corner_count = (int)ncorners;
|
||||
}
|
||||
|
||||
void cv::goodFeaturesToTrack( InputArray _image, OutputArray _corners,
|
||||
int maxCorners, double qualityLevel, double minDistance,
|
||||
InputArray _mask, int blockSize,
|
||||
bool useHarrisDetector, double harrisK )
|
||||
{
|
||||
cv::goodFeaturesToTrack(_image, _corners, maxCorners, qualityLevel, minDistance,
|
||||
_mask, blockSize, 3, useHarrisDetector, harrisK );
|
||||
}
|
||||
/* End of file. */
|
||||
|
@ -161,7 +161,7 @@ test_cornerEigenValsVecs( const Mat& src, Mat& eigenv, int block_size,
|
||||
static void
|
||||
test_goodFeaturesToTrack( InputArray _image, OutputArray _corners,
|
||||
int maxCorners, double qualityLevel, double minDistance,
|
||||
InputArray _mask, int blockSize,
|
||||
InputArray _mask, int blockSize, int gradientSize,
|
||||
bool useHarrisDetector, double harrisK )
|
||||
{
|
||||
|
||||
@ -170,7 +170,7 @@ test_goodFeaturesToTrack( InputArray _image, OutputArray _corners,
|
||||
|
||||
|
||||
Mat image = _image.getMat(), mask = _mask.getMat();
|
||||
int aperture_size = 3;
|
||||
int aperture_size = gradientSize;
|
||||
int borderType = BORDER_DEFAULT;
|
||||
|
||||
Mat eig, tmp, tt;
|
||||
@ -330,6 +330,7 @@ protected:
|
||||
double qualityLevel;
|
||||
double minDistance;
|
||||
int blockSize;
|
||||
int gradientSize;
|
||||
bool useHarrisDetector;
|
||||
double k;
|
||||
int SrcType;
|
||||
@ -343,6 +344,7 @@ CV_GoodFeatureToTTest::CV_GoodFeatureToTTest()
|
||||
qualityLevel = 0.01;
|
||||
minDistance = 10;
|
||||
blockSize = 3;
|
||||
gradientSize = 3;
|
||||
useHarrisDetector = false;
|
||||
k = 0.04;
|
||||
mask = Mat();
|
||||
@ -397,6 +399,7 @@ void CV_GoodFeatureToTTest::run_func()
|
||||
minDistance,
|
||||
Mat(),
|
||||
blockSize,
|
||||
gradientSize,
|
||||
useHarrisDetector,
|
||||
k );
|
||||
}
|
||||
@ -414,6 +417,7 @@ void CV_GoodFeatureToTTest::run_func()
|
||||
minDistance,
|
||||
Mat(),
|
||||
blockSize,
|
||||
gradientSize,
|
||||
useHarrisDetector,
|
||||
k );
|
||||
}
|
||||
@ -438,6 +442,7 @@ int CV_GoodFeatureToTTest::validate_test_results( int test_case_idx )
|
||||
minDistance,
|
||||
Mat(),
|
||||
blockSize,
|
||||
gradientSize,
|
||||
useHarrisDetector,
|
||||
k );
|
||||
}
|
||||
@ -455,6 +460,7 @@ int CV_GoodFeatureToTTest::validate_test_results( int test_case_idx )
|
||||
minDistance,
|
||||
Mat(),
|
||||
blockSize,
|
||||
gradientSize,
|
||||
useHarrisDetector,
|
||||
k );
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ int main( int argc, char** argv )
|
||||
if( needToInit )
|
||||
{
|
||||
// automatic initialization
|
||||
goodFeaturesToTrack(gray, points[1], MAX_COUNT, 0.01, 10, Mat(), 3, 0, 0.04);
|
||||
goodFeaturesToTrack(gray, points[1], MAX_COUNT, 0.01, 10, Mat(), 3, 3, 0, 0.04);
|
||||
cornerSubPix(gray, points[1], subPixWinSize, Size(-1,-1), termcrit);
|
||||
addRemovePt = false;
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ void goodFeaturesToTrack_Demo( int, void* )
|
||||
vector<Point2f> corners;
|
||||
double qualityLevel = 0.01;
|
||||
double minDistance = 10;
|
||||
int blockSize = 3;
|
||||
int blockSize = 3, gradiantSize = 3;
|
||||
bool useHarrisDetector = false;
|
||||
double k = 0.04;
|
||||
|
||||
@ -75,6 +75,7 @@ void goodFeaturesToTrack_Demo( int, void* )
|
||||
minDistance,
|
||||
Mat(),
|
||||
blockSize,
|
||||
gradiantSize,
|
||||
useHarrisDetector,
|
||||
k );
|
||||
|
||||
|
@ -59,7 +59,7 @@ void goodFeaturesToTrack_Demo( int, void* )
|
||||
vector<Point2f> corners;
|
||||
double qualityLevel = 0.01;
|
||||
double minDistance = 10;
|
||||
int blockSize = 3;
|
||||
int blockSize = 3, gradiantSize = 3;
|
||||
bool useHarrisDetector = false;
|
||||
double k = 0.04;
|
||||
|
||||
@ -75,6 +75,7 @@ void goodFeaturesToTrack_Demo( int, void* )
|
||||
minDistance,
|
||||
Mat(),
|
||||
blockSize,
|
||||
gradiantSize,
|
||||
useHarrisDetector,
|
||||
k );
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user