Posts

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

Test "Waveshare 3.5inch Capacitive Touch LCD" on Raspberry Pi Zero 2 W

Image
This video follow Waveshare "3.5inch Capacitive Touch LCD" guide working with Raspberry Pi in Python. To test  Waveshare 3.5inch Capacitive Touch LCD (Embedded with ST7796S driver chip and FT6336U capacitive touch control chip) on Raspberry Pi Zero 2 W/Raspberry Pi OS (32 bit/bookworm) using Python. Connect the LCD wires to Raspberry Pi: Enable SPI and I2C using raspi-config. sudo raspi-config Install libraries: In my test on 32-bit and 64-bit Raspberry Pi OS (bookworm), they were pre-installed, no need to install. sudo apt-get update sudo apt-get install python3-pip sudo apt-get install python3-pil sudo apt-get install python3-numpy sudo apt-get install python3-spidev Download the demo (include libraries) from https://files.waveshare.com/wiki/3.5inch%20Capacitive%20Touch%20LCD/3.5inch_Capacitive_Touch_LCD_Demo_Pi.zip wget https://files.waveshare.com/wiki/3.5inch%20Capacitive%20Touch%20LCD/3.5inch_Capacitive_Touch_LCD_Demo_Pi.zip E...