mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Update CPU frequency scaling example.
This commit is contained in:
parent
6babf84a1b
commit
6f597a107c
24
scripts/examples/02-Board-Control/cpufreq_scaling.py
Normal file
24
scripts/examples/02-Board-Control/cpufreq_scaling.py
Normal file
@ -0,0 +1,24 @@
|
||||
# CPU frequency scaling example.
|
||||
#
|
||||
# This example shows how to use the cpufreq module to change the CPU frequency on the fly.
|
||||
import sensor, image, time, cpufreq
|
||||
|
||||
sensor.reset() # Reset and initialize the sensor.
|
||||
sensor.set_pixformat(sensor.GRAYSCALE) # Set pixel format to RGB565 (or GRAYSCALE)
|
||||
sensor.set_framesize(sensor.QQVGA) # Set frame size to QVGA (320x240)
|
||||
sensor.skip_frames(time = 2000) # Wait for settings take effect.
|
||||
clock = time.clock() # Create a clock object to track the FPS.
|
||||
|
||||
def test_image_processing():
|
||||
for i in range(0, 50):
|
||||
clock.tick() # Update the FPS clock.
|
||||
img = sensor.snapshot() # Take a picture and return the image.
|
||||
img.find_edges(image.EDGE_CANNY, threshold=(50, 80))
|
||||
|
||||
print("\nFrequency Scaling Test...")
|
||||
for f in cpufreq.get_supported_frequencies():
|
||||
cpufreq.set_frequency(f)
|
||||
clock.reset()
|
||||
test_image_processing()
|
||||
freqs = cpufreq.get_current_frequencies()
|
||||
print("CPU Freq:%dMHz HCLK:%dMhz PCLK1:%dMhz PCLK2:%dMhz FPS:%.2f" %(freqs[0], freqs[1], freqs[2], freqs[3], clock.fps()))
|
||||
@ -1,18 +0,0 @@
|
||||
# Overclocking Example
|
||||
#
|
||||
# This example shows how to overclock your OMV2 cam to 216MHz. The camera will
|
||||
# stay overclocked until the next hard reset, if you need to keep this frequency
|
||||
# call the set_frequency function from your main script.
|
||||
#
|
||||
# WARNING: Overclocking to 216MHz should be safe, however Use at your own risk!
|
||||
|
||||
import cpufreq
|
||||
|
||||
# Print current CPU frequency
|
||||
print(cpufreq.get_frequency())
|
||||
|
||||
# Set frequency valid values are (120, 144, 168, 192, 216)
|
||||
cpufreq.set_frequency(cpufreq.CPUFREQ_216MHZ)
|
||||
|
||||
# Print current CPU frequency
|
||||
print(cpufreq.get_frequency())
|
||||
Loading…
Reference in New Issue
Block a user