mirror of https://github.com/opencv/opencv.git
lot's of changes; nonfree & photo modules added; SIFT & SURF -> nonfree module; Inpainting -> photo; refactored features2d (ORB is still failing tests), optimized brute-force matcher and made it non-template.
parent
6300215b94
commit
957e80abbd
99 changed files with 6690 additions and 7211 deletions
@ -0,0 +1,5 @@ |
|||||||
|
*************************************** |
||||||
|
contrib. Contributed/Experimental Stuff |
||||||
|
*************************************** |
||||||
|
|
||||||
|
The module contains some recently added functionality that has not been stabilized, or functionality that is considered optional. |
@ -0,0 +1,3 @@ |
|||||||
|
#include "test_precomp.hpp" |
||||||
|
|
||||||
|
CV_TEST_MAIN("cv") |
@ -0,0 +1 @@ |
|||||||
|
#include "test_precomp.hpp" |
@ -0,0 +1,9 @@ |
|||||||
|
#ifndef __OPENCV_TEST_PRECOMP_HPP__ |
||||||
|
#define __OPENCV_TEST_PRECOMP_HPP__ |
||||||
|
|
||||||
|
#include "opencv2/ts/ts.hpp" |
||||||
|
#include "opencv2/contrib/contrib.hpp" |
||||||
|
#include <iostream> |
||||||
|
|
||||||
|
#endif |
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,513 +0,0 @@ |
|||||||
# x1 y1 x2 y2 |
|
||||||
-1 -2 -1 7 |
|
||||||
-1 -14 3 -3 |
|
||||||
-2 1 2 11 |
|
||||||
6 1 -7 -10 |
|
||||||
2 13 0 -1 |
|
||||||
5 -14 -3 5 |
|
||||||
8 -2 4 2 |
|
||||||
8 -11 5 -15 |
|
||||||
-23 -6 -9 8 |
|
||||||
6 -12 8 -10 |
|
||||||
-1 -3 1 8 |
|
||||||
6 3 6 5 |
|
||||||
-6 -7 -5 5 |
|
||||||
-2 22 -8 -11 |
|
||||||
7 14 5 8 |
|
||||||
14 -1 -14 -5 |
|
||||||
9 -14 0 2 |
|
||||||
-3 7 6 22 |
|
||||||
6 -6 -5 -8 |
|
||||||
9 -5 -1 7 |
|
||||||
-7 -3 -18 -10 |
|
||||||
-5 4 11 0 |
|
||||||
3 2 10 9 |
|
||||||
3 -10 9 4 |
|
||||||
12 0 19 -3 |
|
||||||
15 1 -5 -11 |
|
||||||
-1 14 8 7 |
|
||||||
-23 7 5 -5 |
|
||||||
-6 0 17 -10 |
|
||||||
-4 13 -4 -3 |
|
||||||
1 -12 2 -12 |
|
||||||
8 0 22 3 |
|
||||||
13 -13 -1 3 |
|
||||||
17 -16 10 6 |
|
||||||
15 7 0 -5 |
|
||||||
-12 2 -2 19 |
|
||||||
-6 3 -15 -4 |
|
||||||
3 8 14 0 |
|
||||||
-11 4 5 5 |
|
||||||
-7 11 1 7 |
|
||||||
12 6 3 21 |
|
||||||
2 -3 1 14 |
|
||||||
1 5 11 -5 |
|
||||||
-17 3 2 -6 |
|
||||||
8 6 -10 5 |
|
||||||
-2 -14 4 0 |
|
||||||
-7 5 5 -6 |
|
||||||
4 10 -7 4 |
|
||||||
0 22 -18 7 |
|
||||||
-3 -1 18 0 |
|
||||||
22 -4 3 -5 |
|
||||||
-7 1 -3 2 |
|
||||||
-20 19 -2 17 |
|
||||||
-10 3 24 -8 |
|
||||||
-14 -5 5 7 |
|
||||||
12 -2 -15 -4 |
|
||||||
12 4 -19 0 |
|
||||||
13 20 5 3 |
|
||||||
-12 -8 0 5 |
|
||||||
6 -5 -11 -7 |
|
||||||
-11 6 -22 -3 |
|
||||||
4 15 1 10 |
|
||||||
-4 -7 -6 15 |
|
||||||
10 5 24 0 |
|
||||||
6 3 -2 22 |
|
||||||
14 -13 -4 4 |
|
||||||
8 -13 -22 -18 |
|
||||||
-1 -1 3 -7 |
|
||||||
-12 -19 3 4 |
|
||||||
10 8 -2 13 |
|
||||||
-1 -6 -5 -6 |
|
||||||
-21 2 2 -3 |
|
||||||
-7 4 16 0 |
|
||||||
-5 -6 -1 -12 |
|
||||||
-1 1 18 9 |
|
||||||
10 -7 6 -11 |
|
||||||
3 4 -7 19 |
|
||||||
5 -18 5 -4 |
|
||||||
0 4 4 -20 |
|
||||||
-11 7 12 18 |
|
||||||
17 -20 7 -18 |
|
||||||
15 2 -11 19 |
|
||||||
6 -18 3 -7 |
|
||||||
1 -4 13 -14 |
|
||||||
3 17 -8 2 |
|
||||||
2 -7 6 1 |
|
||||||
-9 17 8 -2 |
|
||||||
-6 -8 12 -1 |
|
||||||
4 -2 6 -1 |
|
||||||
7 -2 8 6 |
|
||||||
-1 -8 -9 -7 |
|
||||||
-9 8 0 15 |
|
||||||
22 0 -15 -4 |
|
||||||
-1 -14 -2 3 |
|
||||||
-4 -7 -7 17 |
|
||||||
-2 -8 -4 9 |
|
||||||
-7 5 7 7 |
|
||||||
13 -5 11 -8 |
|
||||||
-4 11 8 0 |
|
||||||
-11 5 -6 -9 |
|
||||||
-6 2 -20 3 |
|
||||||
2 -6 10 6 |
|
||||||
-6 -6 7 -15 |
|
||||||
-3 -6 1 2 |
|
||||||
0 11 2 -3 |
|
||||||
-12 7 5 14 |
|
||||||
-7 0 -1 -1 |
|
||||||
0 -16 8 6 |
|
||||||
11 22 -3 0 |
|
||||||
0 19 -17 5 |
|
||||||
-14 -23 -19 -13 |
|
||||||
10 -8 -2 -11 |
|
||||||
6 -11 13 -10 |
|
||||||
-7 1 0 14 |
|
||||||
1 -12 -5 -5 |
|
||||||
7 4 -1 8 |
|
||||||
-5 -1 2 15 |
|
||||||
-1 -3 -10 7 |
|
||||||
-6 3 -18 10 |
|
||||||
-13 -7 10 -13 |
|
||||||
-1 1 -10 13 |
|
||||||
14 -19 -14 8 |
|
||||||
-13 -4 1 7 |
|
||||||
-2 1 -7 12 |
|
||||||
-5 3 -5 1 |
|
||||||
-2 -2 -10 8 |
|
||||||
14 2 7 8 |
|
||||||
9 3 2 8 |
|
||||||
1 -9 0 -18 |
|
||||||
0 4 12 1 |
|
||||||
9 0 -10 -14 |
|
||||||
-9 -13 6 -2 |
|
||||||
5 1 10 10 |
|
||||||
-6 -3 -5 -16 |
|
||||||
6 11 0 -5 |
|
||||||
10 -23 2 1 |
|
||||||
-5 13 9 -3 |
|
||||||
-1 -4 -5 -13 |
|
||||||
13 10 8 -11 |
|
||||||
20 19 2 -9 |
|
||||||
-8 4 -9 0 |
|
||||||
10 -14 19 15 |
|
||||||
-12 -14 -3 -10 |
|
||||||
-3 -23 -2 17 |
|
||||||
-11 -3 -14 6 |
|
||||||
-2 19 2 -4 |
|
||||||
5 -5 -13 3 |
|
||||||
-2 2 4 -5 |
|
||||||
4 17 -11 17 |
|
||||||
-2 -7 23 1 |
|
||||||
13 8 -16 1 |
|
||||||
-5 -13 -17 1 |
|
||||||
6 4 -3 -8 |
|
||||||
-9 -5 -10 -2 |
|
||||||
0 -9 -2 -7 |
|
||||||
0 5 2 5 |
|
||||||
-16 -4 3 6 |
|
||||||
-15 2 12 -2 |
|
||||||
-1 4 2 6 |
|
||||||
1 1 -8 -2 |
|
||||||
12 -2 -2 -5 |
|
||||||
8 -8 9 -9 |
|
||||||
-10 2 1 3 |
|
||||||
10 -4 4 -9 |
|
||||||
12 6 5 2 |
|
||||||
-8 -3 5 0 |
|
||||||
1 -13 2 -7 |
|
||||||
-10 -1 -18 7 |
|
||||||
8 -1 -10 -9 |
|
||||||
-1 -23 2 6 |
|
||||||
-3 -5 2 3 |
|
||||||
11 0 -7 -4 |
|
||||||
2 15 -3 -10 |
|
||||||
-8 -20 3 -13 |
|
||||||
-12 -19 -11 5 |
|
||||||
-13 -17 2 -3 |
|
||||||
4 7 0 -12 |
|
||||||
-1 5 -6 -14 |
|
||||||
11 -4 -4 0 |
|
||||||
10 3 -3 7 |
|
||||||
21 13 6 -11 |
|
||||||
24 -12 -4 -7 |
|
||||||
16 4 -14 3 |
|
||||||
5 -3 -12 -7 |
|
||||||
-4 0 -5 7 |
|
||||||
-9 -17 -7 13 |
|
||||||
-6 22 5 -11 |
|
||||||
-8 2 -11 23 |
|
||||||
-10 7 14 -1 |
|
||||||
-10 -3 3 8 |
|
||||||
1 -13 0 -6 |
|
||||||
-21 -7 -14 6 |
|
||||||
19 18 -6 -4 |
|
||||||
7 10 -4 -1 |
|
||||||
21 -1 -5 1 |
|
||||||
6 -10 -2 -11 |
|
||||||
-3 18 7 -1 |
|
||||||
-9 -3 10 -5 |
|
||||||
14 -13 -3 17 |
|
||||||
-19 11 -18 -1 |
|
||||||
-2 8 -23 -18 |
|
||||||
-5 0 -9 -2 |
|
||||||
-11 -4 -8 2 |
|
||||||
6 14 -6 -3 |
|
||||||
0 -3 0 -15 |
|
||||||
4 -9 -9 -15 |
|
||||||
11 -1 11 3 |
|
||||||
-16 -10 7 -7 |
|
||||||
-10 -2 -2 -10 |
|
||||||
-3 -5 -23 5 |
|
||||||
-8 13 -11 -15 |
|
||||||
11 -15 -6 6 |
|
||||||
-3 -16 2 -2 |
|
||||||
12 6 24 -16 |
|
||||||
0 -10 11 8 |
|
||||||
7 -7 -7 -19 |
|
||||||
16 5 -3 9 |
|
||||||
7 9 -16 -7 |
|
||||||
2 3 9 -10 |
|
||||||
1 21 7 8 |
|
||||||
0 7 17 1 |
|
||||||
12 -8 6 9 |
|
||||||
-7 11 -6 -8 |
|
||||||
0 19 3 9 |
|
||||||
-7 1 -11 -5 |
|
||||||
8 0 14 -2 |
|
||||||
-2 12 -6 -15 |
|
||||||
12 4 -21 0 |
|
||||||
-4 17 -7 -6 |
|
||||||
-9 -10 -7 -14 |
|
||||||
-10 -15 -14 -15 |
|
||||||
-5 -7 -12 5 |
|
||||||
0 -4 -4 15 |
|
||||||
2 5 -23 -6 |
|
||||||
-21 -4 4 -6 |
|
||||||
5 -10 6 -15 |
|
||||||
-3 4 5 -1 |
|
||||||
19 -4 -4 -23 |
|
||||||
17 -4 -11 13 |
|
||||||
12 1 -14 4 |
|
||||||
-6 -11 10 -20 |
|
||||||
5 4 20 3 |
|
||||||
-20 -8 1 3 |
|
||||||
9 -19 -3 9 |
|
||||||
15 18 -4 11 |
|
||||||
16 12 7 8 |
|
||||||
-8 -14 9 -3 |
|
||||||
0 -6 -4 2 |
|
||||||
-10 1 2 -1 |
|
||||||
-7 8 18 -6 |
|
||||||
12 9 -23 -7 |
|
||||||
-6 8 2 5 |
|
||||||
6 -9 -7 -12 |
|
||||||
-2 -1 2 -7 |
|
||||||
9 9 15 7 |
|
||||||
2 6 6 -6 |
|
||||||
12 16 19 0 |
|
||||||
3 4 0 6 |
|
||||||
-1 -2 17 2 |
|
||||||
1 8 1 3 |
|
||||||
-1 -12 0 -11 |
|
||||||
2 -11 9 7 |
|
||||||
3 -1 4 -19 |
|
||||||
-11 -1 3 -1 |
|
||||||
-10 1 -4 -10 |
|
||||||
3 -2 11 6 |
|
||||||
7 3 -8 -9 |
|
||||||
-14 24 -10 -2 |
|
||||||
-3 -3 -6 -18 |
|
||||||
-10 -13 -1 -7 |
|
||||||
-7 2 -6 9 |
|
||||||
-4 2 -13 6 |
|
||||||
-4 4 3 -2 |
|
||||||
2 -4 13 9 |
|
||||||
5 -11 -11 -6 |
|
||||||
-2 4 -9 11 |
|
||||||
0 -19 -5 -23 |
|
||||||
-7 -5 -6 -3 |
|
||||||
-4 -6 14 12 |
|
||||||
-11 12 -16 -8 |
|
||||||
15 -21 6 -12 |
|
||||||
-1 -2 16 -8 |
|
||||||
-1 6 -2 -8 |
|
||||||
-1 1 8 -9 |
|
||||||
-4 3 -2 -2 |
|
||||||
0 -7 -8 4 |
|
||||||
-11 11 2 -12 |
|
||||||
3 2 7 11 |
|
||||||
-4 -7 -6 -9 |
|
||||||
-7 3 0 -5 |
|
||||||
-7 3 -5 -10 |
|
||||||
-1 -3 -10 8 |
|
||||||
8 0 1 5 |
|
||||||
0 9 16 1 |
|
||||||
4 8 -3 -11 |
|
||||||
9 -15 17 8 |
|
||||||
2 0 17 -9 |
|
||||||
-11 -6 -3 -10 |
|
||||||
1 1 -8 15 |
|
||||||
-13 -12 4 -2 |
|
||||||
4 -6 -10 -6 |
|
||||||
-7 5 -5 7 |
|
||||||
6 10 9 8 |
|
||||||
7 -5 -3 -18 |
|
||||||
3 -6 4 5 |
|
||||||
-13 -10 -3 -5 |
|
||||||
2 -11 0 -16 |
|
||||||
-21 7 -13 -5 |
|
||||||
-14 -14 -4 -4 |
|
||||||
9 4 -3 7 |
|
||||||
11 4 -4 10 |
|
||||||
17 6 17 9 |
|
||||||
8 -10 -11 0 |
|
||||||
-16 -6 8 -6 |
|
||||||
5 -13 -5 10 |
|
||||||
2 3 16 12 |
|
||||||
-8 13 -6 0 |
|
||||||
0 10 -11 4 |
|
||||||
5 8 -2 10 |
|
||||||
-7 11 3 -13 |
|
||||||
4 2 -3 -7 |
|
||||||
-2 -14 16 -11 |
|
||||||
-6 11 6 7 |
|
||||||
15 -3 -10 8 |
|
||||||
8 -3 -12 12 |
|
||||||
6 -13 7 -14 |
|
||||||
-5 -11 -6 -8 |
|
||||||
-6 7 3 6 |
|
||||||
10 -4 1 5 |
|
||||||
16 9 13 10 |
|
||||||
10 -17 8 2 |
|
||||||
1 -5 -4 4 |
|
||||||
8 -14 2 -5 |
|
||||||
-9 4 -3 -6 |
|
||||||
-7 3 0 -10 |
|
||||||
-8 -2 4 -10 |
|
||||||
5 -8 24 -9 |
|
||||||
-8 2 -9 8 |
|
||||||
17 -4 2 -5 |
|
||||||
0 14 9 -9 |
|
||||||
15 11 5 -6 |
|
||||||
1 -8 4 -3 |
|
||||||
-21 9 2 10 |
|
||||||
-1 2 11 4 |
|
||||||
3 24 -2 2 |
|
||||||
17 -8 -10 -14 |
|
||||||
5 6 7 -13 |
|
||||||
10 11 -1 0 |
|
||||||
6 4 6 -10 |
|
||||||
-2 -12 6 5 |
|
||||||
-1 3 -15 8 |
|
||||||
-4 1 11 -7 |
|
||||||
11 1 0 5 |
|
||||||
-12 6 1 10 |
|
||||||
-2 -3 4 -1 |
|
||||||
-11 -2 12 -1 |
|
||||||
-8 7 -18 -20 |
|
||||||
0 2 2 -9 |
|
||||||
-1 -13 2 -16 |
|
||||||
-1 3 -17 -5 |
|
||||||
8 15 -14 3 |
|
||||||
-12 -13 15 6 |
|
||||||
-8 2 6 2 |
|
||||||
22 6 -23 -3 |
|
||||||
-7 -2 0 -6 |
|
||||||
-10 13 6 -6 |
|
||||||
7 6 12 -10 |
|
||||||
7 -6 11 -2 |
|
||||||
-22 0 -17 -2 |
|
||||||
-1 -4 -14 -11 |
|
||||||
-8 -2 12 7 |
|
||||||
-5 12 -13 7 |
|
||||||
-2 2 6 -7 |
|
||||||
8 0 23 -3 |
|
||||||
12 6 -11 13 |
|
||||||
-10 -21 8 10 |
|
||||||
0 -3 15 7 |
|
||||||
-6 7 -12 -5 |
|
||||||
-10 -21 -11 12 |
|
||||||
-11 -5 -11 8 |
|
||||||
0 5 -1 -11 |
|
||||||
-9 8 -1 7 |
|
||||||
-23 11 -5 21 |
|
||||||
-5 0 6 -8 |
|
||||||
8 -6 12 8 |
|
||||||
5 -7 -2 3 |
|
||||||
-20 -5 9 -12 |
|
||||||
12 -6 3 -11 |
|
||||||
5 4 11 13 |
|
||||||
12 2 -12 13 |
|
||||||
-13 -4 7 4 |
|
||||||
15 0 -16 -3 |
|
||||||
2 -3 14 -2 |
|
||||||
-14 4 -11 16 |
|
||||||
3 -13 10 23 |
|
||||||
-19 9 5 2 |
|
||||||
3 5 -7 14 |
|
||||||
-13 19 15 -11 |
|
||||||
0 14 -5 -2 |
|
||||||
-4 11 -6 0 |
|
||||||
5 -2 -8 -13 |
|
||||||
-15 -11 -17 -7 |
|
||||||
3 1 -8 -10 |
|
||||||
-10 -13 -12 7 |
|
||||||
-13 0 -6 23 |
|
||||||
-17 2 -3 -7 |
|
||||||
3 1 -10 4 |
|
||||||
4 13 -6 14 |
|
||||||
-2 -19 5 -1 |
|
||||||
-8 9 -5 10 |
|
||||||
-1 7 7 5 |
|
||||||
-10 9 0 19 |
|
||||||
5 7 -7 -4 |
|
||||||
1 -11 -11 -1 |
|
||||||
-1 2 11 -4 |
|
||||||
7 -1 -2 2 |
|
||||||
-20 1 -6 -9 |
|
||||||
-18 -4 -18 8 |
|
||||||
-2 -16 -6 7 |
|
||||||
-6 -3 -4 -1 |
|
||||||
-16 0 -5 24 |
|
||||||
-2 -4 9 -1 |
|
||||||
2 -8 15 -6 |
|
||||||
4 11 -3 0 |
|
||||||
6 7 -10 2 |
|
||||||
-9 -7 -6 12 |
|
||||||
15 24 -1 -8 |
|
||||||
-9 15 -15 -3 |
|
||||||
-5 17 -10 11 |
|
||||||
13 -2 4 -15 |
|
||||||
-1 -2 -23 4 |
|
||||||
3 -16 -14 -7 |
|
||||||
-5 -3 -9 -10 |
|
||||||
3 -5 -1 -2 |
|
||||||
4 -1 8 1 |
|
||||||
9 12 -14 9 |
|
||||||
17 -9 0 -3 |
|
||||||
4 5 -6 13 |
|
||||||
-8 -1 10 19 |
|
||||||
-5 8 2 -15 |
|
||||||
-9 -12 -5 -4 |
|
||||||
0 12 4 24 |
|
||||||
-2 8 4 14 |
|
||||||
-4 8 16 -7 |
|
||||||
-1 5 -4 -8 |
|
||||||
18 -2 17 -5 |
|
||||||
-2 8 -2 -9 |
|
||||||
-7 3 -6 1 |
|
||||||
-22 -5 -2 -5 |
|
||||||
-10 -8 1 14 |
|
||||||
-13 -3 9 3 |
|
||||||
-1 -4 0 -1 |
|
||||||
-21 -7 -19 12 |
|
||||||
8 -8 8 24 |
|
||||||
-6 12 3 -2 |
|
||||||
-11 -5 -4 -22 |
|
||||||
5 -3 4 -4 |
|
||||||
24 -16 -9 7 |
|
||||||
23 -10 18 -9 |
|
||||||
12 1 21 17 |
|
||||||
-6 24 -11 -3 |
|
||||||
17 -7 -6 1 |
|
||||||
4 4 -7 2 |
|
||||||
6 14 3 -12 |
|
||||||
0 -6 13 -16 |
|
||||||
5 -10 12 7 |
|
||||||
2 5 -3 6 |
|
||||||
0 7 1 -23 |
|
||||||
-5 15 14 1 |
|
||||||
-1 -3 6 6 |
|
||||||
-9 6 12 -9 |
|
||||||
-2 4 7 -4 |
|
||||||
-5 -4 4 4 |
|
||||||
0 -13 -10 6 |
|
||||||
-12 2 -3 -6 |
|
||||||
0 16 3 -3 |
|
||||||
-14 5 11 6 |
|
||||||
11 5 -13 0 |
|
||||||
5 7 -5 -1 |
|
||||||
4 12 10 6 |
|
||||||
4 -10 -11 -1 |
|
||||||
10 4 5 -14 |
|
||||||
-14 11 0 -13 |
|
||||||
8 2 24 12 |
|
||||||
3 -1 2 -1 |
|
||||||
-14 9 3 -23 |
|
||||||
-6 -8 9 0 |
|
||||||
14 -15 -10 10 |
|
||||||
-6 -10 -5 -7 |
|
||||||
5 11 -15 -3 |
|
||||||
0 1 8 1 |
|
||||||
-6 -11 -18 -4 |
|
||||||
0 9 -4 22 |
|
||||||
-1 -5 4 -9 |
|
||||||
2 -20 6 1 |
|
||||||
2 1 -12 -9 |
|
||||||
15 5 -6 4 |
|
||||||
4 19 11 4 |
|
||||||
-4 17 -1 -8 |
|
||||||
-12 -8 -3 7 |
|
||||||
9 11 1 8 |
|
||||||
22 9 15 -15 |
|
||||||
-7 -7 -23 1 |
|
||||||
13 -5 2 -8 |
|
||||||
-5 3 -11 11 |
|
||||||
-18 3 -5 14 |
|
||||||
7 -20 -23 -10 |
|
||||||
-5 -2 0 6 |
|
||||||
-13 -17 2 -3 |
|
||||||
-1 -6 -2 14 |
|
||||||
-16 -12 6 15 |
|
||||||
-2 -12 -19 3 |
|
@ -0,0 +1,10 @@ |
|||||||
|
******************************** |
||||||
|
photo. Computational Photography |
||||||
|
******************************** |
||||||
|
|
||||||
|
.. highlight:: cpp |
||||||
|
|
||||||
|
.. toctree:: |
||||||
|
:maxdepth: 2 |
||||||
|
|
||||||
|
inpainting |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,126 @@ |
|||||||
|
/* Original code has been submitted by Liu Liu. Here is the copyright.
|
||||||
|
---------------------------------------------------------------------------------- |
||||||
|
* An OpenCV Implementation of SURF |
||||||
|
* Further Information Refer to "SURF: Speed-Up Robust Feature" |
||||||
|
* Author: Liu Liu |
||||||
|
* liuliu.1987+opencv@gmail.com |
||||||
|
* |
||||||
|
* There are still serveral lacks for this experimental implementation: |
||||||
|
* 1.The interpolation of sub-pixel mentioned in article was not implemented yet; |
||||||
|
* 2.A comparision with original libSurf.so shows that the hessian detector is not a 100% match to their implementation; |
||||||
|
* 3.Due to above reasons, I recommanded the original one for study and reuse; |
||||||
|
* |
||||||
|
* However, the speed of this implementation is something comparable to original one. |
||||||
|
* |
||||||
|
* Copyright© 2008, Liu Liu All rights reserved. |
||||||
|
* |
||||||
|
* Redistribution and use in source and binary forms, with or |
||||||
|
* without modification, are permitted provided that the following |
||||||
|
* conditions are met: |
||||||
|
* Redistributions of source code must retain the above |
||||||
|
* copyright notice, this list of conditions and the following |
||||||
|
* disclaimer. |
||||||
|
* Redistributions in binary form must reproduce the above |
||||||
|
* copyright notice, this list of conditions and the following |
||||||
|
* disclaimer in the documentation and/or other materials |
||||||
|
* provided with the distribution. |
||||||
|
* The name of Contributor may not be used to endorse or |
||||||
|
* promote products derived from this software without |
||||||
|
* specific prior written permission. |
||||||
|
* |
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND |
||||||
|
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, |
||||||
|
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, |
||||||
|
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR |
||||||
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
||||||
|
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY |
||||||
|
* OF SUCH DAMAGE. |
||||||
|
*/ |
||||||
|
|
||||||
|
#include "precomp.hpp" |
||||||
|
|
||||||
|
using namespace cv; |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
CV_IMPL CvSURFParams cvSURFParams(double threshold, int extended) |
||||||
|
{ |
||||||
|
CvSURFParams params; |
||||||
|
params.hessianThreshold = threshold; |
||||||
|
params.extended = extended; |
||||||
|
params.upright = 0; |
||||||
|
params.nOctaves = 4; |
||||||
|
params.nOctaveLayers = 2; |
||||||
|
return params; |
||||||
|
} |
||||||
|
|
||||||
|
CV_IMPL void |
||||||
|
cvExtractSURF( const CvArr* _img, const CvArr* _mask, |
||||||
|
CvSeq** _keypoints, CvSeq** _descriptors, |
||||||
|
CvMemStorage* storage, CvSURFParams params, |
||||||
|
int useProvidedKeyPts) |
||||||
|
{ |
||||||
|
Mat img = cvarrToMat(_img), mask; |
||||||
|
if(_mask) |
||||||
|
mask = cvarrToMat(_mask); |
||||||
|
vector<KeyPoint> kpt; |
||||||
|
Mat descr; |
||||||
|
|
||||||
|
Ptr<Feature2D> surf = Algorithm::create<Feature2D>("Feature2D.SURF"); |
||||||
|
if( surf.empty() ) |
||||||
|
CV_Error(CV_StsNotImplemented, "OpenCV was built without SURF support"); |
||||||
|
|
||||||
|
surf->set("hessianThreshold", params.hessianThreshold); |
||||||
|
surf->set("nOctaves", params.nOctaves); |
||||||
|
surf->set("nOctaveLayers", params.nOctaveLayers); |
||||||
|
surf->set("upright", params.upright != 0); |
||||||
|
surf->set("extended", params.extended != 0); |
||||||
|
|
||||||
|
surf->operator()(img, mask, kpt, _descriptors ? _OutputArray(descr) : noArray(), |
||||||
|
useProvidedKeyPts != 0); |
||||||
|
|
||||||
|
if( _keypoints ) |
||||||
|
*_keypoints = cvCreateSeq(0, sizeof(CvSeq), sizeof(CvSURFPoint), storage); |
||||||
|
|
||||||
|
if( _descriptors ) |
||||||
|
*_descriptors = cvCreateSeq( 0, sizeof(CvSeq), descr.cols*descr.elemSize(), storage ); |
||||||
|
|
||||||
|
for( size_t i = 0; i < kpt.size(); i++ ) |
||||||
|
{ |
||||||
|
if( _keypoints ) |
||||||
|
{ |
||||||
|
CvSURFPoint pt = cvSURFPoint(kpt[i].pt, kpt[i].class_id, cvRound(kpt[i].size)); |
||||||
|
cvSeqPush(*_keypoints, &pt); |
||||||
|
} |
||||||
|
if( _descriptors ) |
||||||
|
cvSeqPush(*_descriptors, descr.ptr(i)); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
CV_IMPL CvSeq* |
||||||
|
cvGetStarKeypoints( const CvArr* _img, CvMemStorage* storage, |
||||||
|
CvStarDetectorParams params ) |
||||||
|
{ |
||||||
|
Ptr<StarDetector> star = new StarDetector(params.maxSize, params.responseThreshold, |
||||||
|
params.lineThresholdProjected, |
||||||
|
params.lineThresholdBinarized, |
||||||
|
params.suppressNonmaxSize); |
||||||
|
vector<KeyPoint> kpts; |
||||||
|
star->detect(cvarrToMat(_img), kpts, Mat()); |
||||||
|
|
||||||
|
CvSeq* seq = cvCreateSeq(0, sizeof(CvSeq), sizeof(CvStarKeypoint), storage); |
||||||
|
for( size_t i = 0; i < kpts.size(); i++ ) |
||||||
|
{ |
||||||
|
CvStarKeypoint kpt = cvStarKeypoint(kpts[i].pt, cvRound(kpts[i].size), kpts[i].response); |
||||||
|
cvSeqPush(seq, &kpt); |
||||||
|
} |
||||||
|
return seq; |
||||||
|
} |
||||||
|
|
||||||
|
|
@ -0,0 +1,3 @@ |
|||||||
|
#include "test_precomp.hpp" |
||||||
|
|
||||||
|
CV_TEST_MAIN("cv") |
@ -0,0 +1 @@ |
|||||||
|
#include "test_precomp.hpp" |
@ -0,0 +1,11 @@ |
|||||||
|
#ifndef __OPENCV_TEST_PRECOMP_HPP__ |
||||||
|
#define __OPENCV_TEST_PRECOMP_HPP__ |
||||||
|
|
||||||
|
#include "opencv2/ts/ts.hpp" |
||||||
|
#include "opencv2/imgproc/imgproc.hpp" |
||||||
|
#include "opencv2/imgproc/imgproc_c.h" |
||||||
|
#include "opencv2/highgui/highgui.hpp" |
||||||
|
#include "opencv2/highgui/highgui_c.h" |
||||||
|
#include <iostream> |
||||||
|
|
||||||
|
#endif |
@ -0,0 +1,2 @@ |
|||||||
|
set(the_description "Functionality with possible limitations on the use") |
||||||
|
ocv_define_module(nonfree opencv_imgproc opencv_features2d) |
@ -0,0 +1,172 @@ |
|||||||
|
Feature Detection and Description |
||||||
|
================================= |
||||||
|
|
||||||
|
SIFT |
||||||
|
---- |
||||||
|
.. ocv:class:: SIFT |
||||||
|
|
||||||
|
Class for extracting keypoints and computing descriptors using the Scale Invariant Feature Transform (SIFT) approach. :: |
||||||
|
|
||||||
|
class CV_EXPORTS SIFT |
||||||
|
{ |
||||||
|
public: |
||||||
|
struct CommonParams |
||||||
|
{ |
||||||
|
static const int DEFAULT_NOCTAVES = 4; |
||||||
|
static const int DEFAULT_NOCTAVE_LAYERS = 3; |
||||||
|
static const int DEFAULT_FIRST_OCTAVE = -1; |
||||||
|
enum{ FIRST_ANGLE = 0, AVERAGE_ANGLE = 1 }; |
||||||
|
|
||||||
|
CommonParams(); |
||||||
|
CommonParams( int _nOctaves, int _nOctaveLayers, int _firstOctave, |
||||||
|
int _angleMode ); |
||||||
|
int nOctaves, nOctaveLayers, firstOctave; |
||||||
|
int angleMode; |
||||||
|
}; |
||||||
|
|
||||||
|
struct DetectorParams |
||||||
|
{ |
||||||
|
static double GET_DEFAULT_THRESHOLD() |
||||||
|
{ return 0.04 / SIFT::CommonParams::DEFAULT_NOCTAVE_LAYERS / 2.0; } |
||||||
|
static double GET_DEFAULT_EDGE_THRESHOLD() { return 10.0; } |
||||||
|
|
||||||
|
DetectorParams(); |
||||||
|
DetectorParams( double _threshold, double _edgeThreshold ); |
||||||
|
double threshold, edgeThreshold; |
||||||
|
}; |
||||||
|
|
||||||
|
struct DescriptorParams |
||||||
|
{ |
||||||
|
static double GET_DEFAULT_MAGNIFICATION() { return 3.0; } |
||||||
|
static const bool DEFAULT_IS_NORMALIZE = true; |
||||||
|
static const int DESCRIPTOR_SIZE = 128; |
||||||
|
|
||||||
|
DescriptorParams(); |
||||||
|
DescriptorParams( double _magnification, bool _isNormalize, |
||||||
|
bool _recalculateAngles ); |
||||||
|
double magnification; |
||||||
|
bool isNormalize; |
||||||
|
bool recalculateAngles; |
||||||
|
}; |
||||||
|
|
||||||
|
SIFT(); |
||||||
|
//! sift-detector constructor |
||||||
|
SIFT( double _threshold, double _edgeThreshold, |
||||||
|
int _nOctaves=CommonParams::DEFAULT_NOCTAVES, |
||||||
|
int _nOctaveLayers=CommonParams::DEFAULT_NOCTAVE_LAYERS, |
||||||
|
int _firstOctave=CommonParams::DEFAULT_FIRST_OCTAVE, |
||||||
|
int _angleMode=CommonParams::FIRST_ANGLE ); |
||||||
|
//! sift-descriptor constructor |
||||||
|
SIFT( double _magnification, bool _isNormalize=true, |
||||||
|
bool _recalculateAngles = true, |
||||||
|
int _nOctaves=CommonParams::DEFAULT_NOCTAVES, |
||||||
|
int _nOctaveLayers=CommonParams::DEFAULT_NOCTAVE_LAYERS, |
||||||
|
int _firstOctave=CommonParams::DEFAULT_FIRST_OCTAVE, |
||||||
|
int _angleMode=CommonParams::FIRST_ANGLE ); |
||||||
|
SIFT( const CommonParams& _commParams, |
||||||
|
const DetectorParams& _detectorParams = DetectorParams(), |
||||||
|
const DescriptorParams& _descriptorParams = DescriptorParams() ); |
||||||
|
|
||||||
|
//! returns the descriptor size in floats (128) |
||||||
|
int descriptorSize() const { return DescriptorParams::DESCRIPTOR_SIZE; } |
||||||
|
//! finds the keypoints using the SIFT algorithm |
||||||
|
void operator()(const Mat& img, const Mat& mask, |
||||||
|
vector<KeyPoint>& keypoints) const; |
||||||
|
//! finds the keypoints and computes descriptors for them using SIFT algorithm. |
||||||
|
//! Optionally it can compute descriptors for the user-provided keypoints |
||||||
|
void operator()(const Mat& img, const Mat& mask, |
||||||
|
vector<KeyPoint>& keypoints, |
||||||
|
Mat& descriptors, |
||||||
|
bool useProvidedKeypoints=false) const; |
||||||
|
|
||||||
|
CommonParams getCommonParams () const { return commParams; } |
||||||
|
DetectorParams getDetectorParams () const { return detectorParams; } |
||||||
|
DescriptorParams getDescriptorParams () const { return descriptorParams; } |
||||||
|
protected: |
||||||
|
... |
||||||
|
}; |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
SURF |
||||||
|
---- |
||||||
|
.. ocv:class:: SURF |
||||||
|
|
||||||
|
Class for extracting Speeded Up Robust Features from an image [Bay06]_. The class is derived from ``CvSURFParams`` structure, which specifies the algorithm parameters: |
||||||
|
|
||||||
|
.. ocv:member:: int extended |
||||||
|
|
||||||
|
* 0 means that the basic descriptors (64 elements each) shall be computed |
||||||
|
* 1 means that the extended descriptors (128 elements each) shall be computed |
||||||
|
|
||||||
|
.. ocv:member:: int upright |
||||||
|
|
||||||
|
* 0 means that detector computes orientation of each feature. |
||||||
|
* 1 means that the orientation is not computed (which is much, much faster). For example, if you match images from a stereo pair, or do image stitching, the matched features likely have very similar angles, and you can speed up feature extraction by setting ``upright=1``. |
||||||
|
|
||||||
|
.. ocv:member:: double hessianThreshold |
||||||
|
|
||||||
|
Threshold for the keypoint detector. Only features, whose hessian is larger than ``hessianThreshold`` are retained by the detector. Therefore, the larger the value, the less keypoints you will get. A good default value could be from 300 to 500, depending from the image contrast. |
||||||
|
|
||||||
|
.. ocv:member:: int nOctaves |
||||||
|
|
||||||
|
The number of a gaussian pyramid octaves that the detector uses. It is set to 4 by default. If you want to get very large features, use the larger value. If you want just small features, decrease it. |
||||||
|
|
||||||
|
.. ocv:member:: int nOctaveLayers |
||||||
|
|
||||||
|
The number of images within each octave of a gaussian pyramid. It is set to 2 by default. |
||||||
|
|
||||||
|
|
||||||
|
.. [Bay06] Bay, H. and Tuytelaars, T. and Van Gool, L. "SURF: Speeded Up Robust Features", 9th European Conference on Computer Vision, 2006 |
||||||
|
|
||||||
|
|
||||||
|
SURF::SURF |
||||||
|
---------- |
||||||
|
The SURF extractor constructors. |
||||||
|
|
||||||
|
.. ocv:function:: SURF::SURF() |
||||||
|
|
||||||
|
.. ocv:function:: SURF::SURF(double hessianThreshold, int nOctaves=4, int nOctaveLayers=2, bool extended=false, bool upright=false) |
||||||
|
|
||||||
|
.. ocv:pyfunction:: cv2.SURF(_hessianThreshold[, _nOctaves[, _nOctaveLayers[, _extended[, _upright]]]]) -> <SURF object> |
||||||
|
|
||||||
|
:param hessianThreshold: Threshold for hessian keypoint detector used in SURF. |
||||||
|
|
||||||
|
:param nOctaves: Number of pyramid octaves the keypoint detector will use. |
||||||
|
|
||||||
|
:param nOctaveLayers: Number of octave layers within each octave. |
||||||
|
|
||||||
|
:param extended: Extended descriptor flag (true - use extended 128-element descriptors; false - use 64-element descriptors). |
||||||
|
|
||||||
|
:param upright: Up-right or rotated features flag (true - do not compute orientation of features; false - compute orientation). |
||||||
|
|
||||||
|
|
||||||
|
SURF::operator() |
||||||
|
---------------- |
||||||
|
Detects keypoints and computes SURF descriptors for them. |
||||||
|
|
||||||
|
.. ocv:function:: void SURF::operator()(const Mat& image, const Mat& mask, vector<KeyPoint>& keypoints) |
||||||
|
.. ocv:function:: void SURF::operator()(const Mat& image, const Mat& mask, vector<KeyPoint>& keypoints, vector<float>& descriptors, bool useProvidedKeypoints=false) |
||||||
|
|
||||||
|
.. ocv:pyfunction:: cv2.SURF.detect(img, mask) -> keypoints |
||||||
|
.. ocv:pyfunction:: cv2.SURF.detect(img, mask[, useProvidedKeypoints]) -> keypoints, descriptors |
||||||
|
|
||||||
|
.. ocv:cfunction:: void cvExtractSURF( const CvArr* image, const CvArr* mask, CvSeq** keypoints, CvSeq** descriptors, CvMemStorage* storage, CvSURFParams params ) |
||||||
|
|
||||||
|
.. ocv:pyoldfunction:: cv.ExtractSURF(image, mask, storage, params)-> (keypoints, descriptors) |
||||||
|
|
||||||
|
:param image: Input 8-bit grayscale image |
||||||
|
|
||||||
|
:param mask: Optional input mask that marks the regions where we should detect features. |
||||||
|
|
||||||
|
:param keypoints: The input/output vector of keypoints |
||||||
|
|
||||||
|
:param descriptors: The output concatenated vectors of descriptors. Each descriptor is 64- or 128-element vector, as returned by ``SURF::descriptorSize()``. So the total size of ``descriptors`` will be ``keypoints.size()*descriptorSize()``. |
||||||
|
|
||||||
|
:param useProvidedKeypoints: Boolean flag. If it is true, the keypoint detector is not run. Instead, the provided vector of keypoints is used and the algorithm just computes their descriptors. |
||||||
|
|
||||||
|
:param storage: Memory storage for the output keypoints and descriptors in OpenCV 1.x API. |
||||||
|
|
||||||
|
:param params: SURF algorithm parameters in OpenCV 1.x API. |
||||||
|
|
@ -0,0 +1,10 @@ |
|||||||
|
******************************** |
||||||
|
nonfree. Non-free functionality |
||||||
|
******************************** |
||||||
|
|
||||||
|
The module contains algorithms that may be patented in some countries or have some other limitations on the use. |
||||||
|
|
||||||
|
.. toctree:: |
||||||
|
:maxdepth: 2 |
||||||
|
|
||||||
|
feature_detection |
@ -0,0 +1,155 @@ |
|||||||
|
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||||
|
//
|
||||||
|
// By downloading, copying, installing or using the software you agree to this license.
|
||||||
|
// If you do not agree to this license, do not download, install,
|
||||||
|
// copy or use the software.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// License Agreement
|
||||||
|
// For Open Source Computer Vision Library
|
||||||
|
//
|
||||||
|
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||||
|
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
// are permitted provided that the following conditions are met:
|
||||||
|
//
|
||||||
|
// * Redistribution's of source code must retain the above copyright notice,
|
||||||
|
// this list of conditions and the following disclaimer.
|
||||||
|
//
|
||||||
|
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||||
|
// this list of conditions and the following disclaimer in the documentation
|
||||||
|
// and/or other materials provided with the distribution.
|
||||||
|
//
|
||||||
|
// * The name of the copyright holders may not be used to endorse or promote products
|
||||||
|
// derived from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// This software is provided by the copyright holders and contributors "as is" and
|
||||||
|
// any express or implied warranties, including, but not limited to, the implied
|
||||||
|
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||||
|
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||||
|
// indirect, incidental, special, exemplary, or consequential damages
|
||||||
|
// (including, but not limited to, procurement of substitute goods or services;
|
||||||
|
// loss of use, data, or profits; or business interruption) however caused
|
||||||
|
// and on any theory of liability, whether in contract, strict liability,
|
||||||
|
// or tort (including negligence or otherwise) arising in any way out of
|
||||||
|
// the use of this software, even if advised of the possibility of such damage.
|
||||||
|
//
|
||||||
|
//M*/
|
||||||
|
|
||||||
|
#ifndef __OPENCV_NONFREE_FEATURES_2D_HPP__ |
||||||
|
#define __OPENCV_NONFREE_FEATURES_2D_HPP__ |
||||||
|
|
||||||
|
#include "opencv2/features2d/features2d.hpp" |
||||||
|
|
||||||
|
#ifdef __cplusplus |
||||||
|
|
||||||
|
namespace cv |
||||||
|
{ |
||||||
|
|
||||||
|
/*!
|
||||||
|
SIFT implementation. |
||||||
|
|
||||||
|
The class implements SIFT algorithm by D. Lowe. |
||||||
|
*/ |
||||||
|
class CV_EXPORTS_W SIFT : public Feature2D |
||||||
|
{ |
||||||
|
public: |
||||||
|
explicit SIFT( int _nfeatures=0, int _nOctaveLayers=3, |
||||||
|
double _contrastThreshold=0.04, double _edgeThreshold=10, |
||||||
|
double _sigma=1.6); |
||||||
|
|
||||||
|
//! returns the descriptor size in floats (128)
|
||||||
|
int descriptorSize() const; |
||||||
|
|
||||||
|
//! returns the descriptor type
|
||||||
|
int descriptorType() const; |
||||||
|
|
||||||
|
//! finds the keypoints using SIFT algorithm
|
||||||
|
void operator()(InputArray img, InputArray mask, |
||||||
|
vector<KeyPoint>& keypoints) const; |
||||||
|
//! finds the keypoints and computes descriptors for them using SIFT algorithm.
|
||||||
|
//! Optionally it can compute descriptors for the user-provided keypoints
|
||||||
|
void operator()(InputArray img, InputArray mask, |
||||||
|
vector<KeyPoint>& keypoints, |
||||||
|
OutputArray descriptors, |
||||||
|
bool useProvidedKeypoints=false) const; |
||||||
|
|
||||||
|
AlgorithmInfo* info() const; |
||||||
|
|
||||||
|
void buildGaussianPyramid( const Mat& base, vector<Mat>& pyr, int nOctaves ) const; |
||||||
|
void buildDoGPyramid( const vector<Mat>& pyr, vector<Mat>& dogpyr ) const; |
||||||
|
void findScaleSpaceExtrema( const vector<Mat>& gauss_pyr, const vector<Mat>& dog_pyr, |
||||||
|
vector<KeyPoint>& keypoints ) const; |
||||||
|
|
||||||
|
protected: |
||||||
|
void detectImpl( const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask=Mat() ) const; |
||||||
|
void computeImpl( const Mat& image, vector<KeyPoint>& keypoints, Mat& descriptors ) const; |
||||||
|
|
||||||
|
CV_PROP_RW int nfeatures; |
||||||
|
CV_PROP_RW int nOctaveLayers; |
||||||
|
CV_PROP_RW double contrastThreshold; |
||||||
|
CV_PROP_RW double edgeThreshold; |
||||||
|
CV_PROP_RW double sigma; |
||||||
|
}; |
||||||
|
|
||||||
|
typedef SIFT SiftFeatureDetector; |
||||||
|
typedef SIFT SiftDescriptorExtractor; |
||||||
|
|
||||||
|
/*!
|
||||||
|
SURF implementation. |
||||||
|
|
||||||
|
The class implements SURF algorithm by H. Bay et al. |
||||||
|
*/ |
||||||
|
class CV_EXPORTS_W SURF : public Feature2D |
||||||
|
{ |
||||||
|
public: |
||||||
|
//! the default constructor
|
||||||
|
SURF(); |
||||||
|
//! the full constructor taking all the necessary parameters
|
||||||
|
explicit SURF(double _hessianThreshold, |
||||||
|
bool _extended=true, bool _upright=false, |
||||||
|
int _nOctaves=4, int _nOctaveLayers=2); |
||||||
|
|
||||||
|
//! returns the descriptor size in float's (64 or 128)
|
||||||
|
int descriptorSize() const; |
||||||
|
|
||||||
|
//! returns the descriptor type
|
||||||
|
int descriptorType() const; |
||||||
|
|
||||||
|
//! finds the keypoints using fast hessian detector used in SURF
|
||||||
|
void operator()(InputArray img, InputArray mask, |
||||||
|
CV_OUT vector<KeyPoint>& keypoints) const; |
||||||
|
//! finds the keypoints and computes their descriptors. Optionally it can compute descriptors for the user-provided keypoints
|
||||||
|
void operator()(InputArray img, InputArray mask, |
||||||
|
CV_OUT vector<KeyPoint>& keypoints, |
||||||
|
OutputArray descriptors, |
||||||
|
bool useProvidedKeypoints=false) const; |
||||||
|
|
||||||
|
AlgorithmInfo* info() const; |
||||||
|
|
||||||
|
CV_PROP_RW double hessianThreshold; |
||||||
|
CV_PROP_RW int nOctaves; |
||||||
|
CV_PROP_RW int nOctaveLayers; |
||||||
|
CV_PROP_RW bool extended; |
||||||
|
CV_PROP_RW bool upright; |
||||||
|
|
||||||
|
protected: |
||||||
|
|
||||||
|
void detectImpl( const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask=Mat() ) const; |
||||||
|
void computeImpl( const Mat& image, vector<KeyPoint>& keypoints, Mat& descriptors ) const; |
||||||
|
}; |
||||||
|
|
||||||
|
typedef SURF SurfFeatureDetector; |
||||||
|
typedef SURF SurfDescriptorExtractor; |
||||||
|
|
||||||
|
} /* namespace cv */ |
||||||
|
|
||||||
|
#endif /* __cplusplus */ |
||||||
|
|
||||||
|
#endif |
||||||
|
|
||||||
|
/* End of file. */ |
@ -0,0 +1,57 @@ |
|||||||
|
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||||
|
//
|
||||||
|
// By downloading, copying, installing or using the software you agree to this license.
|
||||||
|
// If you do not agree to this license, do not download, install,
|
||||||
|
// copy or use the software.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// License Agreement
|
||||||
|
// For Open Source Computer Vision Library
|
||||||
|
//
|
||||||
|
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||||
|
// Copyright (C) 2009-2012, Willow Garage Inc., all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
// are permitted provided that the following conditions are met:
|
||||||
|
//
|
||||||
|
// * Redistribution's of source code must retain the above copyright notice,
|
||||||
|
// this list of conditions and the following disclaimer.
|
||||||
|
//
|
||||||
|
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||||
|
// this list of conditions and the following disclaimer in the documentation
|
||||||
|
// and/or other materials provided with the distribution.
|
||||||
|
//
|
||||||
|
// * The name of the copyright holders may not be used to endorse or promote products
|
||||||
|
// derived from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// This software is provided by the copyright holders and contributors "as is" and
|
||||||
|
// any express or implied warranties, including, but not limited to, the implied
|
||||||
|
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||||
|
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||||
|
// indirect, incidental, special, exemplary, or consequential damages
|
||||||
|
// (including, but not limited to, procurement of substitute goods or services;
|
||||||
|
// loss of use, data, or profits; or business interruption) however caused
|
||||||
|
// and on any theory of liability, whether in contract, strict liability,
|
||||||
|
// or tort (including negligence or otherwise) arising in any way out of
|
||||||
|
// the use of this software, even if advised of the possibility of such damage.
|
||||||
|
//
|
||||||
|
//M*/
|
||||||
|
|
||||||
|
#ifndef __OPENCV_NONFREE_HPP__ |
||||||
|
#define __OPENCV_NONFREE_HPP__ |
||||||
|
|
||||||
|
#include "opencv2/nonfree/features2d.hpp" |
||||||
|
|
||||||
|
namespace cv |
||||||
|
{ |
||||||
|
|
||||||
|
CV_EXPORTS bool initModule_nonfree(void); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
#endif |
||||||
|
|
||||||
|
/* End of file. */ |
@ -0,0 +1,3 @@ |
|||||||
|
#include "perf_precomp.hpp" |
||||||
|
|
||||||
|
CV_PERF_TEST_MAIN(nonfree) |
@ -0,0 +1 @@ |
|||||||
|
#include "perf_precomp.hpp" |
@ -0,0 +1,12 @@ |
|||||||
|
#ifndef __OPENCV_PERF_PRECOMP_HPP__ |
||||||
|
#define __OPENCV_PERF_PRECOMP_HPP__ |
||||||
|
|
||||||
|
#include "opencv2/ts/ts.hpp" |
||||||
|
#include "opencv2/nonfree/nonfree.hpp" |
||||||
|
#include "opencv2/highgui/highgui.hpp" |
||||||
|
|
||||||
|
#if GTEST_CREATE_SHARED_LIBRARY |
||||||
|
#error no modules except ts should have GTEST_CREATE_SHARED_LIBRARY defined |
||||||
|
#endif |
||||||
|
|
||||||
|
#endif |
@ -0,0 +1,44 @@ |
|||||||
|
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||||
|
//
|
||||||
|
// By downloading, copying, installing or using the software you agree to this license.
|
||||||
|
// If you do not agree to this license, do not download, install,
|
||||||
|
// copy or use the software.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Intel License Agreement
|
||||||
|
// For Open Source Computer Vision Library
|
||||||
|
//
|
||||||
|
// Copyright (C) 2000, Intel Corporation, all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
// are permitted provided that the following conditions are met:
|
||||||
|
//
|
||||||
|
// * Redistribution's of source code must retain the above copyright notice,
|
||||||
|
// this list of conditions and the following disclaimer.
|
||||||
|
//
|
||||||
|
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||||
|
// this list of conditions and the following disclaimer in the documentation
|
||||||
|
// and/or other materials provided with the distribution.
|
||||||
|
//
|
||||||
|
// * The name of Intel Corporation may not be used to endorse or promote products
|
||||||
|
// derived from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// This software is provided by the copyright holders and contributors "as is" and
|
||||||
|
// any express or implied warranties, including, but not limited to, the implied
|
||||||
|
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||||
|
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||||
|
// indirect, incidental, special, exemplary, or consequential damages
|
||||||
|
// (including, but not limited to, procurement of substitute goods or services;
|
||||||
|
// loss of use, data, or profits; or business interruption) however caused
|
||||||
|
// and on any theory of liability, whether in contract, strict liability,
|
||||||
|
// or tort (including negligence or otherwise) arising in any way out of
|
||||||
|
// the use of this software, even if advised of the possibility of such damage.
|
||||||
|
//
|
||||||
|
//M*/
|
||||||
|
|
||||||
|
#include "precomp.hpp" |
||||||
|
|
||||||
|
/* End of file. */ |
@ -0,0 +1,58 @@ |
|||||||
|
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||||
|
//
|
||||||
|
// By downloading, copying, installing or using the software you agree to this license.
|
||||||
|
// If you do not agree to this license, do not download, install,
|
||||||
|
// copy or use the software.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// License Agreement
|
||||||
|
// For Open Source Computer Vision Library
|
||||||
|
//
|
||||||
|
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||||
|
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
// are permitted provided that the following conditions are met:
|
||||||
|
//
|
||||||
|
// * Redistribution's of source code must retain the above copyright notice,
|
||||||
|
// this list of conditions and the following disclaimer.
|
||||||
|
//
|
||||||
|
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||||
|
// this list of conditions and the following disclaimer in the documentation
|
||||||
|
// and/or other materials provided with the distribution.
|
||||||
|
//
|
||||||
|
// * The name of the copyright holders may not be used to endorse or promote products
|
||||||
|
// derived from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// This software is provided by the copyright holders and contributors "as is" and
|
||||||
|
// any express or implied warranties, including, but not limited to, the implied
|
||||||
|
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||||
|
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||||
|
// indirect, incidental, special, exemplary, or consequential damages
|
||||||
|
// (including, but not limited to, procurement of substitute goods or services;
|
||||||
|
// loss of use, data, or profits; or business interruption) however caused
|
||||||
|
// and on any theory of liability, whether in contract, strict liability,
|
||||||
|
// or tort (including negligence or otherwise) arising in any way out of
|
||||||
|
// the use of this software, even if advised of the possibility of such damage.
|
||||||
|
//
|
||||||
|
//M*/
|
||||||
|
|
||||||
|
#ifndef __OPENCV_PRECOMP_H__ |
||||||
|
#define __OPENCV_PRECOMP_H__ |
||||||
|
|
||||||
|
#if _MSC_VER >= 1200 |
||||||
|
#pragma warning( disable: 4251 4512 4710 4711 4514 4996 ) |
||||||
|
#endif |
||||||
|
|
||||||
|
#ifdef HAVE_CVCONFIG_H |
||||||
|
#include "cvconfig.h" |
||||||
|
#endif |
||||||
|
|
||||||
|
#include "opencv2/nonfree/nonfree.hpp" |
||||||
|
#include "opencv2/imgproc/imgproc.hpp" |
||||||
|
#include "opencv2/core/internal.hpp" |
||||||
|
|
||||||
|
#endif |
@ -0,0 +1,772 @@ |
|||||||
|
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||||
|
//
|
||||||
|
// By downloading, copying, installing or using the software you agree to this license.
|
||||||
|
// If you do not agree to this license, do not download, install,
|
||||||
|
// copy or use the software.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Intel License Agreement
|
||||||
|
// For Open Source Computer Vision Library
|
||||||
|
//
|
||||||
|
// Copyright (C) 2000, Intel Corporation, all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
// are permitted provided that the following conditions are met:
|
||||||
|
//
|
||||||
|
// * Redistribution's of source code must retain the above copyright notice,
|
||||||
|
// this list of conditions and the following disclaimer.
|
||||||
|
//
|
||||||
|
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||||
|
// this list of conditions and the following disclaimer in the documentation
|
||||||
|
// and/or other materials provided with the distribution.
|
||||||
|
//
|
||||||
|
// * The name of Intel Corporation may not be used to endorse or promote products
|
||||||
|
// derived from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// This software is provided by the copyright holders and contributors "as is" and
|
||||||
|
// any express or implied warranties, including, but not limited to, the implied
|
||||||
|
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||||
|
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||||
|
// indirect, incidental, special, exemplary, or consequential damages
|
||||||
|
// (including, but not limited to, procurement of substitute goods or services;
|
||||||
|
// loss of use, data, or profits; or business interruption) however caused
|
||||||
|
// and on any theory of liability, whether in contract, strict liability,
|
||||||
|
// or tort (including negligence or otherwise) arising in any way out of
|
||||||
|
// the use of this software, even if advised of the possibility of such damage.
|
||||||
|
//
|
||||||
|
//M*/
|
||||||
|
|
||||||
|
/**********************************************************************************************\
|
||||||
|
Implementation of SIFT is based on the code from http://blogs.oregonstate.edu/hess/code/sift/
|
||||||
|
Below is the original copyright. |
||||||
|
|
||||||
|
// Copyright (c) 2006-2010, Rob Hess <hess@eecs.oregonstate.edu>
|
||||||
|
// All rights reserved.
|
||||||
|
|
||||||
|
// The following patent has been issued for methods embodied in this
|
||||||
|
// software: "Method and apparatus for identifying scale invariant features
|
||||||
|
// in an image and use of same for locating an object in an image," David
|
||||||
|
// G. Lowe, US Patent 6,711,293 (March 23, 2004). Provisional application
|
||||||
|
// filed March 8, 1999. Asignee: The University of British Columbia. For
|
||||||
|
// further details, contact David Lowe (lowe@cs.ubc.ca) or the
|
||||||
|
// University-Industry Liaison Office of the University of British
|
||||||
|
// Columbia.
|
||||||
|
|
||||||
|
// Note that restrictions imposed by this patent (and possibly others)
|
||||||
|
// exist independently of and may be in conflict with the freedoms granted
|
||||||
|
// in this license, which refers to copyright of the program, not patents
|
||||||
|
// for any methods that it implements. Both copyright and patent law must
|
||||||
|
// be obeyed to legally use and redistribute this program and it is not the
|
||||||
|
// purpose of this license to induce you to infringe any patents or other
|
||||||
|
// property right claims or to contest validity of any such claims. If you
|
||||||
|
// redistribute or use the program, then this license merely protects you
|
||||||
|
// from committing copyright infringement. It does not protect you from
|
||||||
|
// committing patent infringement. So, before you do anything with this
|
||||||
|
// program, make sure that you have permission to do so not merely in terms
|
||||||
|
// of copyright, but also in terms of patent law.
|
||||||
|
|
||||||
|
// Please note that this license is not to be understood as a guarantee
|
||||||
|
// either. If you use the program according to this license, but in
|
||||||
|
// conflict with patent law, it does not mean that the licensor will refund
|
||||||
|
// you for any losses that you incur if you are sued for your patent
|
||||||
|
// infringement.
|
||||||
|
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
// * Redistributions of source code must retain the above copyright and
|
||||||
|
// patent notices, this list of conditions and the following
|
||||||
|
// disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer in
|
||||||
|
// the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Oregon State University nor the names of its
|
||||||
|
// contributors may be used to endorse or promote products derived
|
||||||
|
// from this software without specific prior written permission.
|
||||||
|
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
// PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// HOLDER BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
\**********************************************************************************************/ |
||||||
|
|
||||||
|
#include "precomp.hpp" |
||||||
|
#include <iostream> |
||||||
|
#include <stdarg.h> |
||||||
|
|
||||||
|
namespace cv |
||||||
|
{ |
||||||
|
|
||||||
|
/******************************* Defs and macros *****************************/ |
||||||
|
|
||||||
|
// default number of sampled intervals per octave
|
||||||
|
static const int SIFT_INTVLS = 3; |
||||||
|
|
||||||
|
// default sigma for initial gaussian smoothing
|
||||||
|
static const float SIFT_SIGMA = 1.6f; |
||||||
|
|
||||||
|
// default threshold on keypoint contrast |D(x)|
|
||||||
|
static const float SIFT_CONTR_THR = 0.04f; |
||||||
|
|
||||||
|
// default threshold on keypoint ratio of principle curvatures
|
||||||
|
static const float SIFT_CURV_THR = 10.f; |
||||||
|
|
||||||
|
// double image size before pyramid construction?
|
||||||
|
static const bool SIFT_IMG_DBL = true; |
||||||
|
|
||||||
|
// default width of descriptor histogram array
|
||||||
|
static const int SIFT_DESCR_WIDTH = 4; |
||||||
|
|
||||||
|
// default number of bins per histogram in descriptor array
|
||||||
|
static const int SIFT_DESCR_HIST_BINS = 8; |
||||||
|
|
||||||
|
// assumed gaussian blur for input image
|
||||||
|
static const float SIFT_INIT_SIGMA = 0.5f; |
||||||
|
|
||||||
|
// width of border in which to ignore keypoints
|
||||||
|
static const int SIFT_IMG_BORDER = 5; |
||||||
|
|
||||||
|
// maximum steps of keypoint interpolation before failure
|
||||||
|
static const int SIFT_MAX_INTERP_STEPS = 5; |
||||||
|
|
||||||
|
// default number of bins in histogram for orientation assignment
|
||||||
|
static const int SIFT_ORI_HIST_BINS = 36; |
||||||
|
|
||||||
|
// determines gaussian sigma for orientation assignment
|
||||||
|
static const float SIFT_ORI_SIG_FCTR = 1.5f; |
||||||
|
|
||||||
|
// determines the radius of the region used in orientation assignment
|
||||||
|
static const float SIFT_ORI_RADIUS = 3 * SIFT_ORI_SIG_FCTR; |
||||||
|
|
||||||
|
// orientation magnitude relative to max that results in new feature
|
||||||
|
static const float SIFT_ORI_PEAK_RATIO = 0.8f; |
||||||
|
|
||||||
|
// determines the size of a single descriptor orientation histogram
|
||||||
|
static const float SIFT_DESCR_SCL_FCTR = 3.f; |
||||||
|
|
||||||
|
// threshold on magnitude of elements of descriptor vector
|
||||||
|
static const float SIFT_DESCR_MAG_THR = 0.2f; |
||||||
|
|
||||||
|
// factor used to convert floating-point descriptor to unsigned char
|
||||||
|
static const float SIFT_INT_DESCR_FCTR = 512.f; |
||||||
|
|
||||||
|
static const int SIFT_FIXPT_SCALE = 48; |
||||||
|
|
||||||
|
|
||||||
|
static Mat createInitialImage( const Mat& img, bool doubleImageSize, float sigma ) |
||||||
|
{ |
||||||
|
Mat gray, gray_fpt; |
||||||
|
if( img.channels() == 3 || img.channels() == 4 ) |
||||||
|
cvtColor(img, gray, COLOR_BGR2GRAY); |
||||||
|
else |
||||||
|
img.copyTo(gray); |
||||||
|
gray.convertTo(gray_fpt, CV_16S, SIFT_FIXPT_SCALE, 0); |
||||||
|
|
||||||
|
float sig_diff; |
||||||
|
|
||||||
|
if( doubleImageSize ) |
||||||
|
{ |
||||||
|
sig_diff = sqrtf( std::max(sigma * sigma - SIFT_INIT_SIGMA * SIFT_INIT_SIGMA * 4, 0.01f) ); |
||||||
|
Mat dbl; |
||||||
|
resize(gray_fpt, dbl, Size(gray.cols*2, gray.rows*2), 0, 0, INTER_LINEAR); |
||||||
|
GaussianBlur(dbl, dbl, Size(), sig_diff, sig_diff); |
||||||
|
return dbl; |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
sig_diff = sqrtf( std::max(sigma * sigma - SIFT_INIT_SIGMA * SIFT_INIT_SIGMA, 0.01f) ); |
||||||
|
GaussianBlur(gray_fpt, gray_fpt, Size(), sig_diff, sig_diff); |
||||||
|
return gray_fpt; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
void SIFT::buildGaussianPyramid( const Mat& base, vector<Mat>& pyr, int nOctaves ) const |
||||||
|
{ |
||||||
|
vector<double> sig(nOctaveLayers + 3); |
||||||
|
pyr.resize(nOctaves*(nOctaveLayers + 3)); |
||||||
|
|
||||||
|
// precompute Gaussian sigmas using the following formula:
|
||||||
|
// \sigma_{total}^2 = \sigma_{i}^2 + \sigma_{i-1}^2
|
||||||
|
sig[0] = sigma; |
||||||
|
double k = pow( 2., 1. / nOctaveLayers ); |
||||||
|
for( int i = 1; i < nOctaveLayers + 3; i++ ) |
||||||
|
{ |
||||||
|
double sig_prev = pow(k, (double)(i-1))*sigma; |
||||||
|
double sig_total = sig_prev*k; |
||||||
|
sig[i] = std::sqrt(sig_total*sig_total - sig_prev*sig_prev); |
||||||
|
} |
||||||
|
|
||||||
|
for( int o = 0; o < nOctaves; o++ ) |
||||||
|
{ |
||||||
|
for( int i = 0; i < nOctaveLayers + 3; i++ ) |
||||||
|
{ |
||||||
|
Mat& dst = pyr[o*(nOctaveLayers + 3) + i]; |
||||||
|
if( o == 0 && i == 0 ) |
||||||
|
dst = base; |
||||||
|
// base of new octave is halved image from end of previous octave
|
||||||
|
else if( i == 0 ) |
||||||
|
{ |
||||||
|
const Mat& src = pyr[(o-1)*(nOctaveLayers + 3) + nOctaveLayers]; |
||||||
|
resize(src, dst, Size(src.cols/2, src.rows/2), |
||||||
|
0, 0, INTER_NEAREST); |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
const Mat& src = pyr[o*(nOctaveLayers + 3) + i-1]; |
||||||
|
GaussianBlur(src, dst, Size(), sig[i], sig[i]); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
void SIFT::buildDoGPyramid( const vector<Mat>& gpyr, vector<Mat>& dogpyr ) const |
||||||
|
{ |
||||||
|
int nOctaves = (int)gpyr.size()/(nOctaveLayers + 3); |
||||||
|
dogpyr.resize( nOctaves*(nOctaveLayers + 2) ); |
||||||
|
|
||||||
|
for( int o = 0; o < nOctaves; o++ ) |
||||||
|
{ |
||||||
|
for( int i = 0; i < nOctaveLayers + 2; i++ ) |
||||||
|
{ |
||||||
|
const Mat& src1 = gpyr[o*(nOctaveLayers + 3) + i]; |
||||||
|
const Mat& src2 = gpyr[o*(nOctaveLayers + 3) + i + 1]; |
||||||
|
Mat& dst = dogpyr[o*(nOctaveLayers + 2) + i]; |
||||||
|
subtract(src2, src1, dst, noArray(), CV_16S); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
// Computes a gradient orientation histogram at a specified pixel
|
||||||
|
static float calcOrientationHist( const Mat& img, Point pt, int radius, |
||||||
|
float sigma, float* hist, int n ) |
||||||
|
{ |
||||||
|
int i, j, k, len = (radius*2+1)*(radius*2+1); |
||||||
|
|
||||||
|
float expf_scale = -1.f/(2.f * sigma * sigma); |
||||||
|
AutoBuffer<float> buf(len*4 + n+4); |
||||||
|
float *X = buf, *Y = X + len, *Mag = X, *Ori = Y + len, *W = Ori + len; |
||||||
|
float* temphist = W + len + 2; |
||||||
|
|
||||||
|
for( i = 0; i < n; i++ ) |
||||||
|
temphist[i] = 0.f; |
||||||
|
|
||||||
|
for( i = -radius, k = 0; i <= radius; i++ ) |
||||||
|
{ |
||||||
|
int y = pt.y + i; |
||||||
|
if( y <= 0 || y >= img.rows - 1 ) |
||||||
|
continue; |
||||||
|
for( j = -radius; j <= radius; j++ ) |
||||||
|
{ |
||||||
|
int x = pt.x + j; |
||||||
|
if( x <= 0 || x >= img.cols - 1 ) |
||||||
|
continue; |
||||||
|
|
||||||
|
float dx = img.at<short>(y, x+1) - img.at<short>(y, x-1); |
||||||
|
float dy = img.at<short>(y-1, x) - img.at<short>(y+1, x); |
||||||
|
|
||||||
|
X[k] = dx; Y[k] = dy; W[k] = (i*i + j*j)*expf_scale; |
||||||
|
k++; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
len = k; |
||||||
|
|
||||||
|
// compute gradient values, orientations and the weights over the pixel neighborhood
|
||||||
|
exp(W, W, len); |
||||||
|
fastAtan2(Y, X, Ori, len, true); |
||||||
|
magnitude(X, Y, Mag, len); |
||||||
|
|
||||||
|
for( k = 0; k < len; k++ ) |
||||||
|
{ |
||||||
|
int bin = cvRound((n/360.f)*Ori[k]); |
||||||
|
if( bin >= n ) |
||||||
|
bin -= n; |
||||||
|
if( bin < 0 ) |
||||||
|
bin += n; |
||||||
|
temphist[bin] += W[k]*Mag[k]; |
||||||
|
} |
||||||
|
|
||||||
|
// smooth the histogram
|
||||||
|
temphist[-1] = temphist[n-1]; |
||||||
|
temphist[-2] = temphist[n-2]; |
||||||
|
temphist[n] = temphist[0]; |
||||||
|
temphist[n+1] = temphist[1]; |
||||||
|
for( i = 0; i < n; i++ ) |
||||||
|
{ |
||||||
|
hist[i] = (temphist[i-2] + temphist[i+2])*(1.f/16.f) + |
||||||
|
(temphist[i-1] + temphist[i+1])*(4.f/16.f) + |
||||||
|
temphist[i]*(6.f/16.f); |
||||||
|
} |
||||||
|
|
||||||
|
float maxval = hist[0]; |
||||||
|
for( i = 1; i < n; i++ ) |
||||||
|
maxval = std::max(maxval, hist[i]); |
||||||
|
|
||||||
|
return maxval; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Interpolates a scale-space extremum's location and scale to subpixel
|
||||||
|
// accuracy to form an image feature. Rejects features with low contrast.
|
||||||
|
// Based on Section 4 of Lowe's paper.
|
||||||
|
static bool adjustLocalExtrema( const vector<Mat>& dog_pyr, KeyPoint& kpt, int octv, |
||||||
|
int& layer, int& r, int& c, int nOctaveLayers, |
||||||
|
float contrastThreshold, float edgeThreshold, float sigma ) |
||||||
|
{ |
||||||
|
const float img_scale = 1.f/(255*SIFT_FIXPT_SCALE); |
||||||
|
const float deriv_scale = img_scale*0.5f; |
||||||
|
const float second_deriv_scale = img_scale; |
||||||
|
const float cross_deriv_scale = img_scale*0.25f; |
||||||
|
|
||||||
|
float xi=0, xr=0, xc=0, contr; |
||||||
|
int i = 0; |
||||||
|
|
||||||
|
for( ; i < SIFT_MAX_INTERP_STEPS; i++ ) |
||||||
|
{ |
||||||
|
int idx = octv*(nOctaveLayers+2) + layer; |
||||||
|
const Mat& img = dog_pyr[idx]; |
||||||
|
const Mat& prev = dog_pyr[idx-1]; |
||||||
|
const Mat& next = dog_pyr[idx+1]; |
||||||
|
|
||||||
|
Matx31f dD((img.at<short>(r, c+1) - img.at<short>(r, c-1))*deriv_scale, |
||||||
|
(img.at<short>(r+1, c) - img.at<short>(r-1, c))*deriv_scale, |
||||||
|
(next.at<short>(r, c) - prev.at<short>(r, c))*deriv_scale); |
||||||
|
|
||||||
|
float v2 = img.at<short>(r, c)*2; |
||||||
|
float dxx = (img.at<short>(r, c+1) + img.at<short>(r, c-1) - v2)*second_deriv_scale; |
||||||
|
float dyy = (img.at<short>(r+1, c) + img.at<short>(r-1, c) - v2)*second_deriv_scale; |
||||||
|
float dss = (next.at<short>(r, c) + prev.at<short>(r, c) - v2)*second_deriv_scale; |
||||||
|
float dxy = (img.at<short>(r+1, c+1) - img.at<short>(r+1, c-1) - |
||||||
|
img.at<short>(r-1, c+1) + img.at<short>(r-1, c-1))*cross_deriv_scale; |
||||||
|
float dxs = (next.at<short>(r, c+1) - next.at<short>(r, c-1) - |
||||||
|
prev.at<short>(r, c+1) + prev.at<short>(r, c-1))*cross_deriv_scale; |
||||||
|
float dys = (next.at<short>(r+1, c) - next.at<short>(r-1, c) - |
||||||
|
prev.at<short>(r+1, c) + prev.at<short>(r-1, c))*cross_deriv_scale; |
||||||
|
|
||||||
|
Matx33f H(dxx, dxy, dxs, |
||||||
|
dxy, dyy, dys, |
||||||
|
dxs, dys, dss); |
||||||
|
|
||||||
|
Matx31f X = H.solve<1>(dD, DECOMP_LU); |
||||||
|
|
||||||
|
xi = -X(2, 0); |
||||||
|
xr = -X(1, 0); |
||||||
|
xc = -X(0, 0); |
||||||
|
|
||||||
|
if( std::abs( xi ) < 0.5f && std::abs( xr ) < 0.5f && std::abs( xc ) < 0.5f ) |
||||||
|
break; |
||||||
|
|
||||||
|
c += cvRound( xc ); |
||||||
|
r += cvRound( xr ); |
||||||
|
layer += cvRound( xi ); |
||||||
|
|
||||||
|
if( layer < 1 || layer > nOctaveLayers || |
||||||
|
c < SIFT_IMG_BORDER || c >= img.cols - SIFT_IMG_BORDER || |
||||||
|
r < SIFT_IMG_BORDER || r >= img.rows - SIFT_IMG_BORDER ) |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
/* ensure convergence of interpolation */ |
||||||
|
if( i >= SIFT_MAX_INTERP_STEPS ) |
||||||
|
return false; |
||||||
|
|
||||||
|
{ |
||||||
|
int idx = octv*(nOctaveLayers+2) + layer; |
||||||
|
const Mat& img = dog_pyr[idx]; |
||||||
|
const Mat& prev = dog_pyr[idx-1]; |
||||||
|
const Mat& next = dog_pyr[idx+1]; |
||||||
|
Matx31f dD((img.at<short>(r, c+1) - img.at<short>(r, c-1))*deriv_scale, |
||||||
|
(img.at<short>(r+1, c) - img.at<short>(r-1, c))*deriv_scale, |
||||||
|
(next.at<short>(r, c) - prev.at<short>(r, c))*deriv_scale); |
||||||
|
float t = dD.dot(Matx31f(xc, xr, xi)); |
||||||
|
|
||||||
|
contr = img.at<short>(r, c)*img_scale + t * 0.5f; |
||||||
|
if( std::abs( contr ) * nOctaveLayers < contrastThreshold ) |
||||||
|
return false; |
||||||
|
|
||||||
|
/* principal curvatures are computed using the trace and det of Hessian */ |
||||||
|
float v2 = img.at<short>(r, c)*2; |
||||||
|
float dxx = (img.at<short>(r, c+1) + img.at<short>(r, c-1) - v2)*second_deriv_scale; |
||||||
|
float dyy = (img.at<short>(r+1, c) + img.at<short>(r-1, c) - v2)*second_deriv_scale; |
||||||
|
float dxy = (img.at<short>(r+1, c+1) - img.at<short>(r+1, c-1) - |
||||||
|
img.at<short>(r-1, c+1) + img.at<short>(r-1, c-1)) * cross_deriv_scale; |
||||||
|
float tr = dxx + dyy; |
||||||
|
float det = dxx * dyy - dxy * dxy; |
||||||
|
|
||||||
|
if( det <= 0 || tr*tr*edgeThreshold >= (edgeThreshold + 1)*(edgeThreshold + 1)*det ) |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
kpt.pt.x = (c + xc) * (1 << octv); |
||||||
|
kpt.pt.y = (r + xr) * (1 << octv); |
||||||
|
kpt.octave = octv + (layer << 8) + (cvRound((xi + 0.5)*255) << 16); |
||||||
|
kpt.size = sigma*powf(2.f, (layer + xi) / nOctaveLayers)*(1 << octv)*2; |
||||||
|
|
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Detects features at extrema in DoG scale space. Bad features are discarded
|
||||||
|
// based on contrast and ratio of principal curvatures.
|
||||||
|
void SIFT::findScaleSpaceExtrema( const vector<Mat>& gauss_pyr, const vector<Mat>& dog_pyr, |
||||||
|
vector<KeyPoint>& keypoints ) const |
||||||
|
{ |
||||||
|
int nOctaves = (int)gauss_pyr.size()/(nOctaveLayers + 3); |
||||||
|
int threshold = cvFloor(0.5 * contrastThreshold / nOctaveLayers * 255 * SIFT_FIXPT_SCALE); |
||||||
|
const int n = SIFT_ORI_HIST_BINS; |
||||||
|
float hist[n]; |
||||||
|
KeyPoint kpt; |
||||||
|
|
||||||
|
keypoints.clear(); |
||||||
|
|
||||||
|
for( int o = 0; o < nOctaves; o++ ) |
||||||
|
for( int i = 1; i <= nOctaveLayers; i++ ) |
||||||
|
{ |
||||||
|
int idx = o*(nOctaveLayers+2)+i; |
||||||
|
const Mat& img = dog_pyr[idx]; |
||||||
|
const Mat& prev = dog_pyr[idx-1]; |
||||||
|
const Mat& next = dog_pyr[idx+1]; |
||||||
|
int step = (int)img.step1(); |
||||||
|
int rows = img.rows, cols = img.cols; |
||||||
|
|
||||||
|
for( int r = SIFT_IMG_BORDER; r < rows-SIFT_IMG_BORDER; r++) |
||||||
|
{ |
||||||
|
const short* currptr = img.ptr<short>(r); |
||||||
|
const short* prevptr = prev.ptr<short>(r); |
||||||
|
const short* nextptr = next.ptr<short>(r); |
||||||
|
|
||||||
|
for( int c = SIFT_IMG_BORDER; c < cols-SIFT_IMG_BORDER; c++) |
||||||
|
{ |
||||||
|
int val = currptr[c]; |
||||||
|
|
||||||
|
// find local extrema with pixel accuracy
|
||||||
|
if( std::abs(val) > threshold && |
||||||
|
((val > 0 && val >= currptr[c-1] && val >= currptr[c+1] && |
||||||
|
val >= currptr[c-step-1] && val >= currptr[c-step] && val >= currptr[c-step+1] && |
||||||
|
val >= currptr[c+step-1] && val >= currptr[c+step] && val >= currptr[c+step+1] && |
||||||
|
val >= nextptr[c] && val >= nextptr[c-1] && val >= nextptr[c+1] && |
||||||
|
val >= nextptr[c-step-1] && val >= nextptr[c-step] && val >= nextptr[c-step+1] && |
||||||
|
val >= nextptr[c+step-1] && val >= nextptr[c+step] && val >= nextptr[c+step+1] && |
||||||
|
val >= prevptr[c] && val >= prevptr[c-1] && val >= prevptr[c+1] && |
||||||
|
val >= prevptr[c-step-1] && val >= prevptr[c-step] && val >= prevptr[c-step+1] && |
||||||
|
val >= prevptr[c+step-1] && val >= prevptr[c+step] && val >= prevptr[c+step+1]) || |
||||||
|
(val < 0 && val <= currptr[c-1] && val <= currptr[c+1] && |
||||||
|
val <= currptr[c-step-1] && val <= currptr[c-step] && val <= currptr[c-step+1] && |
||||||
|
val <= currptr[c+step-1] && val <= currptr[c+step] && val <= currptr[c+step+1] && |
||||||
|
val <= nextptr[c] && val <= nextptr[c-1] && val <= nextptr[c+1] && |
||||||
|
val <= nextptr[c-step-1] && val <= nextptr[c-step] && val <= nextptr[c-step+1] && |
||||||
|
val <= nextptr[c+step-1] && val <= nextptr[c+step] && val <= nextptr[c+step+1] && |
||||||
|
val <= prevptr[c] && val <= prevptr[c-1] && val <= prevptr[c+1] && |
||||||
|
val <= prevptr[c-step-1] && val <= prevptr[c-step] && val <= prevptr[c-step+1] && |
||||||
|
val <= prevptr[c+step-1] && val <= prevptr[c+step] && val <= prevptr[c+step+1]))) |
||||||
|
{ |
||||||
|
int r1 = r, c1 = c, layer = i; |
||||||
|
if( !adjustLocalExtrema(dog_pyr, kpt, o, layer, r1, c1, nOctaveLayers, |
||||||
|
contrastThreshold, edgeThreshold, sigma) ) |
||||||
|
continue; |
||||||
|
float scl_octv = kpt.size*0.5f/(1 << o); |
||||||
|
float omax = calcOrientationHist(gauss_pyr[o*(nOctaveLayers+3) + layer], |
||||||
|
Point(c1, r1), |
||||||
|
cvRound(SIFT_ORI_RADIUS * scl_octv), |
||||||
|
SIFT_ORI_SIG_FCTR * scl_octv, |
||||||
|
hist, n); |
||||||
|
float mag_thr = (float)(omax * SIFT_ORI_PEAK_RATIO); |
||||||
|
for( int j = 0; j < n; j++ ) |
||||||
|
{ |
||||||
|
int l = j > 0 ? j - 1 : n - 1; |
||||||
|
int r = j < n-1 ? j + 1 : 0; |
||||||
|
|
||||||
|
if( hist[j] > hist[l] && hist[j] > hist[r] && hist[j] >= mag_thr ) |
||||||
|
{ |
||||||
|
float bin = j + 0.5f * (hist[l]-hist[r]) / (hist[l] - 2*hist[j] + hist[r]); |
||||||
|
bin = bin < 0 ? n + bin : bin >= n ? bin - n : bin; |
||||||
|
kpt.angle = (float)((360.f/n) * bin); |
||||||
|
keypoints.push_back(kpt); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void calcSIFTDescriptor( const Mat& img, Point2f ptf, float ori, float scl, |
||||||
|
int d, int n, float* dst ) |
||||||
|
{ |
||||||
|
Point pt(cvRound(ptf.x), cvRound(ptf.y)); |
||||||
|
float cos_t = cosf(ori*(float)(CV_PI/180)); |
||||||
|
float sin_t = sinf(ori*(float)(CV_PI/180)); |
||||||
|
float bins_per_rad = n / 360.f; |
||||||
|
float exp_scale = -1.f/(d * d * 0.5f); |
||||||
|
float hist_width = SIFT_DESCR_SCL_FCTR * scl; |
||||||
|
int radius = cvRound(hist_width * 1.4142135623730951f * (d + 1) * 0.5f); |
||||||
|
cos_t /= hist_width; |
||||||
|
sin_t /= hist_width; |
||||||
|
|
||||||
|
int i, j, k, len = (radius*2+1)*(radius*2+1), histlen = (d+2)*(d+2)*(n+2); |
||||||
|
int rows = img.rows, cols = img.cols; |
||||||
|
|
||||||
|
AutoBuffer<float> buf(len*6 + histlen); |
||||||
|
float *X = buf, *Y = X + len, *Mag = Y, *Ori = Mag + len, *W = Ori + len; |
||||||
|
float *RBin = W + len, *CBin = RBin + len, *hist = CBin + len; |
||||||
|
|
||||||
|
for( i = 0; i < d+2; i++ ) |
||||||
|
{ |
||||||
|
for( j = 0; j < d+2; j++ ) |
||||||
|
for( k = 0; k < n+2; k++ ) |
||||||
|
hist[(i*(d+2) + j)*(n+2) + k] = 0.; |
||||||
|
} |
||||||
|
|
||||||
|
for( i = -radius, k = 0; i <= radius; i++ ) |
||||||
|
for( j = -radius; j <= radius; j++ ) |
||||||
|
{ |
||||||
|
/*
|
||||||
|
Calculate sample's histogram array coords rotated relative to ori. |
||||||
|
Subtract 0.5 so samples that fall e.g. in the center of row 1 (i.e. |
||||||
|
r_rot = 1.5) have full weight placed in row 1 after interpolation. |
||||||
|
*/ |
||||||
|
float c_rot = j * cos_t - i * sin_t; |
||||||
|
float r_rot = j * sin_t + i * cos_t; |
||||||
|
float rbin = r_rot + d/2 - 0.5f; |
||||||
|
float cbin = c_rot + d/2 - 0.5f; |
||||||
|
int r = pt.y + i, c = pt.x + j; |
||||||
|
|
||||||
|
if( rbin > -1 && rbin < d && cbin > -1 && cbin < d && |
||||||
|
r > 0 && r < rows - 1 && c > 0 && c < cols - 1 ) |
||||||
|
{ |
||||||
|
float dx = img.at<short>(r, c+1) - img.at<short>(r, c-1); |
||||||
|
float dy = img.at<short>(r-1, c) - img.at<short>(r+1, c); |
||||||
|
X[k] = dx; Y[k] = dy; RBin[k] = rbin; CBin[k] = cbin; |
||||||
|
W[k] = (c_rot * c_rot + r_rot * r_rot)*exp_scale; |
||||||
|
k++; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
len = k; |
||||||
|
fastAtan2(Y, X, Ori, len, true); |
||||||
|
magnitude(X, Y, Mag, len); |
||||||
|
exp(W, W, len); |
||||||
|
|
||||||
|
for( k = 0; k < len; k++ ) |
||||||
|
{ |
||||||
|
float rbin = RBin[k], cbin = CBin[k]; |
||||||
|
float obin = (Ori[k] - ori)*bins_per_rad; |
||||||
|
float mag = Mag[k]*W[k]; |
||||||
|
|
||||||
|
int r0 = cvFloor( rbin ); |
||||||
|
int c0 = cvFloor( cbin ); |
||||||
|
int o0 = cvFloor( obin ); |
||||||
|
rbin -= r0; |
||||||
|
cbin -= c0; |
||||||
|
obin -= o0; |
||||||
|
|
||||||
|
if( o0 < 0 ) |
||||||
|
o0 += n; |
||||||
|
if( o0 >= n ) |
||||||
|
o0 -= n; |
||||||
|
|
||||||
|
// histogram update using tri-linear interpolation
|
||||||
|
float v_r1 = mag*rbin, v_r0 = mag - v_r1; |
||||||
|
float v_rc11 = v_r1*cbin, v_rc10 = v_r1 - v_rc11; |
||||||
|
float v_rc01 = v_r0*cbin, v_rc00 = v_r0 - v_rc01; |
||||||
|
float v_rco111 = v_rc11*obin, v_rco110 = v_rc11 - v_rco111; |
||||||
|
float v_rco101 = v_rc10*obin, v_rco100 = v_rc10 - v_rco101; |
||||||
|
float v_rco011 = v_rc01*obin, v_rco010 = v_rc01 - v_rco011; |
||||||
|
float v_rco001 = v_rc00*obin, v_rco000 = v_rc00 - v_rco001; |
||||||
|
|
||||||
|
int idx = ((r0+1)*(d+2) + c0+1)*(n+2) + o0; |
||||||
|
hist[idx] += v_rco000; |
||||||
|
hist[idx+1] += v_rco001; |
||||||
|
hist[idx+(n+2)] += v_rco010; |
||||||
|
hist[idx+(n+3)] += v_rco011; |
||||||
|
hist[idx+(d+2)*(n+2)] += v_rco100; |
||||||
|
hist[idx+(d+2)*(n+2)+1] += v_rco101; |
||||||
|
hist[idx+(d+3)*(n+2)] += v_rco110; |
||||||
|
hist[idx+(d+3)*(n+2)+1] += v_rco111; |
||||||
|
} |
||||||
|
|
||||||
|
// finalize histogram, since the orientation histograms are circular
|
||||||
|
for( i = 0; i < d; i++ ) |
||||||
|
for( j = 0; j < d; j++ ) |
||||||
|
{ |
||||||
|
int idx = ((i+1)*(d+2) + (j+1))*(n+2); |
||||||
|
hist[idx] += hist[idx+n]; |
||||||
|
hist[idx+1] += hist[idx+n+1]; |
||||||
|
for( k = 0; k < n; k++ ) |
||||||
|
dst[(i*d + j)*n + k] = hist[idx+k]; |
||||||
|
} |
||||||
|
// copy histogram to the descriptor,
|
||||||
|
// apply hysteresis thresholding
|
||||||
|
// and scale the result, so that it can be easily converted
|
||||||
|
// to byte array
|
||||||
|
float nrm2 = 0; |
||||||
|
len = d*d*n; |
||||||
|
for( k = 0; k < len; k++ ) |
||||||
|
nrm2 += dst[k]*dst[k]; |
||||||
|
float thr = std::sqrt(nrm2)*SIFT_DESCR_MAG_THR; |
||||||
|
for( i = 0, nrm2 = 0; i < k; i++ ) |
||||||
|
{ |
||||||
|
float val = std::min(dst[i], thr); |
||||||
|
dst[i] = val; |
||||||
|
nrm2 += val*val; |
||||||
|
} |
||||||
|
nrm2 = SIFT_INT_DESCR_FCTR/std::max(std::sqrt(nrm2), FLT_EPSILON); |
||||||
|
for( k = 0; k < len; k++ ) |
||||||
|
{ |
||||||
|
dst[k] = saturate_cast<uchar>(dst[k]*nrm2); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
static void calcDescriptors(const vector<Mat>& gpyr, const vector<KeyPoint>& keypoints, |
||||||
|
Mat& descriptors, int nOctaveLayers ) |
||||||
|
{ |
||||||
|
int d = SIFT_DESCR_WIDTH, n = SIFT_DESCR_HIST_BINS; |
||||||
|
|
||||||
|
for( size_t i = 0; i < keypoints.size(); i++ ) |
||||||
|
{ |
||||||
|
KeyPoint kpt = keypoints[i]; |
||||||
|
int octv=kpt.octave & 255, layer=(kpt.octave >> 8) & 255; |
||||||
|
float scale = 1.f/(1 << octv); |
||||||
|
float size=kpt.size*scale; |
||||||
|
Point2f ptf(kpt.pt.x*scale, kpt.pt.y*scale); |
||||||
|
const Mat& img = gpyr[octv*(nOctaveLayers + 3) + layer]; |
||||||
|
|
||||||
|
calcSIFTDescriptor(img, ptf, kpt.angle, size*0.5f, d, n, descriptors.ptr<float>(i)); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
SIFT::SIFT( int _nfeatures, int _nOctaveLayers, |
||||||
|
double _contrastThreshold, double _edgeThreshold, double _sigma ) |
||||||
|
: nfeatures(_nfeatures), nOctaveLayers(_nOctaveLayers), |
||||||
|
contrastThreshold(_contrastThreshold), edgeThreshold(_edgeThreshold), sigma(_sigma) |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
int SIFT::descriptorSize() const |
||||||
|
{ |
||||||
|
return SIFT_DESCR_WIDTH*SIFT_DESCR_WIDTH*SIFT_DESCR_HIST_BINS; |
||||||
|
} |
||||||
|
|
||||||
|
int SIFT::descriptorType() const |
||||||
|
{ |
||||||
|
return CV_32F; |
||||||
|
} |
||||||
|
|
||||||
|
static Algorithm* createSIFT() |
||||||
|
{ |
||||||
|
return new SIFT; |
||||||
|
} |
||||||
|
static AlgorithmInfo sift_info("Feature2D.SIFT", createSIFT); |
||||||
|
|
||||||
|
AlgorithmInfo* SIFT::info() const |
||||||
|
{ |
||||||
|
static volatile bool initialized = false; |
||||||
|
if( !initialized ) |
||||||
|
{ |
||||||
|
sift_info.addParam(this, "nFeatures", nfeatures); |
||||||
|
sift_info.addParam(this, "nOctaveLayers", nOctaveLayers); |
||||||
|
sift_info.addParam(this, "contrastThreshold", contrastThreshold); |
||||||
|
sift_info.addParam(this, "edgeThreshold", edgeThreshold); |
||||||
|
sift_info.addParam(this, "sigma", sigma); |
||||||
|
|
||||||
|
initialized = true; |
||||||
|
} |
||||||
|
return &sift_info; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
void SIFT::operator()(InputArray _image, InputArray _mask, |
||||||
|
vector<KeyPoint>& keypoints) const |
||||||
|
{ |
||||||
|
(*this)(_image, _mask, keypoints, noArray()); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
void SIFT::operator()(InputArray _image, InputArray _mask, |
||||||
|
vector<KeyPoint>& keypoints, |
||||||
|
OutputArray _descriptors, |
||||||
|
bool useProvidedKeypoints) const |
||||||
|
{ |
||||||
|
Mat image = _image.getMat(), mask = _mask.getMat(); |
||||||
|
|
||||||
|
if( image.empty() || image.depth() != CV_8U ) |
||||||
|
CV_Error( CV_StsBadArg, "image is empty or has incorrect depth (!=CV_8U)" ); |
||||||
|
|
||||||
|
if( !mask.empty() && mask.type() != CV_8UC1 ) |
||||||
|
CV_Error( CV_StsBadArg, "mask has incorrect type (!=CV_8UC1)" ); |
||||||
|
|
||||||
|
Mat base = createInitialImage(image, false, sigma); |
||||||
|
vector<Mat> gpyr, dogpyr; |
||||||
|
int nOctaves = cvRound(log( (double)std::min( base.cols, base.rows ) ) / log(2.) - 2); |
||||||
|
|
||||||
|
//double t, tf = getTickFrequency();
|
||||||
|
//t = (double)getTickCount();
|
||||||
|
buildGaussianPyramid(base, gpyr, nOctaves); |
||||||
|
buildDoGPyramid(gpyr, dogpyr); |
||||||
|
|
||||||
|
//t = (double)getTickCount() - t;
|
||||||
|
//printf("pyramid construction time: %g\n", t*1000./tf);
|
||||||
|
|
||||||
|
if( !useProvidedKeypoints ) |
||||||
|
{ |
||||||
|
//t = (double)getTickCount();
|
||||||
|
findScaleSpaceExtrema(gpyr, dogpyr, keypoints); |
||||||
|
KeyPointsFilter::removeDuplicated( keypoints ); |
||||||
|
|
||||||
|
if( !mask.empty() ) |
||||||
|
KeyPointsFilter::runByPixelsMask( keypoints, mask ); |
||||||
|
|
||||||
|
if( nfeatures > 0 ) |
||||||
|
KeyPointsFilter::retainBest(keypoints, nfeatures); |
||||||
|
//t = (double)getTickCount() - t;
|
||||||
|
//printf("keypoint detection time: %g\n", t*1000./tf);
|
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
// filter keypoints by mask
|
||||||
|
//KeyPointsFilter::runByPixelsMask( keypoints, mask );
|
||||||
|
} |
||||||
|
|
||||||
|
if( _descriptors.needed() ) |
||||||
|
{ |
||||||
|
//t = (double)getTickCount();
|
||||||
|
int dsize = descriptorSize(); |
||||||
|
_descriptors.create((int)keypoints.size(), dsize, CV_32F); |
||||||
|
Mat descriptors = _descriptors.getMat(); |
||||||
|
|
||||||
|
calcDescriptors(gpyr, keypoints, descriptors, nOctaveLayers); |
||||||
|
//t = (double)getTickCount() - t;
|
||||||
|
//printf("descriptor extraction time: %g\n", t*1000./tf);
|
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void SIFT::detectImpl( const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask) const |
||||||
|
{ |
||||||
|
(*this)(image, mask, keypoints, noArray()); |
||||||
|
}
|
||||||
|
|
||||||
|
void SIFT::computeImpl( const Mat& image, vector<KeyPoint>& keypoints, Mat& descriptors) const |
||||||
|
{ |
||||||
|
(*this)(image, Mat(), keypoints, descriptors, true); |
||||||
|
} |
||||||
|
|
||||||
|
} |
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,3 @@ |
|||||||
|
#include "test_precomp.hpp" |
||||||
|
|
||||||
|
CV_TEST_MAIN("cv") |
@ -0,0 +1 @@ |
|||||||
|
#include "test_precomp.hpp" |
@ -0,0 +1,10 @@ |
|||||||
|
#ifndef __OPENCV_TEST_PRECOMP_HPP__ |
||||||
|
#define __OPENCV_TEST_PRECOMP_HPP__ |
||||||
|
|
||||||
|
#include "opencv2/ts/ts.hpp" |
||||||
|
#include "opencv2/imgproc/imgproc.hpp" |
||||||
|
#include "opencv2/highgui/highgui.hpp" |
||||||
|
#include "opencv2/nonfree/nonfree.hpp" |
||||||
|
#include <iostream> |
||||||
|
|
||||||
|
#endif |
@ -0,0 +1,2 @@ |
|||||||
|
set(the_description "Computational Photography") |
||||||
|
ocv_define_module(photo opencv_imgproc) |
@ -0,0 +1,33 @@ |
|||||||
|
Inpainting |
||||||
|
========== |
||||||
|
|
||||||
|
.. highlight:: cpp |
||||||
|
|
||||||
|
inpaint |
||||||
|
----------- |
||||||
|
Restores the selected region in an image using the region neighborhood. |
||||||
|
|
||||||
|
.. ocv:function:: void inpaint( InputArray src, InputArray inpaintMask, OutputArray dst, double inpaintRadius, int flags ) |
||||||
|
|
||||||
|
.. ocv:pyfunction:: cv2.inpaint(src, inpaintMask, inpaintRange, flags[, dst]) -> dst |
||||||
|
|
||||||
|
.. ocv:cfunction:: void cvInpaint( const CvArr* src, const CvArr* mask, CvArr* dst, double inpaintRadius, int flags) |
||||||
|
.. ocv:pyoldfunction:: cv.Inpaint(src, mask, dst, inpaintRadius, flags) -> None |
||||||
|
|
||||||
|
:param src: Input 8-bit 1-channel or 3-channel image. |
||||||
|
|
||||||
|
:param inpaintMask: Inpainting mask, 8-bit 1-channel image. Non-zero pixels indicate the area that needs to be inpainted. |
||||||
|
|
||||||
|
:param dst: Output image with the same size and type as ``src`` . |
||||||
|
|
||||||
|
:param inpaintRadius: Radius of a circlular neighborhood of each point inpainted that is considered by the algorithm. |
||||||
|
|
||||||
|
:param flags: Inpainting method that could be one of the following: |
||||||
|
|
||||||
|
* **INPAINT_NS** Navier-Stokes based method. |
||||||
|
|
||||||
|
* **INPAINT_TELEA** Method by Alexandru Telea [Telea04]_. |
||||||
|
|
||||||
|
The function reconstructs the selected image area from the pixel near the area boundary. The function may be used to remove dust and scratches from a scanned photo, or to remove undesirable objects from still images or video. See |
||||||
|
http://en.wikipedia.org/wiki/Inpainting |
||||||
|
for more details. |
@ -0,0 +1,10 @@ |
|||||||
|
******************************** |
||||||
|
photo. Computational Photography |
||||||
|
******************************** |
||||||
|
|
||||||
|
.. highlight:: cpp |
||||||
|
|
||||||
|
.. toctree:: |
||||||
|
:maxdepth: 2 |
||||||
|
|
||||||
|
inpainting |
@ -0,0 +1,72 @@ |
|||||||
|
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||||
|
//
|
||||||
|
// By downloading, copying, installing or using the software you agree to this license.
|
||||||
|
// If you do not agree to this license, do not download, install,
|
||||||
|
// copy or use the software.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// License Agreement
|
||||||
|
// For Open Source Computer Vision Library
|
||||||
|
//
|
||||||
|
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||||
|
// Copyright (C) 2008-2012, Willow Garage Inc., all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
// are permitted provided that the following conditions are met:
|
||||||
|
//
|
||||||
|
// * Redistribution's of source code must retain the above copyright notice,
|
||||||
|
// this list of conditions and the following disclaimer.
|
||||||
|
//
|
||||||
|
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||||
|
// this list of conditions and the following disclaimer in the documentation
|
||||||
|
// and/or other materials provided with the distribution.
|
||||||
|
//
|
||||||
|
// * The name of the copyright holders may not be used to endorse or promote products
|
||||||
|
// derived from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// This software is provided by the copyright holders and contributors "as is" and
|
||||||
|
// any express or implied warranties, including, but not limited to, the implied
|
||||||
|
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||||
|
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||||
|
// indirect, incidental, special, exemplary, or consequential damages
|
||||||
|
// (including, but not limited to, procurement of substitute goods or services;
|
||||||
|
// loss of use, data, or profits; or business interruption) however caused
|
||||||
|
// and on any theory of liability, whether in contract, strict liability,
|
||||||
|
// or tort (including negligence or otherwise) arising in any way out of
|
||||||
|
// the use of this software, even if advised of the possibility of such damage.
|
||||||
|
//
|
||||||
|
//M*/
|
||||||
|
|
||||||
|
#ifndef __OPENCV_PHOTO_HPP__ |
||||||
|
#define __OPENCV_PHOTO_HPP__ |
||||||
|
|
||||||
|
#include "opencv2/core/core.hpp" |
||||||
|
#include "opencv2/imgproc/imgproc.hpp" |
||||||
|
|
||||||
|
#ifdef __cplusplus |
||||||
|
|
||||||
|
/*! \namespace cv
|
||||||
|
Namespace where all the C++ OpenCV functionality resides |
||||||
|
*/ |
||||||
|
namespace cv |
||||||
|
{ |
||||||
|
|
||||||
|
//! the inpainting algorithm
|
||||||
|
enum
|
||||||
|
{ |
||||||
|
INPAINT_NS=CV_INPAINT_NS, // Navier-Stokes algorithm
|
||||||
|
INPAINT_TELEA=CV_INPAINT_TELEA // A. Telea algorithm
|
||||||
|
}; |
||||||
|
|
||||||
|
//! restores the damaged image areas using one of the available intpainting algorithms
|
||||||
|
CV_EXPORTS_W void inpaint( InputArray src, InputArray inpaintMask, |
||||||
|
OutputArray dst, double inpaintRange, int flags ); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
#endif |
||||||
|
|
||||||
|
#endif |
@ -0,0 +1,3 @@ |
|||||||
|
#include "perf_precomp.hpp" |
||||||
|
|
||||||
|
CV_PERF_TEST_MAIN(photo) |
@ -0,0 +1 @@ |
|||||||
|
#include "perf_precomp.hpp" |
@ -0,0 +1,12 @@ |
|||||||
|
#ifndef __OPENCV_PERF_PRECOMP_HPP__ |
||||||
|
#define __OPENCV_PERF_PRECOMP_HPP__ |
||||||
|
|
||||||
|
#include "opencv2/ts/ts.hpp" |
||||||
|
#include "opencv2/photo/photo.hpp" |
||||||
|
#include "opencv2/highgui/highgui.hpp" |
||||||
|
|
||||||
|
#if GTEST_CREATE_SHARED_LIBRARY |
||||||
|
#error no modules except ts should have GTEST_CREATE_SHARED_LIBRARY defined |
||||||
|
#endif |
||||||
|
|
||||||
|
#endif |
@ -0,0 +1,44 @@ |
|||||||
|
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||||
|
//
|
||||||
|
// By downloading, copying, installing or using the software you agree to this license.
|
||||||
|
// If you do not agree to this license, do not download, install,
|
||||||
|
// copy or use the software.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Intel License Agreement
|
||||||
|
// For Open Source Computer Vision Library
|
||||||
|
//
|
||||||
|
// Copyright (C) 2000, Intel Corporation, all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
// are permitted provided that the following conditions are met:
|
||||||
|
//
|
||||||
|
// * Redistribution's of source code must retain the above copyright notice,
|
||||||
|
// this list of conditions and the following disclaimer.
|
||||||
|
//
|
||||||
|
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||||
|
// this list of conditions and the following disclaimer in the documentation
|
||||||
|
// and/or other materials provided with the distribution.
|
||||||
|
//
|
||||||
|
// * The name of Intel Corporation may not be used to endorse or promote products
|
||||||
|
// derived from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// This software is provided by the copyright holders and contributors "as is" and
|
||||||
|
// any express or implied warranties, including, but not limited to, the implied
|
||||||
|
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||||
|
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||||
|
// indirect, incidental, special, exemplary, or consequential damages
|
||||||
|
// (including, but not limited to, procurement of substitute goods or services;
|
||||||
|
// loss of use, data, or profits; or business interruption) however caused
|
||||||
|
// and on any theory of liability, whether in contract, strict liability,
|
||||||
|
// or tort (including negligence or otherwise) arising in any way out of
|
||||||
|
// the use of this software, even if advised of the possibility of such damage.
|
||||||
|
//
|
||||||
|
//M*/
|
||||||
|
|
||||||
|
#include "precomp.hpp" |
||||||
|
|
||||||
|
/* End of file. */ |
@ -0,0 +1,56 @@ |
|||||||
|
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||||
|
//
|
||||||
|
// By downloading, copying, installing or using the software you agree to this license.
|
||||||
|
// If you do not agree to this license, do not download, install,
|
||||||
|
// copy or use the software.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// License Agreement
|
||||||
|
// For Open Source Computer Vision Library
|
||||||
|
//
|
||||||
|
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||||
|
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
// are permitted provided that the following conditions are met:
|
||||||
|
//
|
||||||
|
// * Redistribution's of source code must retain the above copyright notice,
|
||||||
|
// this list of conditions and the following disclaimer.
|
||||||
|
//
|
||||||
|
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||||
|
// this list of conditions and the following disclaimer in the documentation
|
||||||
|
// and/or other materials provided with the distribution.
|
||||||
|
//
|
||||||
|
// * The name of the copyright holders may not be used to endorse or promote products
|
||||||
|
// derived from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// This software is provided by the copyright holders and contributors "as is" and
|
||||||
|
// any express or implied warranties, including, but not limited to, the implied
|
||||||
|
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||||
|
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||||
|
// indirect, incidental, special, exemplary, or consequential damages
|
||||||
|
// (including, but not limited to, procurement of substitute goods or services;
|
||||||
|
// loss of use, data, or profits; or business interruption) however caused
|
||||||
|
// and on any theory of liability, whether in contract, strict liability,
|
||||||
|
// or tort (including negligence or otherwise) arising in any way out of
|
||||||
|
// the use of this software, even if advised of the possibility of such damage.
|
||||||
|
//
|
||||||
|
//M*/
|
||||||
|
|
||||||
|
#ifndef __OPENCV_PRECOMP_H__ |
||||||
|
#define __OPENCV_PRECOMP_H__ |
||||||
|
|
||||||
|
#if _MSC_VER >= 1200 |
||||||
|
#pragma warning( disable: 4251 4512 4710 4711 4514 4996 ) |
||||||
|
#endif |
||||||
|
|
||||||
|
#ifdef HAVE_CVCONFIG_H |
||||||
|
#include "cvconfig.h" |
||||||
|
#endif |
||||||
|
|
||||||
|
#include "opencv2/photo/photo.hpp" |
||||||
|
|
||||||
|
#endif |
@ -0,0 +1,3 @@ |
|||||||
|
#include "test_precomp.hpp" |
||||||
|
|
||||||
|
CV_TEST_MAIN("cv") |
@ -0,0 +1 @@ |
|||||||
|
#include "test_precomp.hpp" |
@ -0,0 +1,9 @@ |
|||||||
|
#ifndef __OPENCV_TEST_PRECOMP_HPP__ |
||||||
|
#define __OPENCV_TEST_PRECOMP_HPP__ |
||||||
|
|
||||||
|
#include "opencv2/ts/ts.hpp" |
||||||
|
#include "opencv2/photo/photo.hpp" |
||||||
|
#include "opencv2/highgui/highgui.hpp" |
||||||
|
#include <iostream> |
||||||
|
|
||||||
|
#endif |
Loading…
Reference in new issue