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

相关推荐
a11177610 小时前
MonoGS 在 Jetson Orin Nano 上的部署与性能测试
python·开源·torch·cv
偶尔微微一笑10 小时前
智能体四大核心模块揭秘
python
2301_8159019710 小时前
SQL如何将多行记录聚合成逗号分隔字符串_GROUP_CONCAT技巧
jvm·数据库·python
西索斯10 小时前
Claude API 报 529 Overloaded 怎么办?3 种方案实测,最后一种最省心
python·claude
Flittly10 小时前
【LangGraph新手村系列】(3)PostgreSQL 持久化检查点:让状态跨越进程与重启
人工智能·python·langchain
.柒宇.11 小时前
FastAPI 基础指南:从入门到实战
开发语言·python·fastapi
魔都吴所谓11 小时前
【Python】从扁平参数到层级架构:基于Python argparse构建校园管理CLI工具实战
python·编程语言
zjy2777711 小时前
Layui tab选项卡如何动态根据ID值进行程序化切换
jvm·数据库·python
m0_6028577611 小时前
Redis如何修复槽位分配重叠的脏状态_使用redis-cli --cluster fix工具扫描并修复不一致的Slot
jvm·数据库·python
2301_7662834411 小时前
怎样开启phpMyAdmin的操作审计日志_记录每条执行的SQL
jvm·数据库·python