logo

彩色图转灰度图,图像显示出现莫名错误

2019-07-11 15:31
M
fry6

写程序时需要用到灰度图和彩色图,在初始化时设置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)
4128bbfd-99ee-42b7-a4c6-b87b443b6272.jpg
2019-07-12 20:59
I
网红小智智 星瞳科技

我使用OpenMV3和OpenMV4都没有你的错误。

请升级到最新的固件。

如果不行,联系卖家维修。