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

相关推荐
m0_674294642 分钟前
C#怎么使用Channel异步通道 C#如何用BoundedChannel实现有界队列限流异步数据流【进阶】
jvm·数据库·python
m0_748920363 分钟前
HTML函数在系统更新后变卡是硬件老化吗_软硬兼容性排查【方法】
jvm·数据库·python
23471021273 分钟前
4.20 学习笔记
软件测试·笔记·python·学习
weixin_424999364 分钟前
如何正确对对象键名进行字母序排序并存入数组
jvm·数据库·python
生信研究猿4 分钟前
ACM格式:在pycharm输入
python
maqr_1106 分钟前
如何配置Oracle 19c审计清理_DBMS_AUDIT_MGMT自动清除策略
jvm·数据库·python
qq_372906939 分钟前
如何用 JavaScript 实现单选式盒子颜色切换(点击高亮,其余复原)
jvm·数据库·python
2401_8971905511 分钟前
怎样使用Navicat高级特权进行还原时解决字符集冲突_企业数据保护
jvm·数据库·python
weixin_5806140014 分钟前
c++文件锁使用方法 c++如何实现多进程文件同步
jvm·数据库·python
qq_3300379914 分钟前
如何转换数据文件字节序_CONVERT DATAFILE用于跨OS平台数据库迁移
jvm·数据库·python