Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
daa02aaa
Commit
daa02aaa
authored
Jan 29, 2013
by
Andrey Kamaev
Committed by
OpenCV Buildbot
Jan 29, 2013
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #360 from vpisarev:sift_fixes
parents
3dbb98e4
c69312ea
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
84 additions
and
6 deletions
+84
-6
CMakeLists.txt
modules/nonfree/CMakeLists.txt
+1
-1
sift.cpp
modules/nonfree/src/sift.cpp
+0
-0
test_features2d.cpp
modules/nonfree/test/test_features2d.cpp
+57
-2
test_rotation_and_scale_invariance.cpp
modules/nonfree/test/test_rotation_and_scale_invariance.cpp
+24
-3
descriptor_extractor_matcher.cpp
samples/cpp/descriptor_extractor_matcher.cpp
+2
-0
No files found.
modules/nonfree/CMakeLists.txt
View file @
daa02aaa
...
@@ -3,4 +3,4 @@ if(BUILD_ANDROID_PACKAGE)
...
@@ -3,4 +3,4 @@ if(BUILD_ANDROID_PACKAGE)
endif
()
endif
()
set
(
the_description
"Functionality with possible limitations on the use"
)
set
(
the_description
"Functionality with possible limitations on the use"
)
ocv_define_module
(
nonfree opencv_imgproc opencv_features2d
)
ocv_define_module
(
nonfree opencv_imgproc opencv_features2d
opencv_calib3d
)
modules/nonfree/src/sift.cpp
View file @
daa02aaa
This diff is collapsed.
Click to expand it.
modules/nonfree/test/test_features2d.cpp
View file @
daa02aaa
...
@@ -40,6 +40,7 @@
...
@@ -40,6 +40,7 @@
//M*/
//M*/
#include "test_precomp.hpp"
#include "test_precomp.hpp"
#include "opencv2/calib3d/calib3d.hpp"
using
namespace
std
;
using
namespace
std
;
using
namespace
cv
;
using
namespace
cv
;
...
@@ -1085,4 +1086,59 @@ TEST(Features2d_BruteForceDescriptorMatcher_knnMatch, regression)
...
@@ -1085,4 +1086,59 @@ TEST(Features2d_BruteForceDescriptorMatcher_knnMatch, regression)
Ptr<DescriptorExtractor> s = DescriptorExtractor::create("SURF");
Ptr<DescriptorExtractor> s = DescriptorExtractor::create("SURF");
ASSERT_STREQ(s->paramHelp("extended").c_str(), "");
ASSERT_STREQ(s->paramHelp("extended").c_str(), "");
}
}
*/
*/
\ No newline at end of file
class
CV_DetectPlanarTest
:
public
cvtest
::
BaseTest
{
public
:
CV_DetectPlanarTest
(
const
string
&
_fname
,
int
_min_ninliers
)
:
fname
(
_fname
),
min_ninliers
(
_min_ninliers
)
{}
protected
:
void
run
(
int
)
{
Ptr
<
Feature2D
>
f
=
Algorithm
::
create
<
Feature2D
>
(
"Feature2D."
+
fname
);
if
(
f
.
empty
())
return
;
string
path
=
string
(
ts
->
get_data_path
())
+
"detectors_descriptors_evaluation/planar/"
;
string
imgname1
=
path
+
"box.png"
;
string
imgname2
=
path
+
"box_in_scene.png"
;
Mat
img1
=
imread
(
imgname1
,
0
);
Mat
img2
=
imread
(
imgname2
,
0
);
if
(
img1
.
empty
()
||
img2
.
empty
()
)
{
ts
->
printf
(
cvtest
::
TS
::
LOG
,
"missing %s and/or %s
\n
"
,
imgname1
.
c_str
(),
imgname2
.
c_str
());
ts
->
set_failed_test_info
(
cvtest
::
TS
::
FAIL_INVALID_TEST_DATA
);
return
;
}
vector
<
KeyPoint
>
kpt1
,
kpt2
;
Mat
d1
,
d2
;
f
->
operator
()(
img1
,
Mat
(),
kpt1
,
d1
);
f
->
operator
()(
img1
,
Mat
(),
kpt2
,
d2
);
vector
<
DMatch
>
matches
;
BFMatcher
(
NORM_L2
,
true
).
match
(
d1
,
d2
,
matches
);
vector
<
Point2f
>
pt1
,
pt2
;
for
(
size_t
i
=
0
;
i
<
matches
.
size
();
i
++
)
{
pt1
.
push_back
(
kpt1
[
matches
[
i
].
queryIdx
].
pt
);
pt2
.
push_back
(
kpt2
[
matches
[
i
].
trainIdx
].
pt
);
}
Mat
inliers
,
H
=
findHomography
(
pt1
,
pt2
,
RANSAC
,
10
,
inliers
);
int
ninliers
=
countNonZero
(
inliers
);
if
(
ninliers
<
min_ninliers
)
{
ts
->
printf
(
cvtest
::
TS
::
LOG
,
"too little inliers (%d) vs expected %d
\n
"
,
ninliers
,
min_ninliers
);
ts
->
set_failed_test_info
(
cvtest
::
TS
::
FAIL_INVALID_TEST_DATA
);
return
;
}
}
string
fname
;
int
min_ninliers
;
};
TEST
(
Features2d_SIFTHomographyTest
,
regression
)
{
CV_DetectPlanarTest
test
(
"SIFT"
,
80
);
test
.
safe_run
();
}
//TEST(Features2d_SURFHomographyTest, regression) { CV_DetectPlanarTest test("SURF", 80); test.safe_run(); }
modules/nonfree/test/test_rotation_and_scale_invariance.cpp
View file @
daa02aaa
...
@@ -186,6 +186,20 @@ void matchKeyPoints(const vector<KeyPoint>& keypoints0, const Mat& H,
...
@@ -186,6 +186,20 @@ void matchKeyPoints(const vector<KeyPoint>& keypoints0, const Mat& H,
}
}
}
}
static
void
removeVerySmallKeypoints
(
vector
<
KeyPoint
>&
keypoints
)
{
size_t
i
,
j
=
0
,
n
=
keypoints
.
size
();
for
(
i
=
0
;
i
<
n
;
i
++
)
{
if
(
(
keypoints
[
i
].
octave
&
128
)
!=
0
)
;
else
keypoints
[
j
++
]
=
keypoints
[
i
];
}
keypoints
.
resize
(
j
);
}
class
DetectorRotationInvarianceTest
:
public
cvtest
::
BaseTest
class
DetectorRotationInvarianceTest
:
public
cvtest
::
BaseTest
{
{
public
:
public
:
...
@@ -216,6 +230,7 @@ protected:
...
@@ -216,6 +230,7 @@ protected:
vector
<
KeyPoint
>
keypoints0
;
vector
<
KeyPoint
>
keypoints0
;
featureDetector
->
detect
(
image0
,
keypoints0
);
featureDetector
->
detect
(
image0
,
keypoints0
);
removeVerySmallKeypoints
(
keypoints0
);
if
(
keypoints0
.
size
()
<
15
)
if
(
keypoints0
.
size
()
<
15
)
CV_Error
(
CV_StsAssert
,
"Detector gives too few points in a test image
\n
"
);
CV_Error
(
CV_StsAssert
,
"Detector gives too few points in a test image
\n
"
);
...
@@ -226,6 +241,7 @@ protected:
...
@@ -226,6 +241,7 @@ protected:
vector
<
KeyPoint
>
keypoints1
;
vector
<
KeyPoint
>
keypoints1
;
featureDetector
->
detect
(
image1
,
keypoints1
,
mask1
);
featureDetector
->
detect
(
image1
,
keypoints1
,
mask1
);
removeVerySmallKeypoints
(
keypoints1
);
vector
<
DMatch
>
matches
;
vector
<
DMatch
>
matches
;
matchKeyPoints
(
keypoints0
,
H
,
keypoints1
,
matches
);
matchKeyPoints
(
keypoints0
,
H
,
keypoints1
,
matches
);
...
@@ -329,6 +345,7 @@ protected:
...
@@ -329,6 +345,7 @@ protected:
vector
<
KeyPoint
>
keypoints0
;
vector
<
KeyPoint
>
keypoints0
;
Mat
descriptors0
;
Mat
descriptors0
;
featureDetector
->
detect
(
image0
,
keypoints0
);
featureDetector
->
detect
(
image0
,
keypoints0
);
removeVerySmallKeypoints
(
keypoints0
);
if
(
keypoints0
.
size
()
<
15
)
if
(
keypoints0
.
size
()
<
15
)
CV_Error
(
CV_StsAssert
,
"Detector gives too few points in a test image
\n
"
);
CV_Error
(
CV_StsAssert
,
"Detector gives too few points in a test image
\n
"
);
descriptorExtractor
->
compute
(
image0
,
keypoints0
,
descriptors0
);
descriptorExtractor
->
compute
(
image0
,
keypoints0
,
descriptors0
);
...
@@ -382,6 +399,7 @@ protected:
...
@@ -382,6 +399,7 @@ protected:
float
minDescInliersRatio
;
float
minDescInliersRatio
;
};
};
class
DetectorScaleInvarianceTest
:
public
cvtest
::
BaseTest
class
DetectorScaleInvarianceTest
:
public
cvtest
::
BaseTest
{
{
public
:
public
:
...
@@ -412,6 +430,7 @@ protected:
...
@@ -412,6 +430,7 @@ protected:
vector
<
KeyPoint
>
keypoints0
;
vector
<
KeyPoint
>
keypoints0
;
featureDetector
->
detect
(
image0
,
keypoints0
);
featureDetector
->
detect
(
image0
,
keypoints0
);
removeVerySmallKeypoints
(
keypoints0
);
if
(
keypoints0
.
size
()
<
15
)
if
(
keypoints0
.
size
()
<
15
)
CV_Error
(
CV_StsAssert
,
"Detector gives too few points in a test image
\n
"
);
CV_Error
(
CV_StsAssert
,
"Detector gives too few points in a test image
\n
"
);
...
@@ -423,6 +442,7 @@ protected:
...
@@ -423,6 +442,7 @@ protected:
vector
<
KeyPoint
>
keypoints1
,
osiKeypoints1
;
// osi - original size image
vector
<
KeyPoint
>
keypoints1
,
osiKeypoints1
;
// osi - original size image
featureDetector
->
detect
(
image1
,
keypoints1
);
featureDetector
->
detect
(
image1
,
keypoints1
);
removeVerySmallKeypoints
(
keypoints1
);
if
(
keypoints1
.
size
()
<
15
)
if
(
keypoints1
.
size
()
<
15
)
CV_Error
(
CV_StsAssert
,
"Detector gives too few points in a test image
\n
"
);
CV_Error
(
CV_StsAssert
,
"Detector gives too few points in a test image
\n
"
);
...
@@ -531,6 +551,7 @@ protected:
...
@@ -531,6 +551,7 @@ protected:
vector
<
KeyPoint
>
keypoints0
;
vector
<
KeyPoint
>
keypoints0
;
featureDetector
->
detect
(
image0
,
keypoints0
);
featureDetector
->
detect
(
image0
,
keypoints0
);
removeVerySmallKeypoints
(
keypoints0
);
if
(
keypoints0
.
size
()
<
15
)
if
(
keypoints0
.
size
()
<
15
)
CV_Error
(
CV_StsAssert
,
"Detector gives too few points in a test image
\n
"
);
CV_Error
(
CV_StsAssert
,
"Detector gives too few points in a test image
\n
"
);
Mat
descriptors0
;
Mat
descriptors0
;
...
@@ -603,8 +624,8 @@ TEST(Features2d_RotationInvariance_Detector_SURF, regression)
...
@@ -603,8 +624,8 @@ TEST(Features2d_RotationInvariance_Detector_SURF, regression)
TEST
(
Features2d_RotationInvariance_Detector_SIFT
,
regression
)
TEST
(
Features2d_RotationInvariance_Detector_SIFT
,
regression
)
{
{
DetectorRotationInvarianceTest
test
(
Algorithm
::
create
<
FeatureDetector
>
(
"Feature2D.SIFT"
),
DetectorRotationInvarianceTest
test
(
Algorithm
::
create
<
FeatureDetector
>
(
"Feature2D.SIFT"
),
0.
7
5
f
,
0.
4
5
f
,
0.7
6
f
);
0.7
0
f
);
test
.
safe_run
();
test
.
safe_run
();
}
}
...
@@ -665,7 +686,7 @@ TEST(Features2d_ScaleInvariance_Descriptor_SIFT, regression)
...
@@ -665,7 +686,7 @@ TEST(Features2d_ScaleInvariance_Descriptor_SIFT, regression)
DescriptorScaleInvarianceTest
test
(
Algorithm
::
create
<
FeatureDetector
>
(
"Feature2D.SIFT"
),
DescriptorScaleInvarianceTest
test
(
Algorithm
::
create
<
FeatureDetector
>
(
"Feature2D.SIFT"
),
Algorithm
::
create
<
DescriptorExtractor
>
(
"Feature2D.SIFT"
),
Algorithm
::
create
<
DescriptorExtractor
>
(
"Feature2D.SIFT"
),
NORM_L1
,
NORM_L1
,
0.
87
f
);
0.
78
f
);
test
.
safe_run
();
test
.
safe_run
();
}
}
...
...
samples/cpp/descriptor_extractor_matcher.cpp
View file @
daa02aaa
...
@@ -221,6 +221,8 @@ static void doIteration( const Mat& img1, Mat& img2, bool isWarpPerspective,
...
@@ -221,6 +221,8 @@ static void doIteration( const Mat& img1, Mat& img2, bool isWarpPerspective,
drawMatches
(
img1
,
keypoints1
,
img2
,
keypoints2
,
filteredMatches
,
drawImg
,
CV_RGB
(
0
,
0
,
255
),
CV_RGB
(
255
,
0
,
0
),
matchesMask
,
drawMatches
(
img1
,
keypoints1
,
img2
,
keypoints2
,
filteredMatches
,
drawImg
,
CV_RGB
(
0
,
0
,
255
),
CV_RGB
(
255
,
0
,
0
),
matchesMask
,
DrawMatchesFlags
::
DRAW_OVER_OUTIMG
|
DrawMatchesFlags
::
NOT_DRAW_SINGLE_POINTS
);
DrawMatchesFlags
::
DRAW_OVER_OUTIMG
|
DrawMatchesFlags
::
NOT_DRAW_SINGLE_POINTS
);
#endif
#endif
printf
(
"Number of inliers: %d
\n
"
,
countNonZero
(
matchesMask
));
}
}
else
else
drawMatches
(
img1
,
keypoints1
,
img2
,
keypoints2
,
filteredMatches
,
drawImg
);
drawMatches
(
img1
,
keypoints1
,
img2
,
keypoints2
,
filteredMatches
,
drawImg
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment