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

相关推荐
sg_knight8 分钟前
设计模式实战:代理模式(Proxy)
python·设计模式·代理模式·proxy
xixihaha132411 分钟前
实战:用OpenCV和Python进行人脸识别
jvm·数据库·python
badhope11 分钟前
Python 库全景图:核心工具与最佳实践(小白也能看懂版)
后端·python
带娃的IT创业者17 分钟前
WeClaw WebSocket 路由实战:BridgeConnectionManager 如何用四层映射在 800 个连接中实现毫秒级消息转发?
网络·python·websocket·网络协议·fastapi·实时通信
Storynone21 分钟前
【Day】LeetCode:134. 加油站,135. 分发糖果,860. 柠檬水找零,406. 根据身高重建队列
python·算法·leetcode
阿_旭31 分钟前
基于YOLO26深度学习的茶叶病害智能检测识别系统【python源码+Pyqt5界面+数据集+训练代码】
人工智能·python·深度学习·茶叶病害检测
好家伙VCC34 分钟前
**NumPy中的高效数值计算:从基础到进阶的实战指南**在现代数据科学与机器学习领域
java·python·机器学习·numpy
荷蒲36 分钟前
【小白量化机器人】爬取财经新闻并利用本地大模型评分选择合适交易策略
人工智能·python·机器学习·ai·金融·本地大模型
&变形记¥36 分钟前
openclaw升级/重启
python
ewboYang40 分钟前
自学全栈搭建python [fastapi] + uniapp [vue3+ts]项目
python·uni-app·fastapi