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

相关推荐
Pyeako6 分钟前
机器学习--集成学习之随机森林&贝叶斯算法
python·算法·随机森林·机器学习·集成学习·贝叶斯算法
reasonsummer7 分钟前
【人工智能-03-06】20251227 人工智能第二学期课程 下载课件《教育设计中的信息化》中的“多人编辑文件” 的图片,然后合并PDF
python
.似水22 分钟前
Python面向对象
开发语言·python
山土成旧客24 分钟前
【Python学习打卡-Day30】模块化编程:从“单兵作战”到“军团指挥”
开发语言·python·学习
秋邱28 分钟前
Java包装类:基本类型与包装类转换、自动装箱与拆箱原理
java·开发语言·python
拉拉拉拉拉拉拉马32 分钟前
感知机(Perceptron)算法详解
人工智能·python·深度学习·算法·机器学习
万邦科技Lafite33 分钟前
淘宝开放API获取订单信息教程(2025年最新版)
java·开发语言·数据库·人工智能·python·开放api·电商开放平台
ha_lydms36 分钟前
6、Spark 函数_u/v/w/x/y/z
java·大数据·python·spark·数据处理·dataworks·spark 函数
NullPointer836 分钟前
【剪映小助手源码精讲】第34章:视频任务管理
python·aigc
日日行不惧千万里39 分钟前
Java中Lambda Stream详解
java·开发语言·python