summaryrefslogtreecommitdiffstats
path: root/virtual-programs
diff options
context:
space:
mode:
authorOmar Rizwan <omar@omar.website>2023-05-26 03:49:26 +0000
committerOmar Rizwan <omar@omar.website>2023-05-26 03:49:26 +0000
commitf472f8a7a57caef18b282f14bfb08f810ac78775 (patch)
tree5241b504efcb3ea178127a9ad88cf3ee16014d79 /virtual-programs
parentImplement bidirectional peering & receive statements (diff)
downloadfolk-f472f8a7a57caef18b282f14bfb08f810ac78775.tar.gz
folk-f472f8a7a57caef18b282f14bfb08f810ac78775.zip
WIP: Start implementing AprilTag detector. defineFolkImages shm
Diffstat (limited to 'virtual-programs')
-rw-r--r--virtual-programs/camera.folk41
-rw-r--r--virtual-programs/tags-and-calibration.folk5
2 files changed, 25 insertions, 21 deletions
diff --git a/virtual-programs/camera.folk b/virtual-programs/camera.folk
index 40950eb9..4075162c 100644
--- a/virtual-programs/camera.folk
+++ b/virtual-programs/camera.folk
@@ -1,33 +1,32 @@
if {$::isLaptop} return
+namespace eval ::Camera {
+ variable WIDTH 1280
+ variable HEIGHT 720
+}
+
On process {
source pi/Camera.tcl
# FIXME: do these in outer scope
Camera::init 1280 720
puts "Camera tid: [getTid]"
- set grayFrames [list]
- while true {
- # Hack: we free old images. Really this should be done on
- # the main thread when it's actually done with them.
- if {[llength $grayFrames] > 10} {
- Camera::freeImage [lindex $grayFrames 0]
- set grayFrames [lreplace $grayFrames 0 0]
- }
- set cameraTime [time { set grayFrame [Camera::grayFrame] }]
- lappend grayFrames $grayFrame
+}
- Commit camera {
- Claim the camera time is $cameraTime
- Claim the camera frame is $grayFrame
+On process {
+ Wish $::nodename receives statements like [list /someone/ claims the camera frame is /frame/]
+
+ source pi/AprilTags.tcl
+ AprilTags::init
+
+ When the camera frame is /frame/ {
+ set aprilTime [time { set tags [AprilTags::detect $frame] }]
+ Commit {
+ Claim the AprilTag time is $aprilTime
+ foreach tag $tags {
+ Claim tag [dict get $tag id] has center [dict get $tag center] size [dict get $tag size]
+ Claim tag [dict get $tag id] has corners [dict get $tag corners]
+ }
}
- Step
}
}
-
-# AprilTags::init
- # foreach tag $tags {
- # Claim tag [dict get $tag id] has center [dict get $tag center] size [dict get $tag size]
- # Claim tag [dict get $tag id] has corners [dict get $tag corners]
- # }
-
diff --git a/virtual-programs/tags-and-calibration.folk b/virtual-programs/tags-and-calibration.folk
index d6c4fad7..36086099 100644
--- a/virtual-programs/tags-and-calibration.folk
+++ b/virtual-programs/tags-and-calibration.folk
@@ -2,6 +2,11 @@ Wish $this has filename "tags-and-calibration.folk"
if {$::isLaptop} { return }
+namespace eval ::Camera {
+ variable WIDTH 1280
+ variable HEIGHT 720
+}
+
package require math::linearalgebra
namespace import ::math::linearalgebra::add \
::math::linearalgebra::sub \