Posts

Python + cv2 exercises to resize jpg and save in bmp

Image
Python + cv2 exercises to resize jpg and save in bmp, tested on Raspberry Pi 5/64 bit Raspberry Pi OS (bookworm). py_cv_resize.py , resize jpg and save in bmp, the file name is hard-coded in the program. You can also save the image in other file name/format in cv.imwrite() interface. # Python exercise to resize jpg and save in bmp # tested on Raspberry Pi 5/64 bit Raspberry Pi OS (bookworm) import cv2 as cv target_width = 240 target_height = 240 path = "./images/" file = "05" ext_jpg = ".jpg" ext_bmp = ".bmp" img = cv.imread(path + file + ext_jpg) img = cv.resize(img, (target_width, target_height)) cv.imwrite(path + file + ext_bmp, img) cv.imshow("img", img) cv.waitKey(0) cv.destoryAllWindows() py_cv_batch_resize.py , resize in batch. # Python exercise to batch resize jpg(s) and save in bmp(s) # tested on Raspberry Pi 5/64 bit Raspberry Pi OS (bookworm) import cv2 as cv import glob import os target_width = 240 targ

Seeed Studio XIAO ESP32S3 Sense display on 2.4" TFT 240×320 ST7789V using Adafruit_ST7789 lib in Arduino framework.

Image
Exercise running on  Seeed Studio XIAO ESP32S3 Sense , to display on 2.4" TFT 240×320 ST7789V using Adafruit_ST7789 lib in Arduino framework. Board and library installed: esp32 by Espressif System (arduino-esp32) 3.0.3 Adafruit ST7735 and ST7789 Library 1.10.4 Connection: Code: XiaoS3_ST7789_SPI_240x320_color.ino /************************************************************************** XIAO ESP32S3 Connect display on 2.4" IPS 240x320 SPI (ST7789V) : Color Test Connection: ST7789 XIAO ESP32S3 1 GND GND 2 VCC 3V3 3 SCL GPIO7 (hardware SPI SCK) 4 SDA GPIO9 (hardware SPI MOSI) 5 RST GPIO2 6 DC GPIO3 7 CS GPIO4 8 BL 3V3 **************************************************************************/ #include <Adafruit_GFX.h> // Core graphics library #include <Adafruit_ST7789.h> // Hardware-specific library for ST7789 #include <SPI.h> #define TFT_RST

2.4 inch TFT Module 240×320 ST7789V (GMT024-08-SPI8P VER 1.3)

Image
 2.4 inch TFT Module 240×320 ST7789V, marked "GMT024-08-SPI8P VER 1.3". Pin assignment: 1 GND 2 VCC 3 SCL 4 SDA 5 RST 6 DC 7 CS 8 BL Related exercise: ~  Seeed Studio XIAO ESP32S3 Sense display on 2.4" TFT 240×320 ST7789V using Adafruit_ST7789 lib in Arduino framework .

First try CameraWebServer on Seeed Studio XIAO ESP32S3 Sense + ov5640 Camera (Auto-Focusing), in Arduino framework.

Image
First try CameraWebServer on Seeed Studio XIAO ESP32S3 Sense + ov5640 Camera (Auto-Focusing) , in Arduino framework. Make sure  ESP32 (Arduino-ESP32) is installed to your Arduino IDE , 3.0.2 is installed in this video. Select board of esp32 > XIAO ESP32S3 Open Examples for XIAO_ESP32S3 > ESP32 > Camera > CameraWebServer un-comment the line: #define CAMERA_MODEL_XIAO_ESP32S3 and comment all other CAMERA_MODEL. Edit ssid and password to match with your WiFi network. optionally, you can compare with Seeed Studio XIAO ESP32S3 Sense Schematic . To check the supported camera sensor: Right click on any _PID (OV3660_PID here) in the code, click on Go to Definition. You can add code to check the attached camera sensor at runtime. CameraWebServer.ino #include "esp_camera.h" #include <WiFi.h> // // WARNING!!! PSRAM IC required for UXGA resolution and high JPEG quality // Ensure ESP32 Wrover Module or other board

Seeed Studio XIAO ESP32S3 Sense (with ov2640) & XIAO ov5640 Camera (Auto-Focusing)

Image
Seeed Studio XIAO ESP32S3 Sense (with ov2640) Seeed Studio XIAO ov5640 Camera (Auto-Focusing) Pinout: Related Links: ~  Getting Started with Seeed Studio XIAO ESP32S3 (Sense) ~  Installation of expansion boards and camera sensor ~  DroneBot Workshop for Seeeduino XIAO ESP32S3 Sense Board – A Tiny ESP32 Camera ~  TinyML Case Studies Related post: ~  First try CameraWebServer on Seeed Studio XIAO ESP32S3 Sense + ov5640 Camera (Auto-Focusing), in Arduino framework . ~  Seeed Studio XIAO ESP32S3 Sense display on 2.4" TFT 240×320 ST7789V using Adafruit_ST7789 lib in Arduino framework .

Picamera2+OpenCV+matplotlib Python exercise to display histogram, run on Raspberry Pi

Image
Previous exercise of  Python/OpenCV run on Raspberry Pi to capture images from Camera Module 3 using Picamera2 and display using OpenCV . The exercise plot the histogram using matplotlib. To install OpenCV and matplotlib on Raspberry Pi OS, read the HERE . picam2_cv2_histogram.py """ Picamera2 + OpenCV exercise: Run on Raspberry Pi 5 + Camera Module 3, capture image using capture_array() and display using cv2.imshow(). - plot histogram of the images. Press: S/s to save Q/q to quit My cameras: Picamera2(0) - Camera Module 3 NoIR Wide Picamera2(1) - Camera Module 3 """ import cv2 import picamera2 from libcamera import controls import platform from importlib.metadata import version import time import matplotlib import matplotlib.pyplot as plt print("Python:", platform.python_version()) print(picamera2.__name__ + ":", version(picamera2.__name__)) print(cv2.__name__ + ":", cv2.__version__) print(matplotlib.__nam

Python/OpenCV exercises on Raspberry Pi - Capture images from Camera Module 3 using Picamera2, display using OpenCV.

Image
It's a Python/OpenCV exercise run on Raspberry Pi OS (Bookworm), to capture images using Picamera2 and show using OpenCV. Test on: Raspberry Pi 5B/Raspberry Pi OS 64-bit (Bookworm) Python: 3.11.2 picamera2: 0.3.18 cv2: 4.6.0 ( OpenCV was installed from apt ) Code: picam2_cv2_capture_array.py """ Picamera2 + OpenCV exercise: Run on Raspberry Pi 5 + Camera Module 3, capture image using capture_array() and display using cv2.imshow(). Press: S/s to save Q/q to quit My cameras: Picamera2(0) - Camera Module 3 NoIR Wide Picamera2(1) - Camera Module 3 """ import cv2 import picamera2 from libcamera import controls import platform from importlib.metadata import version import time print("Python:", platform.python_version()) print(picamera2.__name__ + ":", version(picamera2.__name__)) print(cv2.__name__ + ":", cv2.__version__) print() time.sleep(1) cv2.startWindowThread() picam2 = picamera2.Picamera2(1) pica