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

相关推荐
用户3521802454753 小时前
🕸️ GraphRAG 图数据质量评估:让你的知识图谱不再“翻车”!
人工智能·python·ai编程
楼田莉子3 小时前
python小项目——学生管理系统
开发语言·python·学习
yuanpan3 小时前
使用Python创建本地Http服务实现与外部系统数据对接
开发语言·python·http
真*小白3 小时前
Python语法学习篇(三)【py3】
开发语言·python·学习
不一样的故事1263 小时前
学习Python是一个循序渐进的过程,结合系统学习、持续实践和项目驱动,
开发语言·python·学习
@HNUSTer3 小时前
Python数据可视化科技图表绘制系列教程(七)
python·数据可视化·科技论文·专业制图·科研图表
shizidushu4 小时前
How to work with merged cells in Excel with `openpyxl` in Python?
python·microsoft·excel·openpyxl
郝学胜-神的一滴4 小时前
深入探索 Python 元组:从基础到高级应用
运维·服务器·开发语言·python·程序人生
技术程序猿华锋4 小时前
深度解码OpenAI的2025野心:Codex重生与GPT-5 APIKey获取调用示例
人工智能·vscode·python·gpt·深度学习·编辑器
xchenhao8 小时前
SciKit-Learn 全面分析分类任务 breast_cancer 数据集
python·机器学习·分类·数据集·scikit-learn·svm