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

相关推荐
云姜.14 小时前
YAML简单使用
python
喵手15 小时前
Python爬虫实战:手把手教你Python 自动化构建志愿服务岗位结构化数据库!
爬虫·python·自动化·数据采集·爬虫实战·零基础python爬虫教学·志愿服务岗位结构数据库打造
chushiyunen15 小时前
python numpy包的使用
开发语言·python·numpy
小邓睡不饱耶15 小时前
Python多线程爬虫实战:爬取论坛帖子及评论
开发语言·爬虫·python
喵手15 小时前
Python爬虫实战:手把手教你如何采集开源字体仓库目录页(Google Fonts / 其他公开字体目录)!
爬虫·python·自动化·数据采集·爬虫实战·零基础python爬虫教学·开源字体仓库目录页采集
Chase_______15 小时前
【Python 基础】第2章:流程控制完全指南(if/match/while/for)
python
第一程序员15 小时前
Python高级特性详解:从基础到进阶
python·github
wzhidev15 小时前
04、Python核心数据类型详解:从一段诡异的调试说起
开发语言·python
wzhidev15 小时前
05、Python流程控制与函数定义:从调试现场到工程实践
linux·网络·python
Thomas.Sir15 小时前
第十一章:深入剖析 Prompt 提示工程
python·prompt