diff options
| author | Omar Rizwan <omar@omar.website> | 2024-04-29 20:44:12 +0000 |
|---|---|---|
| committer | Omar Rizwan <omar@omar.website> | 2024-04-29 20:44:12 +0000 |
| commit | b7491c42f2d802b0a184e173ed21571f79fca0eb (patch) | |
| tree | 51be694166cba9319de90fa56fb795dd04ed0f09 /virtual-programs | |
| parent | More gadget support: use libcamerify for Pi camera + fault to folk0 (diff) | |
| download | folk-b7491c42f2d802b0a184e173ed21571f79fca0eb.tar.gz folk-b7491c42f2d802b0a184e173ed21571f79fca0eb.zip | |
Changes from osnr/checkerboard-calibration for projecting tags
Support global functions in shaders; support uvec4 argtype in shaders;
carve out tag 48600 and up for self-calibration; expose
::tagImageForId and rename ::tagPsForId.
Diffstat (limited to 'virtual-programs')
| -rw-r--r-- | virtual-programs/apriltags.folk | 3 | ||||
| -rw-r--r-- | virtual-programs/print.folk | 21 |
2 files changed, 21 insertions, 3 deletions
diff --git a/virtual-programs/apriltags.folk b/virtual-programs/apriltags.folk index 49b83e5a..499d8ed3 100644 --- a/virtual-programs/apriltags.folk +++ b/virtual-programs/apriltags.folk @@ -108,6 +108,9 @@ When the collected matches for [list /someone/ detects tags /tags/ at /timestamp set timestamp [dict get $match timestamp] foreach tag [dict get $match tags] { set id [dict get $tag id] + # Setting aside this tag space (48600 to 48713) for calibration. + if {$id >= 48600} { continue } + dict set tag timestamp $timestamp if {[dict exists $::tagsCache $id] && diff --git a/virtual-programs/print.folk b/virtual-programs/print.folk index 6197bdd1..082f48cb 100644 --- a/virtual-programs/print.folk +++ b/virtual-programs/print.folk @@ -3,6 +3,7 @@ source "pi/cUtils.tcl" set cc [c create] $cc cflags -I$::env(HOME)/apriltag -Wall -Werror $::env(HOME)/apriltag/libapriltag.a c loadlib $::env(HOME)/apriltag/libapriltag.so +::defineImageType $cc $cc code { #include <apriltag.h> @@ -11,7 +12,21 @@ $cc code { #define emit(...) i += sprintf(&ret[i], __VA_ARGS__) } -$cc proc ::tagImageForId {int id} char* { + +# HACK (osnr): This is used when someone wants to draw an AprilTag +# (often for calibration/cnc preview purposes); I put it here because +# we already have a whole AprilTag family and C compiler object setup +# here. The returned image_t's data needs to be freed by the caller. +$cc proc ::tagImageForId {int id} image_t { + if (tf == NULL) tf = tagStandard52h13_create(); + + image_u8_t* image = apriltag_to_image(tf, id); + image_t ret = (image_t) { .width = image->width, .height = image->height, .components = 1, .bytesPerRow = image->stride, .data = image->buf }; + free(image); // doesn't free data + return ret; +} + +$cc proc ::tagPsForId {int id} char* { if (tf == NULL) tf = tagStandard52h13_create(); image_u8_t* image = apriltag_to_image(tf, id); @@ -51,7 +66,7 @@ proc ::programToPs {id text {format "letter"} {side "front"}} { set fontsize 8; set lineheight [expr $fontsize*1.5] set margin 36 if {$side eq "front"} { - set image [::tagImageForId $id] + set tagPs [::tagPsForId $id] return [subst { %!PS << /PageSize \[$PageWidth $PageHeight\] >> setpagedevice @@ -61,7 +76,7 @@ proc ::programToPs {id text {format "letter"} {side "front"}} { gsave [expr $PageHeight-$tagheight-$margin] [expr -$margin-$tagwidth] translate $tagwidth $tagheight scale - $image + $tagPs grestore /Helvetica-Narrow findfont |
