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

相关推荐
是小蟹呀^11 分钟前
【总结】LangChain中的中间件Middleware
python·中间件·langchain·agent
qq_3422958212 分钟前
如何为容器内多个列表实现统一滚动条.txt
jvm·数据库·python
FreakStudio31 分钟前
MicroPython对接大模型:uopenai + 火山方舟实现文字聊天和图片理解
python·单片机·ai·嵌入式·面向对象·电子diy
Kimliao16635 分钟前
TFT-LCD液晶显示模组常见驱动电压的作用
python
qq_2069013937 分钟前
CSS如何引入自适应图标_利用svg外链配合css控制颜色
jvm·数据库·python
weixin_4087177744 分钟前
Go语言怎么编译Linux程序_Go语言编译Linux可执行文件教程【避坑】
jvm·数据库·python
2501_944934731 小时前
财务岗位如何在工作中提升数据分析能力?从财务分析到经营分析这样练
python·信息可视化·数据分析
2401_865439631 小时前
CSS怎么在flex布局中实现项目均分间距_设置justify-content space-evenly
jvm·数据库·python
m0_493934531 小时前
CSS如何实现输入框禁用样式_使用-disabled伪类设定
jvm·数据库·python
m0_716430071 小时前
如何用 classList.toggle 实现侧边栏菜单的点击展开与收起
jvm·数据库·python