Posts

ILI9488 SPI LCD on Raspberry Pi/Python using Luma.LCD

Image
Luma.LCD  provides a Python3 interface to small LCD displays connected to Raspberry Pi and other Linux-based single-board computers (SBC). It provides a Pillow-compatible drawing canvas, and other functionality. This exercises tested on Raspberry Pi 4/64-bit Raspberry Pi OS (bookworm) using Python3 + Luma.LCD to driver 3.5 inch 480x320 ILI9488 SPI LCD . Connection: Follows the suggested wiring for ILI9488 in Luma.LCD docs . Enable SPI Interface: Make sure SPI is enabled in Raspberry Pi using raspi-config. ( https://luma-lcd.readthedocs.io/en/latest/hardware.html#enabling-the-spi-interface ) sudo raspi-config Exercise Code: luma_ili9488.py , Hello World with color/pwm backlight test. """ 3.5 inch 480x320 TFT with SPI ILI9488 on Raspberry Pi 4B using Python/luma.lcd Hello World with color/pwm backlight test. """ from luma.core.interface.serial import spi from luma.core.render import canvas from luma.lcd.device import ili9488 fr...

Cartoonized images display on 320×480 ST7796 SPI LCD, using Python on Raspberry Pi 4B

Image
Previous post introduced Cartoonize image using OpenCV in Python, run on Windows 11 . This exercises run on Raspberry Pi 4B/64 bit Raspberry Pi OS (bookworm), and modified to display on Waveshare 3.5" 320×480 ST7796 SPI LCD . Connection and setup demo (include ST7796 driver), read  Test "Waveshare 3.5inch Capacitive Touch LCD" on Raspberry Pi Zero 2 W .  OpenCV (cv2) is needed, to install OpenCV in Python virtual environment: Switch to where you want to Python virtual environment located. Create Python virtual environment to include site packages, where envPy_cv2 is the name of my virtual environment: $ python -m venv --system-site-packages envPy_cv2 Activate the virtual environment: $ source envPy_cv2/bin/activate Install OpenCV: $ pip install opencv-python Exit virtual environment after finished: $ deactivate In Thonny, configure interpreter to select the Python executable in the new virtual environment. Exercise code: pyCartoonize....

Cartoonize image using OpenCV in Python

Image
I found a great example code to cartoonize image using OpenCV in Python, let's give it a try! Reference:  Best Ways to Cartoonize an Image Using OpenCV in Python Modified code in my exercise, pyCartoonize.py. """ Cartoonize image using OpenCV in Python I found a great example code to cartoonize image using OpenCV in Python, let's give it a try! reference: https://blog.finxter.com/5-best-ways-to-cartoonize-an-image-using-opencv-in-python/ In the post, 4 method are listed to Cartoonize an Image Using OpenCV in Python. Method 1: Bilateral Filtering and Edge Detection. Produces a smooth, clean cartoon effect. Good for high-resolution images but can be computationally intensive. Method 2: Color Quantization and Edge Enhancement. Delivers a visually distinct cartoon with flat colors and crisp borders. Works best with strongly contrasting images. The setup is slightly complex due to k-means. Method 3:...

Simple USB Cam viewer in Windows 11, using Python + OpenCV

Image
My scenario is I have two USB Cam deviecs: - A Video Capture Adapter, used to convert HDMI output from Raspberry Pi, convert to USB, my PC will recognize it as a USB web cam. - A normal USB web cam. I use them to record Raspberry Pi operation and unit under developed, as show in the video: https://www.youtube.com/watch?v=JVnYG2-OC8w But in Windows, only one Camera can be opened at the same time. So I make a simple Python code to display the web cam view on screen, no any capture/record control. Such that I can record screen with both my Raspberry Pi operation and the web cam view. In the Python code, OpenCV (cv2) is used to handle the cam, so have to install it. In my practice: - Create a Python virtual environment in Windows 11, named envUSBCAM.      Enter the command in Terminal:    > python -m venv envUSBCAM    Activate the virtual environment:   > .\\Scripts\activate - Install OpenCV in the virtual e...

Python on Raspberry Pi to display images on ST7796S SPI LCD

Image
Python exercises run on Raspberry Pi 4/64-bit Raspberry Pi OS (bookworm) to display images on Waveshare 3.5 inch 320x480 Capacitive Touch LCD, with ST7796S driver . For connection and setup (include downloading of demo and drivers), refer to the post  Test "Waveshare 3.5inch Capacitive Touch LCD" on Raspberry Pi Zero 2 W . Exercise Code: LCD_image_show.py , display single image. Convert and rotate 1024x768 jpg image to 320x480, and display on ST7796 SPI LCD. #!/usr/bin/python # -*- coding: UTF-8 -*- #import chardet """ Python exercise run on Raspberry Pi 4: Read image and display on Waveshare 3.5inch Capacitive Touch LCD with ST7796 SPI driver. Connection and setup, read: https://coxxect.blogspot.com/2025/01/test-waveshare-35inch-capacitive-touch.html remark: All test images were generated by X's Grok, not real. """ import st7796 from PIL import Image, ImageOps if __name__=='__main__': disp = st7796.st77...

CircuitPython on my DIY Pico Cam: Raspberry Pi Pico 2 + OV5640 camera sensor

Image
CircuitPython 9.2.4 exercise run on  my DIY Pico Cam: Raspberry Pi Pico 2 + Waveshare OV5640 Camera Board, display on 240x240 ST7789 display/240x240 GC9A01 round display . cpy_pico2_cam.py """ Raspberry Pi Pico 2/CircuitPython 9.2.4 + Waveshare OV5640 Camera Board (adafruit_ov5640) + 1.54" 240x240 ST7789 SPI IPS (adafruit_st7789) or 1.28" 240x240 Round GC9A01 SPI IPS (gc9a01) CircuitPython Libraries Bundle for Version 9.x needed: (https://circuitpython.org/libraries) - adafruit_ov5640 folder - adafruit_st7789.mpy (optional for st7789 display) - gc9a01.mpy (optional for gc9a01 display) or install using circup: circup install adafruit_ov5640, adafruit_st7789, gc9a01 For Installing and using CircUp, read: https://coxxect.blogspot.com/2024/12/install-and-using-circup-circuitpython.html ref of adafruit_ov5640: https://docs.circuitpython.org/projects/ov5640/en/latest/ """ import sys, os import board import busio from displayio import ( ...

my DIY Pico Cam: Raspberry Pi Pico 2 + OV5640 camera sensor

Image
It's my DIY Pico Cam: Raspberry Pi Pico 2 + Waveshare OV5640 Camera Board , display on  240x240 ST7789 display / 240x240 GC9A01 round display . Connection: Exercise: ~  CircuitPython on my DIY Pico Cam: Raspberry Pi Pico 2 + OV5640 camera sensor