写程序时需要用到灰度图和彩色图,在初始化时设置RGB565,在后面需要用到灰度图时,不知道什么原因,串行端口打印的值感觉没啥问题(只是感觉),但是显示的图像出现问题。用示例代码进行测试如下:
import sensor, image, time
sensor.reset() # Reset and initialize the sensor.
sensor.set_pixformat(sensor.RGB565) # Set pixel format to RGB565 (or GRAYSCALE)
sensor.set_framesize(sensor.QVGA) # 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.
while(True):
clock.tick() # Update the FPS clock.
img = sensor.snapshot()
print(img.get_pixel(45,180))
time.sleep(200)
img = img.to_grayscale()
print(img.get_pixel(45,180))
time.sleep(200)