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

相关推荐
yanghuashuiyue8 分钟前
langchain AI应用框架研究【前端-篇二】
人工智能·python·langchain
维基框架12 分钟前
WIKI 知识库系统 — 项目框架全解析
python
Lenyiin13 分钟前
Python数据类型与运算符:深入理解Python世界的基石
java·开发语言·python
小江的记录本16 分钟前
【大语言模型】大语言模型——核心概念(预训练、SFT监督微调、RLHF/RLAIF对齐、Token、Embedding、上下文窗口)
java·人工智能·后端·python·算法·语言模型·自然语言处理
坐吃山猪17 分钟前
Python04_序列和字符串
python
tang74516396223 分钟前
mac的ideal中调用driver = webdriver.Chrome() 启动不了的原因
chrome·python·macos
码云数智-大飞30 分钟前
CSS 优先级详解:告别样式冲突,掌控网页“层叠”艺术
人工智能·python·tensorflow
迦南的迦 亚索的索35 分钟前
PYTHON_DAY21_数据分析
开发语言·python·数据分析
阿Y加油吧36 分钟前
栈的经典应用:字符串解码 & 每日温度 深度解析
数据结构·python·算法
ID_1800790547339 分钟前
如何使用 Python 调用小红书笔记评论 API 时进行并发控制?
开发语言·笔记·python