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

相关推荐
程序媛徐师姐1 分钟前
Python基于深度学习的声音识别青少年防沉迷系统【附源码、文档说明】
python·深度学习·声音识别青少年防沉迷系统·python声音识别·python青少年防沉迷系统·python深度学习声音识别·青少年防沉迷系统
汤姆yu7 分钟前
基于python大数据的天气可视化及预测系统
大数据·开发语言·python
huohuopro8 分钟前
只能录入不能粘贴?这里解决
python
代码探秘者8 分钟前
【算法篇】2.滑动窗口
java·数据结构·后端·python·算法·spring
进击的雷神8 分钟前
展位号后缀清理、详情页JS数据提取、重试机制控制、地址字段重构——美国NPE展爬虫四大技术难关攻克纪实
javascript·爬虫·python·重构
oem11011 分钟前
Django全栈开发入门:构建一个博客系统
jvm·数据库·python
社畜码农且逊12 分钟前
安装虚拟环境工具virtualenv,通过virtualenv myenv创建虚拟环境,激活虚拟环境后安装项目依赖
python·virtualenv
l1t14 分钟前
Qwen 3.5plus编写的求解欧拉计划901题python程序优化
开发语言·python
no_work15 分钟前
基于python的hog+svm实现混凝土裂缝目标检测
人工智能·python·目标检测·计算机视觉
小陈工15 分钟前
2026年3月21日技术资讯洞察:云原生理性回归与Python异步革命
人工智能·python·云原生·数据挖掘·回归