import sensor, image, time
from machine import UART
from pyb import UART
import json
green_threshold=(37, 100, -26, -8, -18, 32)
red_threshold=(37, 100, 16, 40, -12, 8)
greenin_threshold=(23, 66, -56, -22, -21, 37)
redin_threshold=(18, 85, 23, 52, -17, 55)
#redin_threshold=
#greenin_threshold=
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.set_windowing(150,0,140,140)
sensor.set_vflip(True)
sensor.set_hmirror(True)
#sensor.set_auto_whitebal(False)
sensor.skip_frames(10)
#clock = time.clock()
uart = UART(3, 115200, timeout_char=4000)
sensor.set_auto_gain(False,100)
sensor.set_auto_exposure(False,10)#!!!
#sensor.set_contrast(-3)
#sensor.set_brightness(-3)
while True:
img = sensor.snapshot() # Take a picture and return the image.