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

相关推荐
2401_879693871 分钟前
使用Python控制Arduino或树莓派
jvm·数据库·python
查古穆26 分钟前
python进阶-推导式
开发语言·python
☆5661 小时前
如何为开源Python项目做贡献?
jvm·数据库·python
m0_560396471 小时前
使用Python进行PDF文件的处理与操作
jvm·数据库·python
SEO-狼术1 小时前
Improve Navigation with In-Cell Hyperlinks
python·pdf
2301_816651221 小时前
用Python监控系统日志并发送警报
jvm·数据库·python
飞Link1 小时前
Python Pydantic V2 核心原理解析与企业级实战指南
开发语言·python
Betelgeuse762 小时前
Django 项目远程服务器部署教程:从开发到生产
python·django·vue
2501_918126912 小时前
学习python所有用来写ai的语句
人工智能·python·学习