diff --git a/usr/examples/blob_detection.py b/usr/examples/blob_detection.py index 9b7c64f6c..064cd0413 100644 --- a/usr/examples/blob_detection.py +++ b/usr/examples/blob_detection.py @@ -1,23 +1,15 @@ -from openmv import sensor, imlib -total_frames = 0 -total_ticks = 0 +import sensor, imlib, time +clock = time.clock() while (True): # take snapshot image = sensor.snapshot() - t_start = ticks() # detect blobs - imlib.threshold(image, (255, 127, 127), 38) - imlib.median(image, 1) + imlib.threshold(image, (255, 127, 127), 48) + clock.tick() + imlib.median(image, 3) 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)) + break diff --git a/usr/examples/face_detection.py b/usr/examples/face_detection.py index c41c9b670..2c7db9ab3 100644 --- a/usr/examples/face_detection.py +++ b/usr/examples/face_detection.py @@ -1,21 +1,19 @@ -from openmv import sensor, imlib +import sensor, imlib, time # Set sensor gainceiling -sensor.set_gainceiling(sensor.X32) +sensor.set_gainceiling(sensor.X8) +# Set sensor brightness +sensor.set_brightness(-2) # Set sensor to grayscale sensor.set_pixformat(sensor.GRAYSCALE) # Load Haar Cascade -cascade = imlib.load_cascade("0:/face.bin") +cascade = imlib.load_cascade("0:/frontalface_default.cascade") print(cascade) - -total_frames = 0 -total_ticks = 0 +clock = time.clock() while (True): + clock.tick() image = sensor.snapshot() - t_start = ticks() objects = imlib.detect_objects(image, cascade) - total_ticks = total_ticks + (ticks()-t_start) - total_frames = total_frames + 1 for r in objects: imlib.draw_rectangle(image, r) - print (total_ticks/total_frames) + print (clock.fps()) diff --git a/usr/examples/fb_viewer.py b/usr/examples/fb_viewer.py index a0f71f64c..fc4662e50 100644 --- a/usr/examples/fb_viewer.py +++ b/usr/examples/fb_viewer.py @@ -1,4 +1,4 @@ -from openmv import sensor, imlib +import sensor, imlib sensor.set_pixformat(sensor.RGB565) while (True): image = sensor.snapshot() diff --git a/usr/examples/lcd.py b/usr/examples/lcd.py index 8ebd7c4dd..83892db7f 100644 --- a/usr/examples/lcd.py +++ b/usr/examples/lcd.py @@ -3,4 +3,4 @@ lcd.init() lcd.clear(0xFF) while (True): image = sensor.snapshot() - lcd.write_image(image) + lcd.write_image(image) \ No newline at end of file diff --git a/usr/examples/template_matching.py b/usr/examples/template_matching.py index c37c0acb0..9d34c5f57 100644 --- a/usr/examples/template_matching.py +++ b/usr/examples/template_matching.py @@ -1,15 +1,11 @@ -from openmv import sensor, imlib +import sensor, imlib, time sensor.set_pixformat(sensor.GRAYSCALE) -template = imlib.load_template("0:/temp") -total_frames = 0 -total_ticks = 0 -t_start = ticks() +template = imlib.load_template("0:/minion.template") +clock = time.clock() while (True): - image = sensor.snapshot() - t_start = ticks() - obj = imlib.template_match(image, template, 0.7) - total_ticks = total_ticks + (ticks()-t_start) - total_frames = total_frames + 1 - print (total_ticks/total_frames) - if obj: + clock.tick() + image = sensor.snapshot() + obj = imlib.template_match(image, template, 0.7) + if obj: imlib.draw_rectangle(image, obj) + print (clock.fps())