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

相关推荐
weixin_441003648 分钟前
357本Python精品书籍pdf电子书下载
python·pdf
心勤则明16 分钟前
基于Spring AI Alibaba的监督者模式实践
人工智能·python·spring
源码之家25 分钟前
计算机毕业设计:Python雪球网股票数据采集与可视化系统 Flask框架 数据分析 可视化 大数据 大模型 爬虫(建议收藏)✅
大数据·python·机器学习·数据挖掘·数据分析·flask·课程设计
小白学大数据26 分钟前
企业精准数据分析双路径对比:运营商大数据与 Python 爬虫技术选型与实践
大数据·开发语言·爬虫·python·数据分析
jr-create(•̀⌄•́)35 分钟前
简单视频编辑tools
python·ffmpeg
袁袁袁袁满35 分钟前
亮数据SERP API实现搜索引擎实时数据采集
爬虫·python·网络爬虫·爬山算法
citi36 分钟前
OpenViking 本地搭建指南
开发语言·python·ai
彭于晏Yan38 分钟前
Spring Boot + WebSocket 实现单聊已读未读(四)
spring boot·python·websocket
AI玫瑰助手39 分钟前
Python基础:列表的切片与嵌套列表使用技巧
android·开发语言·python
Rnan-prince40 分钟前
Count-Min Sketch:海量数据频率统计的“轻量级计数器“
python·算法