【代码】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()

相关推荐
u0107475461 分钟前
JavaScript 递归调用栈深度解析与层级遍历陷阱详解
jvm·数据库·python
本地化文档5 分钟前
requests-docs-l10n
python·http·github·gitcode
Metaphor6926 分钟前
使用 Python 将 PowerPoint 转换为 PDF
python·pdf·powerpoint
XiYang-DING8 分钟前
【Java】Lambda表达式
java·开发语言·python
Irene199110 分钟前
配置 PyCharm(汉化版操作指南)
python·pycharm
来自远方的老作者10 分钟前
第9章 函数-9.7 函数嵌套
开发语言·python·函数·函数嵌套
7年前端辞职转AI11 分钟前
Python 错误和异常处理
python·编程语言
7年前端辞职转AI11 分钟前
Python 面向对象编程
python·编程语言
kishu_iOS&AI14 分钟前
机器学习 —— 总结
人工智能·python·机器学习·线性回归
API快乐传递者17 分钟前
Python 爬虫获取 1688 商品详情 API 接口实战指南
java·前端·python