logo

使用get_pixel遍历一遍图像的像素点非常慢,有改进方法吗

2024-05-07 17:58
T
apgl
# Untitled - By: 33316 - Tue May 7 2024

import sensor, image, time
from machine import UART   #openart专用machine

sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 2000)

clock = time.clock()
hei   =  (1, 38, 12, -36, -128, 12)

while(True):
    clock.tick()
    img = sensor.snapshot()
    img_ezh_hei = img

    img_ezh_hei.binary([hei])
    for x in range(0,320):
        for y in range(240,0,-1):
            if(img_ezh_hei.get_pixel(x,y)==(0,0,0)):
                a=1
        print(x)