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

相关推荐
幻云20104 分钟前
Python机器学习:筑基与实践
前端·人工智能·python
喵手4 分钟前
Python爬虫零基础入门【第二章:网页基础·第2节】你要抓的到底是什么:HTML、CSS 选择器、XPath 入门?
爬虫·python·python爬虫实战·python爬虫工程化实战·python爬虫零基础入门·网页基础·网页结构解析
飞天小蜈蚣6 分钟前
python-django_ORM的十三个查询API接口
开发语言·python·django
人工智能AI技术12 分钟前
【Agent从入门到实践】18 脚本化编程:批量执行、自动化逻辑
人工智能·python
摘星编程15 分钟前
React Native + OpenHarmony:MapView自定义标注样式
python
向量引擎18 分钟前
[硬核架构] 2026 企业级 AI 网关落地指南:从“连接超时”到“秒级响应”的架构演进(附 Python/Java 源码)
人工智能·python·gpt·ai作画·架构·aigc·api调用
0思必得020 分钟前
[Web自动化] Selenium模拟用户的常见操作
前端·python·selenium·自动化
凡客丶24 分钟前
Windows版Miniconda打包环境迁移到内网离线环境【详解】
windows·python
AI大佬的小弟28 分钟前
【详细步骤】大模型基础知识(4)---ollama模型调用-多轮对话体验
python·ollama·大模型基础·ai 聊天机器人·简单的大模型部署·实现ollama模型调用·零基础上手 ollama体验
AndrewHZ36 分钟前
【Python与生活】怎么用python画出好看的分形图?
开发语言·python·生活·可视化·递归·分形