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

相关推荐
百锦再2 小时前
第18章 高级特征
android·java·开发语言·后端·python·rust·django
源码之家2 小时前
基于Python房价预测系统 数据分析 Flask框架 爬虫 随机森林回归预测模型、链家二手房 可视化大屏 大数据毕业设计(附源码)✅
大数据·爬虫·python·随机森林·数据分析·spark·flask
SalvoGao2 小时前
Python学习 | 怎么理解epoch?
数据结构·人工智能·python·深度学习·学习
楚疏笃3 小时前
纯Python 实现 Word 文档转换 Markdown
python·word
谅望者3 小时前
数据分析笔记08:Python编程基础-数据类型与变量
数据库·笔记·python·数据分析·概率论
mortimer3 小时前
【实战复盘】 PySide6 + PyTorch 偶发性“假死”?由多线程转多进程
pytorch·python·pyqt
清静诗意3 小时前
Django REST Framework(DRF)RESTful 最完整版实战教程
python·django·restful·drf
studytosky4 小时前
深度学习理论与实战:Pytorch基础入门
人工智能·pytorch·python·深度学习·机器学习
长不大的蜡笔小新4 小时前
手写数字识别:从零搭建神经网络
人工智能·python·tensorflow
前进的李工4 小时前
LeetCode hot100:094 二叉树的中序遍历:从递归到迭代的完整指南
python·算法·leetcode·链表·二叉树