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

相关推荐
蜜獾云5 分钟前
Maven项目引入本地JAR包的三种正确方式对比
python·maven·jar
爱睡懒觉的焦糖玛奇朵6 分钟前
【工业级落地算法之打架斗殴检测算法详解】
人工智能·python·深度学习·学习·算法·yolo·计算机视觉
深挖派8 分钟前
PyCharm 2026.1 全版本安装配置与全功能环境搭建 (保姆级图文教程)
ide·python·pycharm
好家伙VCC9 分钟前
**发散创新:基于算子融合的深度学习推理优化实战**在现代AI部署场景
java·人工智能·python·深度学习
Ofm1z1Q9R10 分钟前
python-langchain框架(3-5-pdf文件load_and_split()加载 )
python·langchain·pdf
数据知道17 分钟前
claw-code 源码详细分析:命令宇宙 vs 工具宇宙——`commands` / `tools` 镜像清单如何驱动路由与 shim 执行?
linux·服务器·网络·python·ai·claude code
郝学胜-神的一滴23 分钟前
Pytorch自动微分模块:从原理到实战,解锁反向传播核心奥秘
服务器·人工智能·pytorch·python·深度学习·机器学习
CappuccinoRose31 分钟前
排序算法和查找算法 - 软考备战(十五)
数据结构·python·算法·排序算法·查找算法
lifallen38 分钟前
Flink Agents:从 DataStream 到 Agent 算子的接入与装配
java·大数据·人工智能·python·语言模型·flink
做cv的小昊1 小时前
【conda】打包已有conda环境并在其他服务器上搭建
运维·服务器·python·conda·运维开发·pip·开发