【代码】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 分钟前
PyQt5多线程UI更新方法
python·qt·ui
玄同7657 分钟前
SQLAlchemy 会话管理终极指南:close、commit、refresh、rollback 的正确打开方式
数据库·人工智能·python·sql·postgresql·自然语言处理·知识图谱
喵手8 分钟前
Python爬虫零基础入门【第九章:实战项目教学·第11节】Playwright 入门实战:渲染后 HTML + 截图定位问题!
爬虫·python·爬虫实战·playwright·python爬虫工程化实战·零基础python爬虫教学·渲染html
一晌小贪欢10 分钟前
Python ORM 深度解析:告别繁琐 SQL,让数据操作如丝般顺滑
开发语言·数据库·python·sql·python基础·python小白
华研前沿标杆游学19 分钟前
2026智启新程 | 走进华为及商汤科技参观研学高级研修班
python
曲幽21 分钟前
FastAPI异常处理全解析:别让你的API在用户面前“裸奔”
python·websocket·api·fastapi·web·exception·error·httexception
小Pawn爷22 分钟前
6.本地安装Fingpt
python·llm
2301_8112329825 分钟前
使用Flask快速搭建轻量级Web应用
jvm·数据库·python
m0_5613596727 分钟前
高级爬虫技巧:处理JavaScript渲染(Selenium)
jvm·数据库·python
OnYoung44 分钟前
实战:用OpenCV和Python进行人脸识别
jvm·数据库·python