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

相关推荐
Humbunklung23 分钟前
PySide6 GUI 学习笔记——常用类及控件使用方法(常用类矩阵QRectF)
笔记·python·学习·pyqt
蹦蹦跳跳真可爱58935 分钟前
Python----深度学习(基于DNN的吃鸡预测)
python·深度学习·dnn
JJ1M81 小时前
Git技巧:Git Hook,自动触发,含实战分享
git·python·自动化
拓端研究室TRL2 小时前
PyMC+AI提示词贝叶斯项目反应IRT理论Rasch分析篮球比赛官方数据:球员能力与位置层级结构研究
大数据·人工智能·python·算法·机器学习
小白用python2 小时前
pycharm无法创建venv虚拟环境
ide·python·pycharm
ImAlex2 小时前
开开心心放假回家,结果忘记老家wifi密码新买的手机连不上WiFi?不用慌,pywifi来拯救你。
python
fantasy_43 小时前
LeetCode238☞除自身以外数组的乘积
java·数据结构·python·算法·leetcode
Tech Synapse3 小时前
零基础搭建AI作曲工具:基于Magenta/TensorFlow的交互式音乐生成系统
人工智能·python·tensorflow
纪元A梦3 小时前
华为OD机试真题——阿里巴巴找黄金宝箱Ⅰ(2025A卷:100分)Java/python/JavaScript/C/C++/GO最佳实现
java·c语言·javascript·c++·python·华为od·go
AI_RSER4 小时前
Python 数据可视化全场景实现(一)
开发语言·人工智能·python·信息可视化·遥感