dongchang/tests/test_camera.py
2025-01-13 16:05:22 +08:00

22 lines
698 B
Python

import cv2
import numpy as np
import time
from src.camera_handler import RTSPCamera
def test_rtsp_camera():
# 使用本地测试视频或摄像头
camera = RTSPCamera("rtsp://10.0.0.17:8554/camera_test/2") # 使用本地摄像头进行测试
print("测试摄像头启动...")
camera.start()
time.sleep(10) # 等待摄像头初始化
print("测试获取帧...")
frame = camera.get_frame()
assert frame is not None, "无法获取视频帧"
assert isinstance(frame, np.ndarray), "帧格式不正确"
assert len(frame.shape) == 3, "帧维度不正确"
print("测试摄像头停止...")
camera.stop()
print("摄像头测试完成!")