summaryrefslogtreecommitdiffstats
path: root/user-programs/haippi7/laser-camera.folk
blob: 09594fdc76684a9e2bee29e7c301018669182eb3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# Comment out the main virtual-programs/Camera.folk before running this

if {$::isLaptop} return

namespace eval ::Camera {
    variable WIDTH 1280
    variable HEIGHT 720
}

On process {
    source pi/Camera.tcl
    source vendor/blobdetect/blobdetect.tcl
    Camera::init 1280 720

    puts "Camera tid: [getTid]"
    
    while true {
        set cameraTime [time {
            set grayFrame [Camera::grayFrame]
        }]
        set aprilTime [time {
            set threshold 128
            set tags [::BlobDetect::detect $grayFrame $threshold]
        }]
        
        Commit {
            Claim the camera frame is $grayFrame

            Claim the camera time is $cameraTime
            Claim the AprilTag time is $aprilTime

            foreach tag $tags {
                Claim laser blob [dict get $tag id] has center [dict get $tag center] size [dict get $tag size]
            }
        }
        Step
    }
}