我对一张灰度图像使用get_pixel的时候,返回值为什么会出现None
请提供你的代码,以及结果。
注释部分麻烦忽略
# findlines - By: shuncs - 周一 1月 14 2019
import sensor, image, time
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
#320*240
sensor.skip_frames(time = 2000)
enable_lens_corr = True
thresholds = [(100, 255)]
clock = time.clock()
while(True):
clock.tick()
img = sensor.snapshot()
imgtmp = img
imgtmp = imgtmp.to_grayscale()
#print(imgtmp.height(), imgtmp.width())
print(imgtmp.get_pixel(14,318),imgtmp.get_pixel(14,319))
#imgtmp.binary(thresholds)
#pos = []
#for row in range(0, imgtmp.height()):
#for col in range(0, imgtmp.width()-1):
##print(row,col)
#print(row,col,imgtmp.get_pixel(row,col),imgtmp.get_pixel(row,col+1))
#if abs(imgtmp.get_pixel(row,col)-imgtmp.get_pixel(row,col+1)) > 50:
#pos.append(col)
#print(col, "too much")
#break
#pos.clear()output:None None318,319超出范围了。
https://docs.singtown.com/micropython/zh/latest/openmvcam/library/omv.sensor.html#sensor.sensor.set_framesize
明白了,建议在文档更新的时候提一下,get_pixle()函数中x是列,y是行
http://book.openmv.cc/image/basic-operation.html