mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Add in a demo for embossing.
This commit is contained in:
parent
60881b534c
commit
63eec63e79
27
usr/examples/04-Image-Filters/kernel_filters.py
Normal file
27
usr/examples/04-Image-Filters/kernel_filters.py
Normal file
@ -0,0 +1,27 @@
|
||||
# Kernel Filtering Example
|
||||
#
|
||||
# This example shows off how to use a generic kernel filter.
|
||||
|
||||
import sensor, image, time
|
||||
|
||||
sensor.reset() # Initialize the camera sensor.
|
||||
sensor.set_pixformat(sensor.GRAYSCALE) # or sensor.RGB565
|
||||
sensor.set_framesize(sensor.QVGA) # or sensor.QQVGA (or others)
|
||||
sensor.skip_frames(time = 2000) # Let new settings take affect.
|
||||
clock = time.clock() # Tracks FPS.
|
||||
|
||||
kernel_size = 1 # 3x3==1, 5x5==2, 7x7==3, etc.
|
||||
|
||||
kernel = [-2, -1, 0, \
|
||||
-1, 1, 1, \
|
||||
0, 1, 2]
|
||||
|
||||
while(True):
|
||||
clock.tick() # Track elapsed milliseconds between snapshots().
|
||||
img = sensor.snapshot() # Take a picture and return the image.
|
||||
|
||||
# Run the kernel on every pixel of the image.
|
||||
img.morph(kernel_size, kernel)
|
||||
|
||||
print(clock.fps()) # Note: Your OpenMV Cam runs about half as fast while
|
||||
# connected to your computer. The FPS should increase once disconnected.
|
||||
Loading…
Reference in New Issue
Block a user