Img to raw #13261
-
Hello I am PiterGR this is my firt write a discussion. I just want to see what can be done using MicroPython I am trying to take photos with esp32 cam and then send them to an esp32 and using a st7789 tft screen 1.3" 240x240 . I know that in the st7789py library the blit_buffer method needs a buffer in raw RGB565 format, something like that. Thanks https://gist.github.com/duryding/26a55ee46142d4801a5495b3c88e2859 and https://github.com/shariltumin/esp32-cam-micropython-2022/tree/main. I hope you can guide me |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
These are the settings you can make after Setting = {
'pixformat':5, # 1:RGB565, 2:YUV422, 3:YUV420, 4:GRAYSCALE, 5:COMPRESSED,
# 6:RGB888, 7:RAW, 8:RGB444, 9:RGB555
'framesize':11, # 1:96x96, 2:160x120, 3:176x144, 4:240x176, 5:240x240
# 6:320x240, 7:400x296, 8:480x320, 9:640x480, 10:800x600
# 11:1024x768, 12:1280x720, 13:1280x1024, 14:1600x1200
# 15:1920x1080, 16:720x1280, 17:864x1536, 18:2048x1536
'quality':11, # [0,63] lower number means higher quality
'contrast':0, # [-2,2] higher number higher contrast
'saturation':0, # [-2,2] higher number higher saturation. -2 grayscale
'brightness':0, # [-2,2] higher number higher brightness. 2 brightest
'speffect':0, # 0:,no effect 1:negative, 2:black and white, 3:reddish,
# 4:greenish, 5:blue, 6:retro
'whitebalance':0, # 0:default, 1:sunny, 2:cloudy, 3:office, 4:home
'aelevels':0, # [-2,2] AE Level: Automatic exposure
'aecvalue':0, # [0,1200] AEC Value: Automatic exposure control
'agcgain':0, # [0,30] AGC Gain: Automatic Gain Control
} In particular, you can try: camera.pixformat(1) # set format to RGB565
camera.framesize(5) # set framesize to 240x240 or camera.pixformat(4) # set format to GRAYSCALE
camera.framesize(5) # set framesize to 240x240 The default values are: camera.pixformat(5) # set format to JPG-COMPRESSED
camera.framesize(10) # set framesize to 800x600 You can play around with I got good results writing bytes from camptured image directly to ST7735. Part of my test code (the main loop): def display():
w,h=160-1,80-1 # screen image size
s0=160*20*2 # start at img[160*20*2] i.e 20 row down
sx=160*100*2 # end at img[160*100*2] i.e 100-20=80 rows
loc=tft._setwindowloc
take=camera.capture
put=tft._writedata
while True:
img=take()
loc((0,0),(w,h)) # top left, bottom right
put(img[s0:sx]) # send portion of img to TFT screen I haven't tried with the ST7789, but if you can get "_setwindowloc" and "_writedata" or equivalent to work on the ST7789, then the rest is easy. Best of luck. Merry Christmas and Happy New Year 2024. |
Beta Was this translation helpful? Give feedback.
-
Hi, With these code: camera.init()
camera.pixformat(1) # set format to RGB565
camera.framesize(5) # set framesize to 240x240
buf = camera.capture() You will get an RGB565 formatted image in buf which you can simply write to ST7789 WITHOUT using any conversion program such as utils/img2rgb565.py because the data in buf is already in RGB565 format. Don't worry about my s0 and sx, they are there because I need to trim the image to fit my small display. In your case they will be Please try with a simple program first;
I hope this will work for you. |
Beta Was this translation helpful? Give feedback.
-
Hi, Thanks for testing. Yes, the firmware has some bugs. The method I wrote about was for pre-2022 firmwares. I had released a new version here. Please give it a try. The sample scripts are for ST7735 only. Hopefully it will work better this time. |
Beta Was this translation helpful? Give feedback.
Hi,
Thanks for testing. Yes, the firmware has some bugs. The method I wrote about was for pre-2022 firmwares. I had released a new version here.
Please give it a try. The sample scripts are for ST7735 only. Hopefully it will work better this time.