summaryrefslogtreecommitdiffstats
path: root/virtual-programs
diff options
context:
space:
mode:
authorOmar Rizwan <omar@omar.website>2023-07-25 18:54:31 +0000
committerNaveen Michaud-Agrawal <naveen.michaudagrawal@gmail.com>2023-09-22 21:58:57 +0000
commit1bcb36bfd6cdd9eec57cc2750a8c6a6d54fa010c (patch)
tree9c1d02d28ca4a4519c6f714db665c62ce94d8be8 /virtual-programs
parentUpdate folk-cwervo host wifi (diff)
downloadfolk-1bcb36bfd6cdd9eec57cc2750a8c6a6d54fa010c.tar.gz
folk-1bcb36bfd6cdd9eec57cc2750a8c6a6d54fa010c.zip
Refactor AprilTags to make an object
Diffstat (limited to 'virtual-programs')
-rw-r--r--virtual-programs/apriltags.folk11
1 files changed, 7 insertions, 4 deletions
diff --git a/virtual-programs/apriltags.folk b/virtual-programs/apriltags.folk
index 8bdd415a..69fcf51c 100644
--- a/virtual-programs/apriltags.folk
+++ b/virtual-programs/apriltags.folk
@@ -1,9 +1,10 @@
if {$::isLaptop} return
+set tagfamily "tagStandard52h13"
+
# Plain detector. Runs on entire camera frame.
set mainDetectorProcess [On process {
source pi/AprilTags.tcl
- AprilTags::init
# TODO: Clean this up. We retract these so that we don't bounce
# statements back to the main Folk process that it sends us.
@@ -18,9 +19,10 @@ set mainDetectorProcess [On process {
Wish $::thisProcess shares statements like \
[list /someone/ claims $::thisProcess has pid /pid/]
+ set detector [AprilTags new $tagfamily]
When the camera frame is /grayFrame/ at /timestamp/ {
set aprilTime [time {
- set tags [AprilTags::detect $grayFrame]
+ set tags [$detector detect $grayFrame]
}]
Claim $::thisProcess detects tags $tags at $timestamp in time $aprilTime
}
@@ -30,7 +32,6 @@ set mainDetectorProcess [On process {
# old camera frame.
On process {
source pi/AprilTags.tcl
- AprilTags::init
# TODO: Clean this up. We retract these so that we don't bounce
# statements back to the main Folk process that it sends us.
@@ -65,6 +66,8 @@ On process {
}
}
+ set detector [AprilTags new $tagfamily]
+
When the camera frame is /grayFrame/ at /timestamp/ & \
/process/ detects tags /prevTags/ at /something/ in time /something/ {
@@ -89,7 +92,7 @@ On process {
set subimage [subimage $grayFrame $x $y [- $x1 $x] [- $y1 $y]]
set aprilTime [+ $aprilTime [baretime {
- foreach tag [AprilTags::detect $subimage] {
+ foreach tag [$detector detect $subimage] {
dict with tag {
set center [vec2 add $center [list $x $y]]
set corners [lmap corner $corners {vec2 add $corner [list $x $y]}]