【代码】jetson+OLED屏幕+显示mp4视频

import cv2

import time

import Adafruit_GPIO.SPI as SPI

import Adafruit_SSD1306

from PIL import Image

Raspberry Pi pin configuration:

RST = 24

DC = 23

SPI_PORT = 0

SPI_DEVICE = 0

128x32 display with hardware I2C:

disp = Adafruit_SSD1306.SSD1306_128_32(rst=None, i2c_bus=1, gpio=1)

Initialize library.

disp.begin()

Clear display.

disp.clear()

disp.display()

Open the video file

cap = cv2.VideoCapture('932592103.mp4')

Check if the video file opened successfully

if not cap.isOpened():

print("Error: Unable to open video file.")

exit()

Read and display each frame

while cap.isOpened():

ret, frame = cap.read()

if not ret:

break

Convert the frame to grayscale

gray_frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

Resize the frame to fit the OLED display

resized_frame = cv2.resize(gray_frame, (disp.width, disp.height))

Convert the frame to PIL Image

pil_image = Image.fromarray(resized_frame).convert('1')

Display image.

disp.image(pil_image)

disp.display()

Delay to control frame rate (adjust as needed)

time.sleep(0.1)

Release the video capture object and close the display

cap.release()

disp.clear()

disp.display()

相关推荐
輕華3 分钟前
uv工具详解——Python包与项目管理器完全指南
开发语言·python·uv
li星野5 分钟前
位运算 & 数学 & 高频进阶九题通关(Python + C++)
c++·python·学习·算法
2303_8212873812 分钟前
如何清洗SQL输入数据_使用框架内置的ORM处理数据交互
jvm·数据库·python
go不是csgo14 分钟前
s01 搭建第一个对话智能体
服务器·网络·python·ai
用户83562907805117 分钟前
使用 Python 在 PowerPoint 中生成并自定义饼图与环形图
后端·python
棉猴21 分钟前
python海龟绘图之倾转
python·turtle·海龟绘图·titlangle·tilt
小白学大数据1 小时前
基于大模型的Python智能爬虫:语义识别与数据清洗实践
开发语言·爬虫·python·数据分析
Cloud_Shy6181 小时前
Python 数据分析基础入门:《Excel Python:飞速搞定数据分析与处理》学习笔记系列(附录 B 高级 VS Code 功能)
vscode·python·jupyter·数据分析·excel
进击切图仔1 小时前
从零手写 RAG
python·huggingface·rag
Dxy12393102161 小时前
Python请求方式介绍:JSON、表单及其他常见数据传输格式
数据库·python·json