From ab05fb6213a6a8227ba256c289604fd7eadb1459 Mon Sep 17 00:00:00 2001 From: iabdalkader Date: Sun, 2 Mar 2014 01:47:20 +0200 Subject: [PATCH] Update blob detection example --- usr/examples/blob_detection.py | 23 +++++++++++++++++++++++ usr/examples/color_detection.py | 6 ------ 2 files changed, 23 insertions(+), 6 deletions(-) create mode 100644 usr/examples/blob_detection.py delete mode 100644 usr/examples/color_detection.py diff --git a/usr/examples/blob_detection.py b/usr/examples/blob_detection.py new file mode 100644 index 000000000..9b7c64f6c --- /dev/null +++ b/usr/examples/blob_detection.py @@ -0,0 +1,23 @@ +from openmv import sensor, imlib +total_frames = 0 +total_ticks = 0 +while (True): + # take snapshot + image = sensor.snapshot() + t_start = ticks() + + # detect blobs + imlib.threshold(image, (255, 127, 127), 38) + imlib.median(image, 1) + blobs = imlib.count_blobs(image) + + total_ticks = total_ticks + (ticks()-t_start) + total_frames = total_frames + 1 + + # take new snapshot + image = sensor.snapshot() + for r in blobs: + imlib.draw_rectangle(image, r) + + print (total_ticks/total_frames) + print (len(blobs)) diff --git a/usr/examples/color_detection.py b/usr/examples/color_detection.py deleted file mode 100644 index e61f5ecd4..000000000 --- a/usr/examples/color_detection.py +++ /dev/null @@ -1,6 +0,0 @@ -from openmv import sensor, imlib -while (True): - image = sensor.snapshot() - r= imlib.detect_color(image, (340, 50, 50), 10) - imlib.draw_rectangle(image, r) -