Example: 50-OpenMV-Boards/50-STM32-Boards/50-Board-Control/cpufreq_scaling.py

# 本作品采用MIT许可证授权。
# 版权所有 (c) 2013-2023 OpenMV LLC。保留所有权利。
# https://github.com/openmv/openmv/blob/master/LICENSE
#
# CPU频率缩放示例。
#
# 此示例展示了如何使用cpufreq模块动态更改CPU频率。
import sensor
import image
import time
import cpufreq

sensor.reset()  # 重置并初始化传感器。
sensor.set_pixformat(sensor.GRAYSCALE)  # 将像素格式设置为RGB565 (or GRAYSCALE)
sensor.set_framesize(sensor.QVGA)  # 将帧大小设置为QVGA (320x240)
clock = time.clock()  # 创建一个时钟对象来跟踪FPS。


def test_image_processing():
    for i in range(0, 50):
        clock.tick()  # 更新FPS时钟。
        img = sensor.snapshot()  # 拍照并返回图像。
        img.find_edges(image.EDGE_CANNY, threshold=(50, 80))


print("\nFrequency Scaling Test...")
for f in cpufreq.get_supported_frequencies():
    print("Testing CPU Freq: %dMHz..." % (f))
    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())
    )

results matching ""

    No results matching ""