Written by coh at home
[Maixbot] camera & LCD 본문
import sensor, image, time, lcd
lcd.init(freq=15000000)
sensor.reset() # Reset and initialize the sensor. It will
# run automatically, call sensor.run(0) to stop
sensor.set_pixformat(sensor.RGB565) # Set pixel format to RGB565 (or GRAYSCALE)
sensor.set_framesize(sensor.QVGA) # Set frame size to QVGA (320x240)
sensor.skip_frames(time = 2000) # Wait for settings take effect.
clock = time.clock() # Create a clock object to track the FPS.
while(True):
clock.tick() # Update the FPS clock.
img = sensor.snapshot() # Take a picture and return the image.
lcd.display(img) # Display on LCD
print(clock.fps()) # 1초에 몇장 들어오는지!
# to the IDE. The FPS should increase once disconnected.
4~6line
R 5bit, G6bit, B5bit 사용
QVGA (320 x 240) 프레임사이즈 사용
세팅하는데 걸리는 시간을 기다려주기 위해 2초동안 프레임 스킵.
다음은 간단한 lcd, img를 이용한 예제들이다.
import image, lcd, utime
lcd.init()
img = image.Image(size=(320, 240))
img.draw_circle((100,100,200),color=(255,255,0), fill=True)
lcd.display(img)
# 0, 0위치에 300 width 700 height
img.draw_rectangle((0,0,30,70), color=(0,0,255),fill=True)
lcd.display(img)
img.draw_line((0,0,lcd.width(), lcd.height()), thickness=100, color=(255,0,0))
lcd.display(img)
# lcd.draw_string(0,0,"hello world")
이제 어떤 색깔을 detection하는 코드를 작성해보자. LAB space 툴을 이용하여 parameter값을 알아내면 된다.
'Advanced > Maixbot Project' 카테고리의 다른 글
[Maixbot]프로젝트 (0) | 2023.07.12 |
---|---|
[Maixbot]딥러닝 모델 실습 (0) | 2023.07.11 |
[Maixbot]Analog output (0) | 2023.07.10 |
[Maixbot]Analog IO (0) | 2023.07.10 |
[Maixbot]AI concept review with CNN (0) | 2023.07.07 |