Skip to content

Commit

Permalink
Merge pull request #89 from yakir12/yg/add-tagStandard41h12
Browse files Browse the repository at this point in the history
Add support for the `tagStandard41h12` family
  • Loading branch information
Affie authored May 23, 2024
2 parents 3392cba + df01f70 commit 8213ab8
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/helpers.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@enum TagFamilies tag36h11 tag25h9 tag16h5
@enum TagFamilies tag36h11 tag25h9 tag16h5 tagStandard41h12 #tagStandard52h13 #tagCircle49h12

"""
$(TYPEDEF)
Expand Down Expand Up @@ -115,6 +115,12 @@ function AprilTagDetector(tagfamily::TagFamilies = tag36h11)
tf = tag25h9_create()
elseif tagfamily == tag16h5
tf = tag16h5_create()
elseif tagfamily == tagStandard41h12
tf = tagStandard41h12_create()
# elseif tagfamily == tagStandard52h13
# tf = tagStandard52h13_create()
# elseif tagfamily == tagCircle49h12
# tf = tagCircle49h12_create()
end

#add family to detector
Expand Down Expand Up @@ -313,6 +319,12 @@ function getAprilTagImage(tagIndex::Int, tagfamily::TagFamilies = tag36h11; bla
tf = tag25h9_create()
elseif tagfamily == tag16h5
tf = tag16h5_create()
elseif tagfamily == tagStandard41h12
tf = tagStandard41h12_create()
# elseif tagfamily == tagStandard52h13
# tf = tagStandard52h13_create()
# elseif tagfamily == tagCircle49h12
# tf = tagCircle49h12_create()
end

tagptr = AprilTags.apriltag_to_image(tf, Int32(tagIndex))
Expand Down
26 changes: 26 additions & 0 deletions src/wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,32 @@ function tag16h5_destroy(tf)
ccall((:tag16h5_destroy, libapriltag), Nothing, (Ptr{apriltag_family_t},), tf)
end

function tagStandard41h12_create()
ccall((:tagStandard41h12_create, libapriltag), Ptr{apriltag_family_t}, ())
end

function tagStandard41h12_destroy(tf)
ccall((:tagStandard41h12_destroy, libapriltag), Nothing, (Ptr{apriltag_family_t},), tf)
end

# # this family segfaults for `apriltag_detector_add_family(td, tf)
# function tagStandard52h13_create()
# ccall((:tagStandard52h13_create, libapriltag), Ptr{apriltag_family_t}, ())
# end
#
# function tagStandard52h13_destroy(tf)
# ccall((:tagStandard52h13_destroy, libapriltag), Nothing, (Ptr{apriltag_family_t},), tf)
# end

# # circular tags are problematic because they require a mask of white pixels around the circle
# function tagCircle49h12_create()
# ccall((:tagCircle49h12_create, libapriltag), Ptr{apriltag_family_t}, ())
# end
#
# function tagCircle49h12_destroy(tf)
# ccall((:tagCircle49h12_destroy, libapriltag), Nothing, (Ptr{apriltag_family_t},), tf)
# end

"""
apriltag_detector_create()
Create a AprilTag Detector object with all fields set to default value.
Expand Down
17 changes: 17 additions & 0 deletions test/basictests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@ using Test
detector2 = AprilTagDetector(AprilTags.tag36h11)
freeDetector!(detector2)

detector2 = AprilTagDetector(AprilTags.tagStandard41h12)
freeDetector!(detector2)

# detector2 = AprilTagDetector(AprilTags.tagStandard52h13)
# freeDetector!(detector2)

# detector2 = AprilTagDetector(AprilTags.tag36h10)
# freeDetector!(detector2)

Expand Down Expand Up @@ -203,6 +209,17 @@ using Test
1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0]
@test reftag25h9_0 == getAprilTagImage(0, AprilTags.tag25h9)

reftagStandard41h12_0 = Gray{N0f8}[1.0 1.0 0.0 1.0 1.0 1.0 1.0 0.0 0.0;
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0;
1.0 0.0 1.0 1.0 1.0 1.0 1.0 0.0 0.0;
0.0 0.0 1.0 1.0 1.0 1.0 1.0 0.0 1.0;
0.0 0.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0;
0.0 0.0 1.0 0.0 1.0 0.0 1.0 0.0 1.0;
1.0 0.0 1.0 1.0 1.0 1.0 1.0 0.0 0.0;
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0;
1.0 1.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0]
@test reftagStandard41h12_0 == getAprilTagImage(0, AprilTags.tagStandard41h12, blackborder=false)

# TODO test, just placeholder for now
detector = AprilTagDetector()
detector.quad_decimate = 1.0 #NOTE see line 84
Expand Down

0 comments on commit 8213ab8

Please sign in to comment.