急问:改变图像格式,为什么下面这样改不回来了呢?
-
执行会报错 OSError: Image format is not supported! 是图像格式还是在VGA 格式,没有回到QQVGA吗?
import sensor, image, time,pyb def find_max(blobs): #寻找最大色块函数定义 max_pixels=0 #通过像素比较 for blob in blobs: #blob[0,1,2,3,4]=x,y,w,h,pixels (int) if blob[4]>max_pixels: max_blob=blob max_pixels=blob[4] return max_blob sensor.reset() sensor.set_pixformat(sensor.RGB565) sensor.set_framesize(sensor.QVGA) sensor.skip_frames(time = 2000) clock = time.clock() yellow= (44, 99, -47, 19, 28, 92) while(True): clock.tick() img = sensor.snapshot() blobs = img.find_blobs([yellow],area_threshold=50, pixels_threshold=50,margin = 1) if blobs: max_blob=find_max(blobs) print(max_blob[5],max_blob[6],max_blob.rotation()) img.draw_rectangle(max_blob.rect(),color = (255,0,0)) img.draw_cross(max_blob.cx(),max_blob.cy()) sensor.set_framesize(sensor.VGA) img = sensor.snapshot() img.save("example4.jpg") pyb.delay(500) sensor.set_framesize(sensor.QQVGA) print("11111") pyb.delay(500) sensor.set_framesize(sensor.QQVGA) print("22222") pyb.delay(500)
-
重新设置之后,sensor.skip_frames(time = 2000)