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

相关推荐
PONY LEE28 分钟前
Flink keyby使用随机数踩坑记
大数据·python·flink
一只小松许️1 小时前
量化投资从入门到入土:金融基础概念
python·金融
憨憨崽&1 小时前
C语言、Java、Python 的选择与未来发展以及学习路线
java·c语言·python
练习两年半的帅b1 小时前
正则表达式及应用
python
ZhengEnCi1 小时前
Python字符串完全指南-从创建拼接到格式化的高效实践
python
junziruruo1 小时前
半监督学习,少样本学习和零样本学习
python·学习·机器学习
yunbao00_2 小时前
博客系统测试报告
python·功能测试·测试用例
长颈鹿仙女2 小时前
发送 Prompt 指令:请用一句话总结文本内容
python·深度学习·大模型
该用户已不存在2 小时前
构建现代应用的9个Python GUI库
前端·后端·python
Java中文社群2 小时前
用代码书写浪漫,网友直呼“太美了”!
python