Inquiry about camera brightness

Hello RT1062 If you turn on ambient light after code operation, the screen brightens, but if you turn on ambient light before code operation, it shows the brightness of the screen similar to the brightness before lighting. Why?

Also, is there a code that brightens up the screen? Leave the code you use below.


import sensor, image, machine, display, time
thresholds = [
    [(100, 100, -128, 127, -128, 127)], # sliver
    [(57, 100, -10, 12, 26, 54)]   # black
]
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 100) 
sensor.set_auto_gain(False)
sensor.set_auto_whitebal(False)
sensor.set_gainceiling(16) 

led_R = machine.Pin('P1', machine.Pin.OUT)
led_G = machine.Pin('P2', machine.Pin.OUT)
led_B = machine.Pin('P3', machine.Pin.OUT)
led_R.off()
led_G.off()
led_B.off()

lcd = display.SPIDisplay() #lcd.init() 구문 대신 사용
pin13 = machine.Pin('P13', machine.Pin.IN, machine.Pin.PULL_DOWN)  # 차종1
pin4 = machine.Pin('P4', machine.Pin.IN, machine.Pin.PULL_DOWN)  # 차종2
pin5 = machine.Pin('P5', machine.Pin.OUT, machine.Pin.PULL_DOWN)  # OK
pin6 = machine.Pin('P6', machine.Pin.OUT, machine.Pin.PULL_DOWN)  # LCD 제어
pin9 = machine.Pin('P9', machine.Pin.OUT, machine.Pin.PULL_DOWN)  # NG

Count_I = 0
first_ok = 0
first_ng = 0
second_ok = 0
second_ng = 0
pin6.value(1) #LCD Back Light On

while(True):
   img=sensor.snapshot()
   lcd.write(img) #lcd.display 대신 사용
   value13=pin13.value()
   value4=pin13.value()
   if value13==1:
    Count_I += 1
    if Count_I <= 9:
        blobs1 = img.find_blobs(thresholds[0], roi=(69,103,7,62), pixels_threshold=10, area_threshold=30, merge=True, margin=100) #부쉬
        blobs2 = img.find_blobs(thresholds[0], roi=(278,100,8,63), pixels_threshold=10, area_threshold=30, merge=True, margin=100)
        blobs3 = img.find_blobs(thresholds[0], roi=(138,16,82,12), pixels_threshold=10, area_threshold=30, merge=True, margin=100)
        blobs4 = img.find_blobs(thresholds[0], roi=(148,228,62,8), pixels_threshold=10, area_threshold=30, merge=True, margin=100)
        if blobs1 or blobs2 or blobs3 or blobs4:  # 어느 하나의 영역에서라도 객체를 찾았을 경우
            for blob in blobs1:
                if blob.area() > 10 and blob.area() < 5000:
                    img.draw_rectangle(blob.rect(), color=(255, 0, 0))
                    img.draw_cross(blob.cx(), blob.cy())
            for blob in blobs2:
                if blob.area() > 10 and blob.area() < 5000:
                    img.draw_rectangle(blob.rect(), color=(255, 0, 0))
                    img.draw_cross(blob.cx(), blob.cy())
            for blob in blobs3:
                if blob.area() > 10 and blob.area() < 5000:
                    img.draw_rectangle(blob.rect(), color=(255, 0, 0))
                    img.draw_cross(blob.cx(), blob.cy())
            for blob in blobs4:
                if blob.area() > 10 and blob.area() < 5000:
                    img.draw_rectangle(blob.rect(), color=(255, 0, 0))
                    img.draw_cross(blob.cx(), blob.cy())
            img.draw_string(0, 0, "OK", color=(0, 255, 0), scale=2, mono_space=False)
            lcd.write(img)
            first_ok += 1
        else:  # 네 영역 모두에서 객체를 찾지 못한 경우
            img.draw_string(0, 0, "NG", color=(255, 0, 0), scale=2, mono_space=False)
            lcd.write(img)
            first_ng += 1                    
    else:
        if first_ok > first_ng:
            led_G.on()
            print('total OK')
            pin5.value(1)
            img.draw_string(0,0,"TOTAL OK",color=(0,255,0),scale=2,mono_space=False)
            lcd.write(img)
        else:
            led_R.on()
            print('total ng')
            pin9.value(1)
            img.draw_string(0,0,"TOTAL NG",color=(255,0,0),scale=2,mono_space=False)
            lcd.write(img)
   elif value4==1:
    Count_I += 1
    if Count_I <= 9:
        blobs1 = img.find_blobs(thresholds[1], roi=(260,169,298,164), pixels_threshold=10, area_threshold=30, merge=True, margin=100) #부쉬
        if blobs1:  # 어느 하나의 영역에서라도 객체를 찾았을 경우
            for blob in blobs1:
                if blob.area() > 10 and blob.area() < 5000:
                    img.draw_rectangle(blob.rect(), color=(255, 0, 0))
                    img.draw_cross(blob.cx(), blob.cy())
            img.draw_string(0, 0, "OK", color=(0, 255, 0), scale=2, mono_space=False)
            lcd.write(img)
            second_ok += 1
        else:  # 두 영역 모두에서 객체를 찾지 못한 경우
            img.draw_string(0, 0, "NG", color=(255,0, 0), scale=2, mono_space=False)
            lcd.write(img)
            second_ng += 1                    
    else:
        if second_ok > second_ng:
            led_G.on()
            print('total OK')
            pin5.value(1)
            img.draw_string(0,0,"TOTAL OK",color=(0,255,0),scale=2,mono_space=False)
            lcd.write(img)
        else:
            led_R.on()
            print('total ng')
            pin9.value(1)
            img.draw_string(0,0,"TOTAL NG",color=(255,0,0),scale=2,mono_space=False)
            lcd.write(img)
   else:
    img.draw_string(0,0," NO INPUT",color=(255,255,255),scale=2,mono_space=False)
    print('no input')
    lcd.write(img)
    pin5.value(0)
    pin9.value(0)
    Count_I = 0
    first_ok = 0
    first_ng = 0
    second_ok = 0
    second_ng = 0
    led_R.off()
    led_G.off()
    led_B.off()

I’m not sure what you mean. The screen brightness is fixed. The camera image brightness is determined by what it’s looking at.