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

相关推荐
m0_3776182312 小时前
如何在 Node.js 服务器间正确配置 CORS 实现跨子域资源访问
jvm·数据库·python
qq_1898070312 小时前
如何在 Django ListView 中正确过滤当前用户的照片数据
jvm·数据库·python
m0_3776182312 小时前
Go语言如何用systemd_Go语言systemd服务管理教程【总结】
jvm·数据库·python
棉猴13 小时前
python海龟绘图之计算夹角towards()
开发语言·python·turtle·海龟绘图·towards
星马梦缘13 小时前
强化学习实战8.1——用PPO打赢星际争霸【环境配置与下位机代码】
人工智能·python·jupyter·强化学习·星际争霸·stablebaseline3·starcraft2
qq_1898070313 小时前
SQL快速查找分组记录数异常的分类_利用HAVING筛选
jvm·数据库·python
m0_7478545213 小时前
Python模型保存为ONNX格式_跨平台推理部署与加速技巧
jvm·数据库·python
YuanDaima204813 小时前
Python 数据结构与语法速查笔记
开发语言·数据结构·人工智能·python·算法
粉嘟小飞妹儿13 小时前
怎么关闭MongoDB不需要的HTTP管理接口及REST API
jvm·数据库·python
qq_2069013913 小时前
c++如何将浮点数按指定精度写入文本_setprecision用法【实战】
jvm·数据库·python