Posts

Python 3 +OpenCV + PyQt6 to display usbcam

Image
A simple exercise run on Windows 11/Python 3.13.0 to capture images from usbcam display with GUI using OpenCV and PyQt6. It's tested in Python virtual environment on Windows 11, with OpenCV aand PyQt6 installed . pyqt6_cv2_usbcam.py , actually it's provided by MicroSoft Copilot. import sys import cv2 from PyQt6.QtWidgets import QApplication, QLabel, QWidget, QVBoxLayout from PyQt6.QtGui import QImage, QPixmap from PyQt6.QtCore import QTimer class WebcamViewer(QWidget): def __init__(self): super().__init__() self.initUI() self.cap = cv2.VideoCapture(0) self.timer = QTimer(self) self.timer.timeout.connect(self.update_frame) self.timer.start(20) def initUI(self): self.setWindowTitle('Webcam') self.image_label = QLabel(self) layout = QVBoxLayout() layout.addWidget(self.image_label) self.setLayout(layout) def update_frame(self): ret, frame = self.cap...

download bmp via WiFi and display using OnDiskBitmap, running on ESP32S3/CircuitPython 9.

Image
Previous exercises post " Seeed Studio XIAO ESP32S3 Sense/CircuitPython display on 1.28" 240x240 GC9A01 Round IPS LCD " and " Display bmp with XIAO ESP32S3 Sense/CircuitPython on GC9A01 Round LCD using OnDiskBitmap, adafruit_imageload and adafruit_slideshow ". It's another exercise running on Seeed Studio XIAO ESP32S3 Sense/CircuitPython 9.2.1, to download bmp from Python http server via WiFi, save to local filesystem, and display on 1.28" 240x240 GC9A01 Round IPS LCD using OnDiskBitmap. Actually, it's ESP32S3 version of another previous exercise " Pico 2 W/CircuitPython download bmp via WiFi, and display using OnDiskBitmap ". Connection between XIAO ESP32S3 Sense and GC9A01 Round IPS LCD, refer to previous exercise " Seeed Studio XIAO ESP32S3 Sense/CircuitPython display on 1.28" 240x240 GC9A01 Round IPS LCD ". To run http server on using Python (tested in Windows 11/Python 3): > python -m ...

Display bmp with XIAO ESP32S3 Sense/CircuitPython on GC9A01 Round LCD using OnDiskBitmap, adafruit_imageload and adafruit_slideshow

Image
Previous exercise on " Seeed Studio XIAO ESP32S3 Sense/CircuitPython display on 1.28" 240x240 GC9A01 Round IPS LCD ", it's another exercise to display bmp using OnDiskBitmap, adafruit_imageload and adafruit_slideshow. Actually, it's ported from my previous exercises on Raspberry Pi Pico with 1.54" 240x240 ST7789 SPI IPS: ~  Raspberry Pi Pico 2/CircuitPython 9 display bmp on ST7789 LCD using adafruit_imageload/adafruit_slideshow ~  displayio.OnDiskBitmap on Pico 2 W/CircuitPython 9 Connection, same as in previous exercise . All testing images were generated using "Image Creator in Bing", not real. Converted to 240x240 RGB888/RGB565 using Python . The exercises need libraries gc9a01, adafruit_imageload and adafruit_slideshow. To install the libraries using circup: circup install gc9a01, adafruit_imageload, adafruit_slideshow To know how to install and use circup, read:  https://coxxect.blogspot.com/2024/12/inst...

Seeed Studio XIAO ESP32S3 Sense/CircuitPython display on 1.28" 240x240 GC9A01 Round IPS LCD

Image
This exercise run on  Seeed Studio XIAO ESP32S3 Sense running CircuitPython 9.2.1, to display on  1.28" 240x240 GC9A01 Round IPS LCD . Also exercises to run Turtle graphics on CircuitPython. Libraries (or modules) gc9a01, adafruit_display_text and adafruit_turtle are needed. In old approach, you can download them from  CircuitPython Libraries and copy to CircuitPython device manually. In this video, the libraries were installed using another approach CircUp. To install CircUp, read my previous post " Install and using CircUp (CircuitPython library updater) to install CircuitPython libraries ". If you use old approach to download manually, notice that gc9a01.mpy is in Community Bundle (circuitpython-community-bundle-...), not Adafruit Circuit Bundle (adafruit-circuitpython-bundle-...). Connection: Exercise Code: cpy_XS3_gc9a01_color.py , simple demo exercise with color test. """ Color test on Seeed Studio XIAO...

Install and using CircUp (CircuitPython library updater) to install CircuitPython libraries

Image
CircUp (CircuitPython library updater) is a tool to manage and update libraries (modules) on a CircuitPython device. In old approach, we will download library bundle from CircuitPython Libraries , extract, and fine the libraries to upload to CircuitPython device manually. If any libraries updated, we have to do it again. With CircUp, it install and update libraries automatically.  This utility looks at all the libraries on the device and checks if they are the most recent (compared to the versions found in the most recent version of the Adafruit CircuitPython Bundle and Circuitpython Community Bundle). If the libraries are out of date, the utility helps you update them. It's suggested to install CircUp in virtualenv (Python virtual environment). This video show steps to create virtualenv in Windows 11, install CircUp in virtualenv, and install libraries on CircuitPython device using CircUp. Circup requires Python 3.5 or higher. To create a virtualenv for circup,...

Pico 2 W/CircuitPython download bmp via WiFi, and display using OnDiskBitmap.

Image
Previous Raspberry Pi Pico 2W/CircuitPython 9 exercise display bmp in local filesystem on 1.54" IPS 240x240 with SPI ST7789 driver using displayio.OnDiskBitmap . This exercise using Pico 2 W wireless feature, download bmp via WiFi to local filesystem, then display on ST7789 LCD using OnDiskBitmap. We are going to setup a python http server on Windows 11, then Pico 2 W connect to the same WiFi network ("ssid" here) and request bmp from the http server. The simplest way to setup http server in Python is: python -m http.server Then you can reach the http server at http://[IP address]:8000/ Exercise code: cpy_pico2w_wifi_OnDiskBitmap.py """ Raspberry Pi Pico 2 W/CircuitPython 9 to display bmp on 1.54" 240x240 ST7789 SPI IPS Download bmp from wifi and display on LCD using OnDiskBitmap Connection: ----------- GND GND VCC 3V3 SCL GP18 SDA GP19 RES GP20 DC GP21 CS GP17 BLK GP22 CircuitPython Libraries Bundle for Version 9.x nee...

Set CircuitPython file system Writable, and write/read text file on CircuitPython.

Image
This code simple try to write a text file in CircuitPython file system and read back, tested on  Raspberry Pi Pico 2 W running CircuitPython 9.2.1. cpy_write_and_read_text_file.py """ CircuitPython exercise to write and read text file. Tested on Raspberry Pi Pico 2 W/CircuitPython 9.2.1 """ print("- To write hello.txt -") try: with open("/hello.txt", "w") as fp: fp.write("hello, world! from coXXect") except OSError as err: print(err) print("- To read hello.txt 0") try: with open("/hello.txt", "r") as fp: print(fp.readline()) except OSError as err: print(err) It will raise OSError of Read-only filesystem. Because by default in CircuitPython, filesystem is read-only for running code. cpy_check_vfs_readonly.py , check if the filesystem is readonly or not. """ CircuitPython code to check if Filesystem is Read Only or Writable....