项目初始化

This commit is contained in:
2025-06-26 16:48:49 +08:00
commit eb17d1f7f5
19 changed files with 301 additions and 0 deletions

40
cut.py Normal file
View File

@ -0,0 +1,40 @@
import cv2
import time
# RTSP流地址
rtsp_url = "rtsp://admin:xkrs0425@172.16.20.15:554/D6/main/av_stream"
# 通过opencv创建一个视频捕获对象
cap = cv2.VideoCapture(rtsp_url)
# 检查是否成功打开
if not cap.isOpened():
print("Error: Could not open video stream from provided RTSP URL.")
else:
print("Successfully opened RTSP stream, starting to capture frames...")
# 等待几秒让摄像头预热(可选)
time.sleep(2)
# 循环读取帧
while True:
ret, frame = cap.read()
if not ret:
print("Failed to grab frame")
break
# 显示当前帧(可选)
cv2.imshow('RTSP Stream', frame)
# 保存截图到文件
img_name = f"D:\\syg\\jk2\\frame_{int(time.time())}.png"
cv2.imwrite(img_name, frame)
print(f"{img_name} saved!")
# 按键检测,按下 'q' 键退出循环
if cv2.waitKey(1) & 0xFF == ord('q'):
break
# 结束后释放资源
cap.release()
cv2.destroyAllWindows()