mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
105 lines
4.4 KiB
Python
105 lines
4.4 KiB
Python
import pyb, sensor, image
|
|
sensor.reset()
|
|
sensor.set_framesize(sensor.QVGA)
|
|
while(True):
|
|
# Test Set Pixel
|
|
sensor.set_pixformat(sensor.GRAYSCALE)
|
|
for i in range(10):
|
|
img = sensor.snapshot()
|
|
for j in range(100):
|
|
x = (pyb.rng() % (2*img.width())) - (img.width()//2)
|
|
y = (pyb.rng() % (2*img.height())) - (img.height()//2)
|
|
img.set_pixel(x, y, 255)
|
|
sensor.set_pixformat(sensor.RGB565)
|
|
for i in range(10):
|
|
img = sensor.snapshot()
|
|
for j in range(100):
|
|
x = (pyb.rng() % (2*img.width())) - (img.width()//2)
|
|
y = (pyb.rng() % (2*img.height())) - (img.height()//2)
|
|
img.set_pixel(x, y, (255, 255, 255))
|
|
# Test Draw Line
|
|
sensor.set_pixformat(sensor.GRAYSCALE)
|
|
for i in range(10):
|
|
img = sensor.snapshot()
|
|
for j in range(100):
|
|
x0 = (pyb.rng() % (2*img.width())) - (img.width()//2)
|
|
y0 = (pyb.rng() % (2*img.height())) - (img.height()//2)
|
|
x1 = (pyb.rng() % (2*img.width())) - (img.width()//2)
|
|
y1 = (pyb.rng() % (2*img.height())) - (img.height()//2)
|
|
img.draw_line([x0, y0, x1, y1])
|
|
sensor.set_pixformat(sensor.RGB565)
|
|
for i in range(10):
|
|
img = sensor.snapshot()
|
|
for j in range(100):
|
|
x0 = (pyb.rng() % (2*img.width())) - (img.width()//2)
|
|
y0 = (pyb.rng() % (2*img.height())) - (img.height()//2)
|
|
x1 = (pyb.rng() % (2*img.width())) - (img.width()//2)
|
|
y1 = (pyb.rng() % (2*img.height())) - (img.height()//2)
|
|
img.draw_line([x0, y0, x1, y1])
|
|
# Test Draw Rectangle
|
|
sensor.set_pixformat(sensor.GRAYSCALE)
|
|
for i in range(10):
|
|
img = sensor.snapshot()
|
|
for j in range(100):
|
|
x = (pyb.rng() % (2*img.width())) - (img.width()//2)
|
|
y = (pyb.rng() % (2*img.height())) - (img.height()//2)
|
|
w = (pyb.rng() % img.width())
|
|
h = (pyb.rng() % img.height())
|
|
img.draw_rectangle([x, y, w, h])
|
|
sensor.set_pixformat(sensor.RGB565)
|
|
for i in range(10):
|
|
img = sensor.snapshot()
|
|
for j in range(100):
|
|
x = (pyb.rng() % (2*img.width())) - (img.width()//2)
|
|
y = (pyb.rng() % (2*img.height())) - (img.height()//2)
|
|
w = (pyb.rng() % img.width())
|
|
h = (pyb.rng() % img.height())
|
|
img.draw_rectangle([x, y, w, h])
|
|
# Test Draw Circle
|
|
sensor.set_pixformat(sensor.GRAYSCALE)
|
|
for i in range(10):
|
|
img = sensor.snapshot()
|
|
for j in range(100):
|
|
x = (pyb.rng() % (2*img.width())) - (img.width()//2)
|
|
y = (pyb.rng() % (2*img.height())) - (img.height()//2)
|
|
r = (pyb.rng() % (img.width() if (img.width() > img.height()) else img.height()))
|
|
img.draw_circle(x, y, r)
|
|
sensor.set_pixformat(sensor.RGB565)
|
|
for i in range(10):
|
|
img = sensor.snapshot()
|
|
for j in range(100):
|
|
x = (pyb.rng() % (2*img.width())) - (img.width()//2)
|
|
y = (pyb.rng() % (2*img.height())) - (img.height()//2)
|
|
r = (pyb.rng() % (img.width() if (img.width() > img.height()) else img.height()))
|
|
img.draw_circle(x, y, r)
|
|
# Test Draw String
|
|
sensor.set_pixformat(sensor.GRAYSCALE)
|
|
for i in range(10):
|
|
img = sensor.snapshot()
|
|
for j in range(100):
|
|
x = (pyb.rng() % (2*img.width())) - (img.width()//2)
|
|
y = (pyb.rng() % (2*img.height())) - (img.height()//2)
|
|
img.draw_string(x, y, "Hello\nWorld!")
|
|
sensor.set_pixformat(sensor.RGB565)
|
|
for i in range(10):
|
|
img = sensor.snapshot()
|
|
for j in range(100):
|
|
x = (pyb.rng() % (2*img.width())) - (img.width()//2)
|
|
y = (pyb.rng() % (2*img.height())) - (img.height()//2)
|
|
img.draw_string(x, y, "Hello\nWorld!")
|
|
# Test Draw Cross
|
|
sensor.set_pixformat(sensor.GRAYSCALE)
|
|
for i in range(10):
|
|
img = sensor.snapshot()
|
|
for j in range(100):
|
|
x = (pyb.rng() % (2*img.width())) - (img.width()//2)
|
|
y = (pyb.rng() % (2*img.height())) - (img.height()//2)
|
|
img.draw_cross(x, y)
|
|
sensor.set_pixformat(sensor.RGB565)
|
|
for i in range(10):
|
|
img = sensor.snapshot()
|
|
for j in range(100):
|
|
x = (pyb.rng() % (2*img.width())) - (img.width()//2)
|
|
y = (pyb.rng() % (2*img.height())) - (img.height()//2)
|
|
img.draw_cross(x, y)
|