From a264fc7e178493e3d4b47a6ea094934aebee36e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Cuervo?= Date: Sun, 18 Dec 2022 15:00:10 -0500 Subject: Add camera-slice --- virtual-programs/camera-slice.folk | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 virtual-programs/camera-slice.folk (limited to 'virtual-programs') diff --git a/virtual-programs/camera-slice.folk b/virtual-programs/camera-slice.folk new file mode 100644 index 00000000..857ac0ec --- /dev/null +++ b/virtual-programs/camera-slice.folk @@ -0,0 +1,9 @@ +Wish $this has filename "camera-slice.folk" +Wish $this has camera image +When $this has camera image /im/ { + When $this has region /r/ { + Wish display runs [list Display::image {*}[lindex $r 0 0] $im] + } +} + +Wish $this is outlined white -- cgit v1.2.3 From 2048253027aca674ad6cf5f5420513fa978f69a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Cuervo?= Date: Mon, 19 Dec 2022 13:56:39 -0500 Subject: add im --- virtual-programs/camera-slice.folk | 11 +++++++-- virtual-programs/im.folk | 46 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 virtual-programs/im.folk (limited to 'virtual-programs') diff --git a/virtual-programs/camera-slice.folk b/virtual-programs/camera-slice.folk index 857ac0ec..3fb4e98d 100644 --- a/virtual-programs/camera-slice.folk +++ b/virtual-programs/camera-slice.folk @@ -1,9 +1,16 @@ Wish $this has filename "camera-slice.folk" Wish $this has camera image +Wish $this is outlined white + +# Wish program code labelled + When $this has camera image /im/ { When $this has region /r/ { - Wish display runs [list Display::image {*}[lindex $r 0 0] $im] + set coords [lmap n [lindex $r 0 0] {expr $n * 1}] + Wish display runs [list Display::image {*}$coords $im] + Wish $this is labelled "$coords $im" + # filter $im } } -Wish $this is outlined white + diff --git a/virtual-programs/im.folk b/virtual-programs/im.folk new file mode 100644 index 00000000..20370a78 --- /dev/null +++ b/virtual-programs/im.folk @@ -0,0 +1,46 @@ +Wish $this has filename "im.folk" + +Wish $this is outlined green +When $this has region /r/ { + Wish $this is labelled [regionToBbox $r]; # minX minY maxX maxY + lassign [regionToBbox $r] minX minY maxX maxY + Wish $this is labelled "width: [expr $maxX - $minX]" +} + +set cc [c create] +defineImageType $cc + +$cc include +$cc include +$cc proc bw {image_t im} image_t { + image_t ret; + ret.width = im.width; + ret.height = im.height; + ret.components = 3; + ret.bytesPerRow = ret.width * ret.components; + ret.data = calloc(ret.bytesPerRow, ret.height); + int b = ret.bytesPerRow * ret.height * 0.2; + uint8_t L = 0xBB; + + memset(ret.data, L, b); + + for (uint32_t y = 0; y < im.height; ++y) { + for (uint32_t x = 0; x < im.width; ++x) { + ret.data[y * ret.bytesPerRow + x * ret.components] = x; // R + ret.data[y * ret.bytesPerRow + x * ret.components + 1] = y; // G + ret.data[y * ret.bytesPerRow + x * ret.components + 2] = im.width; // B + } + } + + return ret; +} + +$cc compile + +Wish $this has camera image + +When $this has camera image /im/ { + When $this has region /r/ { + Wish display runs [list Display::image {*}[lindex $r 0 0] [bw $im]] + } +} \ No newline at end of file -- cgit v1.2.3 From 7beb92d49d5e7206a9c48443526480f889c93519 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Cuervo?= Date: Mon, 19 Dec 2022 16:02:35 -0500 Subject: Add 96 - 98 & update im.folk --- virtual-programs/im.folk | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) (limited to 'virtual-programs') diff --git a/virtual-programs/im.folk b/virtual-programs/im.folk index 20370a78..95e4252f 100644 --- a/virtual-programs/im.folk +++ b/virtual-programs/im.folk @@ -1,11 +1,5 @@ Wish $this has filename "im.folk" - Wish $this is outlined green -When $this has region /r/ { - Wish $this is labelled [regionToBbox $r]; # minX minY maxX maxY - lassign [regionToBbox $r] minX minY maxX maxY - Wish $this is labelled "width: [expr $maxX - $minX]" -} set cc [c create] defineImageType $cc @@ -19,28 +13,28 @@ $cc proc bw {image_t im} image_t { ret.components = 3; ret.bytesPerRow = ret.width * ret.components; ret.data = calloc(ret.bytesPerRow, ret.height); - int b = ret.bytesPerRow * ret.height * 0.2; - uint8_t L = 0xBB; - - memset(ret.data, L, b); for (uint32_t y = 0; y < im.height; ++y) { + int R = 0; int G = 1; int B = 2; for (uint32_t x = 0; x < im.width; ++x) { - ret.data[y * ret.bytesPerRow + x * ret.components] = x; // R - ret.data[y * ret.bytesPerRow + x * ret.components + 1] = y; // G - ret.data[y * ret.bytesPerRow + x * ret.components + 2] = im.width; // B + int i = y * ret.bytesPerRow + x * ret.components; + int j = y * im.bytesPerRow + x * im.components; + ret.data[i + 0] = im.data[j + R]; + ret.data[i + 1] = im.data[j + G]; + ret.data[i + 2] = im.data[j + B]; } } return ret; } - +$cc proc freeImage {image_t im} void { free(im.data); } $cc compile Wish $this has camera image - When $this has camera image /im/ { When $this has region /r/ { - Wish display runs [list Display::image {*}[lindex $r 0 0] [bw $im]] + set bwim [bw $im] + Wish display runs [list Display::image {*}[lindex $r 0 0] $bwim] + On unmatch [list freeImage $bwim] } } \ No newline at end of file -- cgit v1.2.3