diff --git a/usr/examples/blit_image.py b/usr/examples/blit_image.py new file mode 100644 index 000000000..aa074119f --- /dev/null +++ b/usr/examples/blit_image.py @@ -0,0 +1,5 @@ +import sensor, time +sensor.set_pixformat(sensor.GRAYSCALE) +fb = sensor.snapshot() +img = Image("minion.pgm") +fb.blit((0, 0), img) diff --git a/usr/examples/blob_detection.py b/usr/examples/blob_detection.py index 38bb9cfae..211a12729 100644 --- a/usr/examples/blob_detection.py +++ b/usr/examples/blob_detection.py @@ -9,7 +9,7 @@ while (True): # detect blobs image.threshold((255, 127, 127), 40) image.median(3) - blobs = image.count_blobs() + blobs = image.find_blobs() # draw rectangles around detected blobs image = sensor.snapshot() diff --git a/usr/examples/circle.py b/usr/examples/circle.py new file mode 100644 index 000000000..24c8e0f07 --- /dev/null +++ b/usr/examples/circle.py @@ -0,0 +1,8 @@ +import sensor + +# Set sensor to grayscale +sensor.set_pixformat(sensor.GRAYSCALE) +sensor.set_brightness(-2) + +image = sensor.snapshot() +image.draw_circle((50, 50), 10) \ No newline at end of file diff --git a/usr/examples/face_detection.py b/usr/examples/face_detection.py index 2c7db9ab3..2cbc15cf3 100644 --- a/usr/examples/face_detection.py +++ b/usr/examples/face_detection.py @@ -1,19 +1,19 @@ -import sensor, imlib, time +import sensor, time # Set sensor gainceiling -sensor.set_gainceiling(sensor.X8) +sensor.set_gainceiling(16) # Set sensor brightness sensor.set_brightness(-2) # Set sensor to grayscale sensor.set_pixformat(sensor.GRAYSCALE) # Load Haar Cascade -cascade = imlib.load_cascade("0:/frontalface_default.cascade") +cascade = HaarCascade("0:/frontalface_default.cascade") print(cascade) clock = time.clock() while (True): clock.tick() image = sensor.snapshot() - objects = imlib.detect_objects(image, cascade) + objects = image.find_features(cascade) for r in objects: - imlib.draw_rectangle(image, r) + image.draw_rectangle(r) print (clock.fps()) diff --git a/usr/examples/median.py b/usr/examples/median.py new file mode 100644 index 000000000..c332f2c33 --- /dev/null +++ b/usr/examples/median.py @@ -0,0 +1,3 @@ +import sensor, time +sensor.set_pixformat(sensor.GRAYSCALE) +sensor.snapshot().median(size=3) diff --git a/usr/examples/surf_detect_and_draw.py b/usr/examples/surf_detect_and_draw.py index 194bc605c..fe2502e47 100644 --- a/usr/examples/surf_detect_and_draw.py +++ b/usr/examples/surf_detect_and_draw.py @@ -1,11 +1,11 @@ -import sensor, imlib, time -clock = time.clock() +import sensor, time # Set sensor to grayscale sensor.set_pixformat(sensor.GRAYSCALE) +clock = time.clock() while (True): image = sensor.snapshot() - clock.tick() - surf1 = imlib.surf_detector(image, False, 0.0008) + clock.tick() + kp = image.find_keypoints(upright=False, thresh=0.0004, octaves=2) + image.draw_keypoints(kp) print (clock.avg()) - imlib.surf_draw_ipts(image, surf1) \ No newline at end of file diff --git a/usr/examples/surf_detect_and_match.py b/usr/examples/surf_detect_and_match.py index 873887505..fe504f112 100644 --- a/usr/examples/surf_detect_and_match.py +++ b/usr/examples/surf_detect_and_match.py @@ -1,15 +1,19 @@ -import sensor, imlib, time -clock = time.clock() +import sensor, time +# Set sensor gainceiling +sensor.set_gainceiling(16) +# Set sensor brightness +sensor.set_brightness(-2) # Set sensor to grayscale sensor.set_pixformat(sensor.GRAYSCALE) -sensor.set_brightness(-2) + image = sensor.snapshot() -surf1 = imlib.surf_detector(image, False, 0.0004) -imlib.surf_draw_ipts(image, surf1) +kp = image.find_keypoints(upright=False, thresh=0.0004, octaves=2) +image.draw_keypoints(kp) time.sleep(2000) + +clock = time.clock() while (True): image = sensor.snapshot() clock.tick() - surf2 = imlib.surf_detector(image, False, 0.0004) - imlib.surf_match(image, surf1, surf2) + ipts2 = image.find_keypoints_match(kp) print (clock.avg()) \ No newline at end of file diff --git a/usr/examples/write_image.py b/usr/examples/write_image.py new file mode 100644 index 000000000..8e8a389e1 --- /dev/null +++ b/usr/examples/write_image.py @@ -0,0 +1,3 @@ +import sensor, time +sensor.set_pixformat(sensor.GRAYSCALE) +sensor.snapshot().save("0:/test.ppm", subimage=(0, 0, 10,10))