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

相关推荐
yangtuoni3 分钟前
vscode调试C++ python相关配置
c++·vscode·python
小章UPUP9 分钟前
2026 信息技术中考复习资料大全
python
2401_8822737210 分钟前
CSS 背景色无法撑满父容器?解决浮动导致的高度塌陷问题
jvm·数据库·python
好家伙VCC16 分钟前
上市公司产学研合作及专利数据(1998-2022年)
人工智能·python
weixin_3812881821 分钟前
jsoup如何读取html
jvm·数据库·python
2401_8822737228 分钟前
golang如何处理zip压缩包_golang zip压缩包处理思路
jvm·数据库·python
Hesionberger29 分钟前
LeetCode72.编辑距离(多维动态规划)
java·开发语言·c++·python·算法
tjc1990100534 分钟前
Golang怎么实现分布式定时任务_Golang如何保证集群中定时任务不重复执行【进阶】
jvm·数据库·python
卷心菜狗35 分钟前
Python进阶--网络编程入门
python
XLYcmy37 分钟前
2026游戏安全技术竞赛-PC客户端安全-初赛 求解起点到终点的最短路径
windows·python·网络安全·dfs·bfs·游戏安全·曼哈顿距离