I’m using the QRCode sample, modified slightly, to read a large QR Code. The problem I’m having is how difficult it is to get the exposure right so that the code can be read. Ideally, I want to use a properly tuned auto exposure, because I’m sure that the lighting conditions will change in my lab over the course of a day. The sun hits the windows for part of the day. I tried turning off autoexposure and setting things manually, but it didn’t work the way I thought it should.
Here is my code. You can see in the images that the QR Code is overexposed and the histogram shows it. Using manual exposure settings is only good if the environment is tightly controlled. I need a better autoexposure.
import sensor, image, time sensor.reset() sensor.set_pixformat(sensor.GRAYSCALE) sensor.set_framesize(sensor.VGA) sensor.set_windowing((240, 240)) # look at center 240x240 pixels of the VGA resolution. sensor.skip_frames(time = 2000) sensor.set_auto_gain(False) # must turn this off to prevent image washout... sensor.set_auto_whitebal(False) sensor.set_auto_exposure(True) #sensor.set_brightness(0) # range 0-31 #sensor.set_saturation(0) # range -3 to 3 #sensor.set_gainceiling(2) # 2,4,8,16,32,64,128 #sensor.set_contrast(2) # range -3 to 3 clock = time.clock() while(True): clock.tick() img = sensor.snapshot() for code in img.find_qrcodes(): img.draw_rectangle(code.rect(), color = 127) print(code)