notes:circle-detector
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| notes:circle-detector [2024/09/09 21:14] – Create page admin | notes:circle-detector [2024/10/21 23:01] (current) – Add updated dots.folk code and cameraToProjector note admin | ||
|---|---|---|---|
| Line 2: | Line 2: | ||
| > [[https:// | > [[https:// | ||
| + | * TODO: Replace '' | ||
| * TODO: affix relative codepaths below | * TODO: affix relative codepaths below | ||
| * Copy the C++ code paths below onto your Folk machine (make sure your directory names match the paths below) | * Copy the C++ code paths below onto your Folk machine (make sure your directory names match the paths below) | ||
| Line 178: | Line 179: | ||
| # Dot detector using OpenCV | # Dot detector using OpenCV | ||
| + | |||
| set makeDotDetector {{} { | set makeDotDetector {{} { | ||
| set detector DotDetector | set detector DotDetector | ||
| namespace eval $detector { | namespace eval $detector { | ||
| + | |||
| set cc [c create] | set cc [c create] | ||
| - | + | ||
| - | $cc cflags -I$:: | + | $cc cflags -I$:: |
| $cc include < | $cc include < | ||
| $cc include < | $cc include < | ||
| $cc include < | $cc include < | ||
| - | $cc include " | + | $cc include "$:: |
| + | |||
| :: | :: | ||
| $cc import ::Heap::cc folkHeapAlloc as folkHeapAlloc | $cc import ::Heap::cc folkHeapAlloc as folkHeapAlloc | ||
| $cc import ::Heap::cc folkHeapFree as folkHeapFree | $cc import ::Heap::cc folkHeapFree as folkHeapFree | ||
| + | |||
| $cc proc detect {image_t gray} Tcl_Obj* { | $cc proc detect {image_t gray} Tcl_Obj* { | ||
| assert(gray.components == 1); | assert(gray.components == 1); | ||
| cv_image_t im = (cv_image_t) { .width = gray.width, .height = gray.height, | cv_image_t im = (cv_image_t) { .width = gray.width, .height = gray.height, | ||
| + | |||
| int max_count = 100; | int max_count = 100; | ||
| cv_keypoint_t* detections = (cv_keypoint_t*)malloc(sizeof(cv_keypoint_t)*max_count); | cv_keypoint_t* detections = (cv_keypoint_t*)malloc(sizeof(cv_keypoint_t)*max_count); | ||
| + | |||
| int detectionCount = cvSimpleBlobDetector(im, | int detectionCount = cvSimpleBlobDetector(im, | ||
| + | |||
| Tcl_Obj* detectionObjs[detectionCount]; | Tcl_Obj* detectionObjs[detectionCount]; | ||
| for (int i = 0; i < detectionCount; | for (int i = 0; i < detectionCount; | ||
| cv_keypoint_t* det = & | cv_keypoint_t* det = & | ||
| + | |||
| detectionObjs[i] = Tcl_ObjPrintf(" | detectionObjs[i] = Tcl_ObjPrintf(" | ||
| | | ||
| Line 215: | Line 216: | ||
| return result; | return result; | ||
| } | } | ||
| - | + | ||
| - | c loadlib $:: | + | c loadlib $:: |
| $cc compile | $cc compile | ||
| + | |||
| namespace export * | namespace export * | ||
| namespace ensemble create | namespace ensemble create | ||
| + | |||
| } | } | ||
| + | |||
| return $detector | return $detector | ||
| }} | }} | ||
| Line 229: | Line 230: | ||
| # Plain detector. Runs on entire camera frame. | # Plain detector. Runs on entire camera frame. | ||
| set detectorProcess [Start process { | set detectorProcess [Start process { | ||
| + | |||
| set detector [apply $makeDotDetector] | set detector [apply $makeDotDetector] | ||
| + | |||
| Wish $:: | Wish $:: | ||
| - | [list /someone/ claims | + | [list /someone/ claims camera |
| Wish $:: | Wish $:: | ||
| [list /someone/ claims /process/ detects dots /dots/ at /timestamp/ in time /dotTime/] | [list /someone/ claims /process/ detects dots /dots/ at /timestamp/ in time /dotTime/] | ||
| - | + | ||
| - | When the camera frame is /grayFrame/ at /timestamp/ { | + | When camera |
| set dotTime [time { | set dotTime [time { | ||
| set dots [$detector detect $grayFrame] | set dots [$detector detect $grayFrame] | ||
| Line 244: | Line 245: | ||
| } | } | ||
| }] | }] | ||
| - | + | ||
| + | |||
| When /someone/ detects dots /dots/ at /timestamp/ in time /dotTime/ & \ | When /someone/ detects dots /dots/ at /timestamp/ in time /dotTime/ & \ | ||
| /obj/ has region /region/ { | /obj/ has region /region/ { | ||
| + | |||
| set dots [lmap dot $dots { dict create center [lmap d [:: | set dots [lmap dot $dots { dict create center [lmap d [:: | ||
| + | |||
| set contained [list ] | set contained [list ] | ||
| foreach dot $dots { | foreach dot $dots { | ||
notes/circle-detector.1725916491.txt.gz · Last modified: by admin
