|
1 | | -# test simple blob detector |
2 | | -# TODO: the keypoint distance assertion below is intermittently wrong across |
3 | | -# platforms, and on Julia 1.11 + Windows `OpenCV.detect` itself hits a |
4 | | -# stack-overflow in the artifact's `julia_to_cpp` stride fallback. Disable the |
5 | | -# whole block until both issues are addressed. |
6 | | -# |
7 | | -# img_gray = OpenCV.imread(joinpath(test_dir, "shared", "pic1.png"), OpenCV.IMREAD_GRAYSCALE) |
8 | | -# |
9 | | -# detector = OpenCV.SimpleBlobDetector_create() |
10 | | -# |
11 | | -# # Compare centers of keypoints and se how many of them match, |
12 | | -# kps = OpenCV.detect(detector, img_gray) |
13 | | -# |
14 | | -# kps_expect = [OpenCV.Point{Float32}(174.9114f0, 227.75146f0),OpenCV.Point{Float32}(106.925545f0, 179.5765f0)] |
15 | | -# for kp in kps |
16 | | -# closest_match = 100000 |
17 | | -# for kpe in kps_expect |
18 | | -# dx = kpe.x - kp.pt.x |
19 | | -# dy = kpe.y - kp.pt.y |
20 | | -# if sqrt(dx*dx+dy*dy) < closest_match |
21 | | -# closest_match = sqrt(dx*dx+dy*dy) |
22 | | -# end |
23 | | -# end |
24 | | -# |
25 | | -# @test closest_match < 10 |
26 | | -# end |
| 1 | +@testset "features2d" begin |
| 2 | + img_gray = OpenCV.imread(joinpath(test_dir, "shared", "pic1.png"), OpenCV.IMREAD_GRAYSCALE) |
| 3 | + |
| 4 | + @testset "ORB detect+compute+match" begin |
| 5 | + orb = OpenCV.ORB_create() |
| 6 | + kps = OpenCV.detect(orb, img_gray) |
| 7 | + @test length(kps) > 0 |
| 8 | + kps2, desc = OpenCV.compute(orb, img_gray, kps) |
| 9 | + @test length(kps2) == length(kps) |
| 10 | + @test size(desc, 1) == length(kps) |
| 11 | + @test size(desc, 2) == OpenCV.descriptorSize(orb) |
| 12 | + |
| 13 | + bf = OpenCV.BFMatcher_create(OpenCV.NORM_HAMMING, true) |
| 14 | + matches = OpenCV.match(bf, desc, desc) |
| 15 | + @test length(matches) == length(kps) |
| 16 | + end |
| 17 | + |
| 18 | + @testset "SimpleBlobDetector" begin |
| 19 | + detector = OpenCV.SimpleBlobDetector_create() |
| 20 | + kps = OpenCV.detect(detector, img_gray) |
| 21 | + @test length(kps) > 0 |
| 22 | + end |
| 23 | +end |
0 commit comments