mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Add new code example
This commit is contained in:
parent
dbe7bf0591
commit
7d8ae6f9ba
35
scripts/examples/04-Image-Filters/vflip_hmirror_transpose.py
Normal file
35
scripts/examples/04-Image-Filters/vflip_hmirror_transpose.py
Normal file
@ -0,0 +1,35 @@
|
||||
# Vertical Flip - Horizontal Mirror - Transpose
|
||||
#
|
||||
# This example shows off how to vertically flip, horizontally mirror, or
|
||||
# transpose an image. Note that:
|
||||
#
|
||||
# vflip=False, hmirror=False, transpose=False -> 0 degree rotation
|
||||
# vflip=True, hmirror=False, transpose=True -> 90 degree rotation
|
||||
# vflip=True, hmirror=True, transpose=False -> 180 degree rotation
|
||||
# vflip=False, hmirror=True, transpose=True -> 270 degree rotation
|
||||
|
||||
import sensor, image, time, pyb
|
||||
|
||||
sensor.reset()
|
||||
sensor.set_pixformat(sensor.RGB565)
|
||||
sensor.set_framesize(sensor.QVGA)
|
||||
sensor.skip_frames(time = 2000)
|
||||
clock = time.clock()
|
||||
|
||||
mills = pyb.millis()
|
||||
counter = 0
|
||||
|
||||
while(True):
|
||||
clock.tick()
|
||||
|
||||
img = sensor.snapshot()
|
||||
# You can also use "set" or "assign".
|
||||
img.replace(img, vflip=(counter//2)%2,
|
||||
hmirror=(counter//4)%2,
|
||||
transpose=(counter//8)%2)
|
||||
|
||||
if (pyb.millis() > (mills + 1000)):
|
||||
mills = pyb.millis()
|
||||
counter += 1
|
||||
|
||||
print(clock.fps())
|
||||
Loading…
Reference in New Issue
Block a user