Skip to content

Commit 5a24081

Browse files
committed
fix feature type, multiple bugs
1 parent 98195ab commit 5a24081

File tree

4 files changed

+40
-25
lines changed

4 files changed

+40
-25
lines changed

src/brisk.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
"""
2+
```
3+
brisk_params = BRISK([pattern_scale = 1.0])
4+
```
5+
6+
| Argument | Type | Description |
7+
|----------|------|-------------|
8+
| `pattern_scale` | `Float64` | Scaling factor for the sampling window |
9+
"""
110
type BRISK{S, T, O} <: Params
211
threshold::Float64
312
octaves::Int

src/core.jl

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,25 @@
11
abstract Params
22

3+
"""
4+
```
5+
keypoint = Keypoint(y, x)
6+
keypoint = Keypoint(feature)
7+
```
8+
9+
A `Keypoint` may be created by passing the coordinates of the point or from a feature.
10+
"""
11+
typealias Keypoint CartesianIndex{2}
12+
13+
"""
14+
```
15+
keypoints = Keypoints(boolean_img)
16+
keypoints = Keypoints(features)
17+
```
18+
19+
Creates a `Vector{Keypoint}` of the `true` values in a boolean image or from a list of features.
20+
"""
21+
typealias Keypoints Vector{CartesianIndex{2}}
22+
323
"""
424
```
525
feature = Feature(keypoint, orientation = 0.0, scale = 0.0)
@@ -13,10 +33,6 @@ immutable Feature
1333
scale::Float64
1434
end
1535

16-
Feature(k::Keypoint) = Feature(k, 0.0, 0.0)
17-
18-
Feature(k::Keypoint, ori::Float64) = Feature(k, ori, 0.0)
19-
2036
"""
2137
```
2238
features = Features(boolean_img)
@@ -28,29 +44,15 @@ list of keypoints.
2844
"""
2945
typealias Features Vector{Feature}
3046

31-
Features(keypoints::Keypoints) = map(k -> Feature(k), keypoints)
32-
33-
Features(img::AbstractArray) = Features(Keypoints(img))
47+
Feature(k::Keypoint) = Feature(k, 0.0, 0.0)
3448

35-
"""
36-
```
37-
keypoint = Keypoint(y, x)
38-
keypoint = Keypoint(feature)
39-
```
49+
Feature(k::Keypoint, ori::Number) = Feature(k, ori, 0.0)
4050

41-
A `Keypoint` may be created by passing the coordinates of the point or from a feature.
42-
"""
43-
typealias Keypoint CartesianIndex{2}
51+
Features(keypoints::Keypoints) = map(k -> Feature(k), keypoints)
4452

45-
"""
46-
```
47-
keypoints = Keypoints(boolean_img)
48-
keypoints = Keypoints(features)
49-
```
53+
Features(img::AbstractArray) = Features(Keypoints(img))
5054

51-
Creates a `Vector{Keypoint}` of the `true` values in a boolean image or from a list of features.
52-
"""
53-
typealias Keypoints Vector{CartesianIndex{2}}
55+
Keypoint(feature::Feature) = feature.keypoint
5456

5557
function Keypoints(img::AbstractArray)
5658
r, c, _ = findnz(img)
@@ -59,8 +61,6 @@ end
5961

6062
Keypoints(features::Features) = map(f -> f.keypoint, features)
6163

62-
Keypoint(feature::Feature) = feature.keypoint
63-
6464
"""
6565
```
6666
distance = hamming_distance(desc_1, desc_2)

test/brisk.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ facts("BRISK") do
1919

2020
desc_1, ret_features_1 = create_descriptor(img_array_1, features_1, brisk_params)
2121
desc_2, ret_features_2 = create_descriptor(img_array_2, features_2, brisk_params)
22+
2223
matches = match_keypoints(Keypoints(ret_features_1), Keypoints(ret_features_2), desc_1, desc_2, 0.1)
2324
reverse_keypoints_1 = [_reverserotate(m[1], pi / 4, (256, 384)) for m in matches]
2425
@fact all(isapprox(rk[1], m[2][1], atol = 4) && isapprox(rk[2], m[2][2], atol = 4) for (rk, m) in zip(reverse_keypoints_1, matches)) --> true

test/core.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ facts("Core") do
99
keypoints = Keypoints(img)
1010
@fact sort(keypoints) == sort(ids) --> true
1111
@fact Keypoint(1, 2) --> CartesianIndex{2}(1, 2)
12+
13+
features = Features(img)
14+
keypoints = Keypoints(features)
15+
@fact sort(keypoints) == sort(ids) --> true
16+
1217
end
1318

1419
context("Keypoint Matching") do

0 commit comments

Comments
 (0)