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

相关推荐
susu10830189115 分钟前
python代码把GIF 转成视频
开发语言·python
木头程序员9 分钟前
关于load_data_fashion_mnist函数运行原理以及运行速度慢解决方案
人工智能·python·深度学习·d2l
林姜泽樾20 分钟前
python入门第六课,其他字符串格式化和input
开发语言·python·pycharm
yunpeng.zhou21 分钟前
深度理解agent与llm之间的关系、及mcp与skill的区别
人工智能·python·ai
智算菩萨37 分钟前
【Pygame】第14章 摄像机系统与游戏视口控制技术
python·游戏·pygame
小镇学者43 分钟前
【python】 macos 安装ffmpeg 命令行工具
python·macos·ffmpeg
电商API&Tina1 小时前
【京东item_getAPI 】高稳定:API 、非爬虫、不封号、不掉线、大促稳跑
大数据·网络·人工智能·爬虫·python·sql·json
O丶ne丨柒夜1 小时前
Claude Code、Codex 常用命令和命令速查
python
weixin_408099671 小时前
身份证正反面合并+识别OCR接口调用
java·人工智能·后端·python·ocr·api·身份证ocr
vx_biyesheji00011 小时前
计算机毕业设计:Python汽车市场智能决策系统 Flask框架 可视化 机器学习 AI 大模型 大数据(建议收藏)✅
大数据·人工智能·python·算法·django·汽车·课程设计