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

相关推荐
l1t7 小时前
对在aarch64 Linux环境编译安装的CinderX补充测试
linux·运维·服务器·python·jit
getapi7 小时前
Windows 11 安装 uv包括:更新、常用命令、Python 管理、环境切换等,(Astral 的 Python 包/环境工具)完整指南
windows·python·uv
智算菩萨7 小时前
【Pygame】第1章 Pygame入门与环境搭建
python·ai编程·pygame
Dxy12393102167 小时前
Python 使用 `raise` 报错抛出异常显示 Unicode 码如何解决
开发语言·python
源码之家7 小时前
计算机毕业设计:Python 共享单车数据分析可视化系统 Flask框架 可视化 大数据 机器学习 深度学习 数据挖掘(建议收藏)✅
大数据·python·数据挖掘·数据分析·汽车·课程设计·美食
SiYuanFeng7 小时前
uv初步介绍及简单的使用方法例子
开发语言·python·uv
zero15977 小时前
Python 8天极速入门笔记(大模型工程师专用):第八篇-Python 综合实战|完整大模型调用脚本,8 天成果落地
人工智能·python·ai编程·大模型开发
孤魂2337 小时前
机器学习基本概念
python·机器学习
人工干智能7 小时前
科普:<generator object ...>,不是报错!兼谈[x for x in ...]与(x for x in ...)
python
张二娃同学7 小时前
基于 Python 与 Tkinter 的猜数字游戏设计与实现:支持玩家猜数与 AI 反向推理
开发语言·git·python·游戏·开源