Explication de routine-02-cpufreq_scaling CPU mise à l'échelle de fréquence

# CPU频率缩放示例。
#
# 此示例显示如何使用cpufreq模块动态更改CPU频率。
import sensor, image, time, cpufreq

sensor.reset()                          # 复位并初始化感光元件
sensor.set_pixformat(sensor.GRAYSCALE)  # 设置图像色彩格式为RGB565(或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 ""