diff --git a/opencv_webcamv_v03.py b/opencv_webcam_v03.py similarity index 94% rename from opencv_webcamv_v03.py rename to opencv_webcam_v03.py index c7018b6..e616e3c 100644 --- a/opencv_webcamv_v03.py +++ b/opencv_webcam_v03.py @@ -1,6 +1,6 @@ -# OpenCV Webcam Script v0.2 +# OpenCV Webcam Script v0.3 # 创建人:曾逸夫 -# 创建时间:2022-01-02 +# 创建时间:2022-01-08 import cv2 from pathlib import Path @@ -16,8 +16,8 @@ from utils.frame_opt import frame_opt def parse_args(known=False): parser = argparse.ArgumentParser(description='OpenCV Webcam Script v0.2') - parser.add_argument('--device', '-dev', default=0, - type=int, help='device index for webcam') + parser.add_argument('--device', '-dev', default='0', + type=str, help='device index for webcam, 0 or rtsp') parser.add_argument('--quit', '-q', default="q", type=str, help='quit key for webcam') parser.add_argument('--is_autoSaveFrame', '-isasf', @@ -62,7 +62,9 @@ def webcam_opencv(device_index=0, quit_key="q", pause_key="p", is_autoSaveFrame= # ------------------程序开始------------------ s_time = time.time() # 起始时间 - cap = cv2.VideoCapture(device_index) # 连接设备 + dev_index = eval(device_index) if device_index.isnumeric( + ) else device_index # 设备选择 (usb 0,1,2; rtsp) + cap = cv2.VideoCapture(dev_index) # 连接设备 frame_width = cap.get(3) # 宽度 frame_height = cap.get(4) # 高度 fps = cap.get(5) # 帧率 diff --git a/v03.md b/v03.md index 0acb9c9..ff5989e 100644 --- a/v03.md +++ b/v03.md @@ -7,7 +7,7 @@ ### 功能更新 - +- 加入rtsp功能 ### BUG修复 \ No newline at end of file