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

相关推荐
ZC跨境爬虫10 小时前
极验滑动验证码自动化实战(ddddocr免费方案):本地缺口识别与Playwright滑动模拟
前端·爬虫·python·自动化
单片机学习之路10 小时前
【Python】输入print函数
开发语言·前端·python
后藤十八里10 小时前
极验4消消乐验证码逆向笔记
笔记·爬虫·python
李昊哲小课10 小时前
Python办公自动化教程 - 第1章 openpyxl基础入门 - 第一次用代码操控Excel
开发语言·python·excel·openpyxl
智算菩萨10 小时前
【Python图像处理】4 NumPy数组操作与图像矩阵运算
图像处理·python·numpy
SomeB1oody10 小时前
【Python深度学习】1.1. 多层感知器MLP(人工神经网络)介绍
开发语言·人工智能·python·深度学习·机器学习
数据科学小丫10 小时前
数据分析利器 Pandas :apply() 方法 + map() 配对 + 计算描述统计 + 协方差和相关性 + 异常值处理常用方法(基于 python )
python·数据分析·numpy·pandas
财经资讯数据_灵砚智能10 小时前
基于全球经济类多源新闻的NLP情感分析与数据可视化(日间)2026年4月6日
大数据·人工智能·python·信息可视化·语言模型·自然语言处理·ai编程
爱写代码的小朋友11 小时前
使用 Nuitka 打包 Python 应用:从入门到进阶
开发语言·python
不屈的铝合金11 小时前
Python入门:数字类型与运算
python·数据类型·python类型判断与转换·python运算符优先级