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

相关推荐
四维迁跃2 分钟前
如何排查SQL存储过程死锁_分析死锁日志与索引优化
jvm·数据库·python
m0_741173332 分钟前
如何检测SQL注入风险_利用模糊测试技术发现漏洞
jvm·数据库·python
xcbrand5 分钟前
餐饮品牌全案公司哪家可靠
运维·python
2401_8463395613 分钟前
CSS如何解决Less与CSS兼容性问题_通过配置文件实现平滑过渡与混合开发
jvm·数据库·python
qq_4138474014 分钟前
CSS如何控制全屏显示的元素样式
jvm·数据库·python
scan72417 分钟前
上下文摘要
python
第一程序员19 分钟前
2026年GitHub上最火的10个Python项目,Rust开发者必看
python·rust·github
阿正呀24 分钟前
CSS粘性定位不生效怎么办_检查父元素高度与overflow属性设置
jvm·数据库·python
2403_8832610926 分钟前
如何获取DDL语句_DBMS_METADATA.GET_DDL提取对象定义
jvm·数据库·python
m0_6138562932 分钟前
mysql数据库乱码如何解决_mysql字符集与校对规则配置方法
jvm·数据库·python