2022-01-22 11:11:16 +08:00
|
|
|
|
中文简体|[English](#)
|
2021-12-30 12:51:33 +08:00
|
|
|
|
<p align="center">
|
2021-12-31 11:28:29 +08:00
|
|
|
|
<a href="https://gitee.com/CV_Lab/opencv_webcam">
|
2022-01-23 09:34:11 +08:00
|
|
|
|
<img src="https://gitee.com/CV_Lab/opencv_webcam/attach_files/952125/download/opencv-webcam-script_logo.png" alt="Simple Icons" >
|
2021-12-30 12:51:33 +08:00
|
|
|
|
</a>
|
2022-01-23 09:34:11 +08:00
|
|
|
|
<p align="center">
|
|
|
|
|
基于OpenCV的Webcam程序,适用于实时视频帧采集、计算机视觉数据收集等。
|
|
|
|
|
</p>
|
|
|
|
|
<p align="center">
|
|
|
|
|
具有安装便捷、操作简单、跨平台等特点。
|
2022-01-18 09:12:51 +08:00
|
|
|
|
</p>
|
2022-01-23 09:34:11 +08:00
|
|
|
|
</p>
|
2021-12-30 12:51:33 +08:00
|
|
|
|
<p align="center">
|
2022-01-20 09:15:12 +08:00
|
|
|
|
<a href="https://gitee.com/CV_Lab/opencv_webcam/blob/master/codeCheck.md"><img src="https://img.shields.io/badge/CodeCheck-passing-success" alt="code check" /></a>
|
2022-01-24 10:32:14 +08:00
|
|
|
|
<a href="https://pypi.org/project/opencv-webcam-script/0.4.0/"><img src="https://img.shields.io/badge/PyPi-v0.4.0-brightgreen?logo=pypi" alt="PyPi" /></a>
|
2022-01-24 16:42:09 +08:00
|
|
|
|
<a href="https://gitee.com/CV_Lab/opencv_webcam/releases/v0.4"><img src="https://img.shields.io/badge/Releases-v0.4-green" alt="Releases Version" /></a>
|
2022-01-24 16:36:48 +08:00
|
|
|
|
<a href="https://hub.docker.com/r/zengdockerdocker/opencv-webcam-script"><img src="https://img.shields.io/badge/docker-v0.4-blue?logo=docker" alt="Docker" /></a>
|
2022-01-26 11:07:19 +08:00
|
|
|
|
<a href="https://gitee.com/CV_Lab/opencv_webcam/blob/master/tutorial/ows_jupyter.ipynb"><img src="https://img.shields.io/badge/Jupyter-v0.4-orange?logo=jupyter" alt="Jupyter" /></a>
|
2022-01-14 20:41:19 +08:00
|
|
|
|
<a href="https://gitee.com/CV_Lab/opencv_webcam/blob/master/LICENSE"><img src="https://img.shields.io/badge/License-GPL--3.0-blue" alt="License" /></a>
|
2021-12-30 12:51:33 +08:00
|
|
|
|
</p>
|
2022-01-26 16:40:40 +08:00
|
|
|
|
|
2022-01-26 11:21:05 +08:00
|
|
|
|
<h2 align="center">更新走势</h2>
|
2021-12-30 12:53:18 +08:00
|
|
|
|
|
2022-01-26 08:07:39 +08:00
|
|
|
|
- `2022-01-24` **⚡ [opencv-webcam-script v0.4 发行版](https://gitee.com/CV_Lab/opencv_webcam/releases/v0.4)正式上线**
|
|
|
|
|
- `2022-01-24` **⚡ [opencv-webcam-script v0.4 docker版](https://hub.docker.com/r/zengdockerdocker/opencv-webcam-script)正式上线**
|
|
|
|
|
- `2022-01-24` **⚡ [opencv-webcam-script v0.4.0 PyPi版](https://pypi.org/project/opencv-webcam-script/0.4.0/)正式上线**
|
2022-01-26 11:07:19 +08:00
|
|
|
|
- `2022-01-24` **⚡ [opencv-webcam-script v0.4 Jupyter版](https://gitee.com/CV_Lab/opencv_webcam/blob/master/tutorial/ows_jupyter.ipynb)正式上线**
|
2022-01-26 08:07:39 +08:00
|
|
|
|
- ⚡ [opencv-webcam-script v0.3](./v_change/v03_change.md)
|
|
|
|
|
- ⚡ [opencv-webcam-script v0.2](./v_change/v02_change.md)
|
|
|
|
|
- ⚡ [opencv-webcam-script v0.1](./v_change/v01_change.md)
|
2022-01-16 12:48:26 +08:00
|
|
|
|
|
2021-12-29 18:10:01 +08:00
|
|
|
|
|
2022-01-26 11:21:05 +08:00
|
|
|
|
<h2 align="center">项目结构</h2>
|
2022-01-23 10:24:48 +08:00
|
|
|
|
|
2022-01-23 10:23:50 +08:00
|
|
|
|
```
|
|
|
|
|
.
|
|
|
|
|
├── opencv_webcam # 项目名称
|
|
|
|
|
│ ├── utils # 工具包
|
|
|
|
|
│ │ ├── args_yaml.py # 指令管理
|
|
|
|
|
│ │ ├── compress.py # 压缩管理
|
|
|
|
|
│ │ ├── frame_opt.py # 帧保存管理
|
2022-01-24 17:33:39 +08:00
|
|
|
|
│ │ ├── hotkey.py # 热键管理
|
|
|
|
|
│ │ ├── __init__.py # 工具包初始化
|
|
|
|
|
│ │ ├── log.py # 日志管理
|
|
|
|
|
│ │ ├── ows_path.py # 保存路径管理
|
2022-01-23 10:23:50 +08:00
|
|
|
|
│ │ └── time_format.py # 时间格式化
|
|
|
|
|
│ ├── v_change # 版本变更
|
|
|
|
|
│ │ ├── v01_change.md # v0.1版本变更
|
2022-01-24 10:34:49 +08:00
|
|
|
|
│ │ ├── v02_change.md # v0.2版本变更
|
|
|
|
|
│ │ └── v03_change.md # v0.3版本变更
|
2022-01-26 11:13:58 +08:00
|
|
|
|
│ ├── tutorial # ows教程
|
|
|
|
|
│ │ ├── ows_pypi.md # ows pypi版教程
|
|
|
|
|
│ │ ├── ows_docker.md # ows docker版教程
|
|
|
|
|
│ │ └── ows_jupyter.md # ows Jupyter版教程
|
2022-01-23 10:23:50 +08:00
|
|
|
|
│ ├── codeCheck.md # 代码检查
|
|
|
|
|
│ ├── Dockerfile # docker构建文件
|
|
|
|
|
│ ├── __init__.py # 项目初始化
|
|
|
|
|
│ ├── LICENSE # 项目许可
|
|
|
|
|
│ ├── opencv_webcam.py # 脚本主运行文件
|
|
|
|
|
│ ├── README.md # 项目说明
|
2022-01-26 16:40:40 +08:00
|
|
|
|
│ └── requirements.txt # 脚本依赖包
|
2022-01-23 10:23:50 +08:00
|
|
|
|
```
|
|
|
|
|
|
2022-01-26 11:21:05 +08:00
|
|
|
|
<h2 align="center">安装教程</h2>
|
2021-12-29 18:10:01 +08:00
|
|
|
|
|
2022-01-26 11:16:57 +08:00
|
|
|
|
### ✅ 方法一:Linux Shell安装(开发版)
|
2021-12-29 16:47:23 +08:00
|
|
|
|
|
2022-01-16 17:14:22 +08:00
|
|
|
|
- 第一步:克隆项目
|
|
|
|
|
|
|
|
|
|
```shell
|
|
|
|
|
git clone https://gitee.com/CV_Lab/opencv_webcam.git # 克隆项目
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
- 第二步:创建虚拟环境
|
|
|
|
|
|
2021-12-29 16:47:23 +08:00
|
|
|
|
```shell
|
|
|
|
|
# 创建conda虚拟环境,以python 3.8为例
|
2022-01-23 21:45:26 +08:00
|
|
|
|
conda create -n ows python==3.8 # 虚拟环境名称为ows
|
|
|
|
|
conda activate ows # 激活虚拟环境
|
2022-01-16 17:14:22 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
- 第三步:安装脚本
|
|
|
|
|
|
|
|
|
|
```shell
|
2021-12-29 16:47:23 +08:00
|
|
|
|
pip install -r ./requirements.txt -U # 安装OpenCV Webcam脚本
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-01-26 11:16:57 +08:00
|
|
|
|
### ✅ 方法二:pip 快速安装(PyPi版)
|
2022-01-26 09:14:50 +08:00
|
|
|
|
|
2022-01-26 11:16:57 +08:00
|
|
|
|
#### 🔥 [opencv-webcam-script PyPi版 详细教程](./tutorial/ows_pypi.md)
|
2021-12-29 16:47:23 +08:00
|
|
|
|
|
2022-01-26 11:16:57 +08:00
|
|
|
|
#### 🔑 简易教程
|
2022-01-26 09:31:15 +08:00
|
|
|
|
|
2022-01-23 21:45:26 +08:00
|
|
|
|
- 第一步:创建ows虚拟环境,参见方法一
|
2021-12-29 19:56:07 +08:00
|
|
|
|
- 第二步:执行pip指令
|
|
|
|
|
|
|
|
|
|
```shell
|
2022-01-24 10:50:30 +08:00
|
|
|
|
pip install opencv-webcam-script==0.4.0
|
2021-12-29 19:56:07 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
- 第三步:编写python程序
|
|
|
|
|
|
|
|
|
|
```python
|
|
|
|
|
from opencv_webcam.opencv_webcam import webcam_opencv
|
2022-01-26 08:52:42 +08:00
|
|
|
|
# 例举几个功能
|
2022-01-06 21:33:05 +08:00
|
|
|
|
webcam_opencv() # 常规调用
|
|
|
|
|
webcam_opencv(is_autoSaveFrame=True) # 自动保存帧
|
2022-01-24 08:08:00 +08:00
|
|
|
|
webcam_opencv(is_autoSaveFrame=True, is_compress=True) # 压缩帧
|
2021-12-29 16:47:23 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
2021-12-31 23:38:11 +08:00
|
|
|
|
|
2022-01-26 11:16:57 +08:00
|
|
|
|
### ✅ 方法三:docker 镜像安装(docker版)
|
2021-12-31 23:38:11 +08:00
|
|
|
|
|
2022-01-26 11:16:57 +08:00
|
|
|
|
#### 🔥 [opencv-webcam-script docker版 详细教程](./tutorial/ows_docker.md)
|
2022-01-26 09:16:10 +08:00
|
|
|
|
|
2022-01-26 11:16:57 +08:00
|
|
|
|
#### 🔑 简易教程
|
2022-01-26 09:31:15 +08:00
|
|
|
|
|
2022-01-16 17:14:22 +08:00
|
|
|
|
- 第一步:下载镜像
|
|
|
|
|
|
2021-12-31 23:38:11 +08:00
|
|
|
|
```shell
|
2022-01-24 16:19:40 +08:00
|
|
|
|
sudo docker pull zengdockerdocker/opencv-webcam-script:v0.4 # 镜像拉取
|
2022-01-16 17:14:22 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
- 第二步:创建容器
|
2021-12-31 23:54:16 +08:00
|
|
|
|
|
2022-01-16 17:14:22 +08:00
|
|
|
|
```shell
|
2022-01-23 20:11:17 +08:00
|
|
|
|
xhost +local:root # 允许root用户访问正在运行的X服务器(重要)
|
2022-01-24 16:19:40 +08:00
|
|
|
|
sudo docker run --name=ows --ipc=host -it -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=unix$DISPLAY --device=/dev/video0:/dev/video0 zengdockerdocker/opencv-webcam-script:v0.4 # 创建名称为ows的容器
|
2021-12-31 23:38:11 +08:00
|
|
|
|
```
|
|
|
|
|
|
2022-01-16 17:14:22 +08:00
|
|
|
|
- 第三步:运行程序
|
2021-12-31 23:38:11 +08:00
|
|
|
|
|
2022-01-16 17:14:22 +08:00
|
|
|
|
```shell
|
|
|
|
|
python3 opencv_webcam.py # 运行脚本程序
|
|
|
|
|
python3 opencv_webcam.py -isasf # 自动保存帧
|
2022-01-24 07:41:31 +08:00
|
|
|
|
|
|
|
|
|
# 获取docker帧数据到本机
|
2022-01-23 21:45:26 +08:00
|
|
|
|
sudo docker cp 容器名称:容器目录 本机宿主目录
|
|
|
|
|
sudo docker cp ows:/usr/src/app/WebcamFrame /home/用户名 # 举例
|
2022-01-16 17:14:22 +08:00
|
|
|
|
```
|
2022-01-04 13:30:22 +08:00
|
|
|
|
|
2022-01-26 11:16:57 +08:00
|
|
|
|
### ✅ 方法四:Jupyter 安装(Jupyter版)
|
2022-01-26 10:56:03 +08:00
|
|
|
|
|
2022-01-26 11:16:57 +08:00
|
|
|
|
#### 🔥 [opencv-webcam-script Jupyter版 详细教程](./tutorial/ows_jupyter.ipynb)
|
2022-01-26 10:56:03 +08:00
|
|
|
|
|
2022-01-26 11:16:57 +08:00
|
|
|
|
#### 🔑 简易教程
|
2022-01-26 10:56:03 +08:00
|
|
|
|
|
|
|
|
|
- 第一步:安装
|
|
|
|
|
|
|
|
|
|
```shell
|
|
|
|
|
# 首先手动创建虚拟环境
|
|
|
|
|
# conda create -n ows python==3.8 # 虚拟环境名称为ows
|
|
|
|
|
# conda activate ows # 激活虚拟环境
|
|
|
|
|
!git clone https://gitee.com/CV_Lab/opencv_webcam.git # 克隆
|
|
|
|
|
%cd opencv_webcam
|
|
|
|
|
%pip install -qr requirements.txt -U # 安装
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
- 第二步:运行
|
|
|
|
|
|
|
|
|
|
```shell
|
|
|
|
|
!python opencv_webcam.py # 默认按q键退出
|
|
|
|
|
!python opencv_webcam.py -isasf # 视频帧自动保存
|
|
|
|
|
```
|
|
|
|
|
|
2022-01-26 10:57:56 +08:00
|
|
|
|
**注:Jupyter版ows程序通过`Ctrl+Enter` 即可运行单元指令**
|
2022-01-26 10:56:03 +08:00
|
|
|
|
|
2022-01-26 11:21:05 +08:00
|
|
|
|
<h2 align="center">使用教程</h2>
|
2021-12-29 10:51:27 +08:00
|
|
|
|
|
2022-01-26 08:04:48 +08:00
|
|
|
|
#### 💡 常规调用
|
2021-12-29 10:51:27 +08:00
|
|
|
|
|
|
|
|
|
```shell
|
|
|
|
|
# 默认按q键退出
|
2021-12-29 18:39:29 +08:00
|
|
|
|
python opencv_webcam.py
|
2021-12-29 10:51:27 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-01-26 08:04:48 +08:00
|
|
|
|
#### 💡 设备选择
|
2021-12-31 17:13:04 +08:00
|
|
|
|
|
|
|
|
|
```shell
|
2022-01-08 10:07:42 +08:00
|
|
|
|
# 多摄像头切换示例,默认为0
|
|
|
|
|
python opencv_webcam.py -dev 0
|
2021-12-31 17:13:04 +08:00
|
|
|
|
python opencv_webcam.py -dev 1
|
|
|
|
|
python opencv_webcam.py -dev 2
|
2022-01-08 10:07:42 +08:00
|
|
|
|
# RTSP
|
|
|
|
|
python opencv_webcam.py -dev rtsp://username:password@xxx.xxx.xxx
|
2021-12-31 17:13:04 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-01-26 08:04:48 +08:00
|
|
|
|
#### 💡 设置退出键
|
2021-12-29 10:51:27 +08:00
|
|
|
|
|
|
|
|
|
```shell
|
|
|
|
|
# 默认按q键退出
|
2022-01-16 12:38:05 +08:00
|
|
|
|
python opencv_webcam.py -q z # 设置z键退出
|
|
|
|
|
python opencv_webcam.py -q k # 设置k键退出
|
2021-12-29 10:51:27 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-01-26 08:04:48 +08:00
|
|
|
|
#### 💡 自动保存帧
|
2021-12-29 10:51:27 +08:00
|
|
|
|
|
|
|
|
|
```shell
|
2021-12-29 18:39:29 +08:00
|
|
|
|
python opencv_webcam.py -isasf
|
2021-12-29 10:51:27 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-01-26 08:04:48 +08:00
|
|
|
|
#### 💡 每隔n帧保存一次帧
|
2021-12-29 10:51:27 +08:00
|
|
|
|
|
|
|
|
|
```shell
|
|
|
|
|
# 每隔10帧保存一次帧
|
2021-12-29 18:39:29 +08:00
|
|
|
|
python opencv_webcam.py -isasf -fns 10
|
2021-12-29 10:51:27 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-01-26 08:04:48 +08:00
|
|
|
|
#### 💡 手动保存帧
|
2021-12-29 10:51:27 +08:00
|
|
|
|
|
|
|
|
|
```shell
|
|
|
|
|
# 默认按a键捕获一帧
|
2021-12-29 18:39:29 +08:00
|
|
|
|
python opencv_webcam.py -ishsf
|
2021-12-29 10:51:27 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-01-26 08:04:48 +08:00
|
|
|
|
#### 💡 自定义捕获键
|
2021-12-29 10:51:27 +08:00
|
|
|
|
|
|
|
|
|
```shell
|
2022-01-16 12:38:05 +08:00
|
|
|
|
# 设置z键为捕获键,默认为a键
|
2021-12-29 18:39:29 +08:00
|
|
|
|
python opencv_webcam.py -ishsf -fck z
|
2021-12-29 10:51:27 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-01-26 08:04:48 +08:00
|
|
|
|
#### 💡 重塑帧尺寸(自定义宽高)
|
2021-12-29 10:51:27 +08:00
|
|
|
|
|
|
|
|
|
```shell
|
|
|
|
|
# 重塑宽度300 高度200
|
2022-01-16 12:38:05 +08:00
|
|
|
|
python opencv_webcam.py -isasf -isrf -rf 300 200 # 自动版
|
|
|
|
|
python opencv_webcam.py -ishsf -isrf -rf 300 200 # 手动版
|
2021-12-29 10:51:27 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-01-26 08:04:48 +08:00
|
|
|
|
#### 💡 重塑帧尺寸(自定义宽高缩放比)
|
2021-12-29 10:51:27 +08:00
|
|
|
|
|
|
|
|
|
```shell
|
|
|
|
|
# 宽高缩放比为0.5
|
2022-01-16 12:38:05 +08:00
|
|
|
|
python opencv_webcam.py -isasf -isrf -rrf 0.5 # 自动版
|
|
|
|
|
python opencv_webcam.py -ishsf -isrf -rrf 0.5 # 手动版
|
2021-12-29 10:51:27 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-01-26 08:04:48 +08:00
|
|
|
|
#### 💡 自定义保存路径
|
2021-12-29 10:51:27 +08:00
|
|
|
|
|
|
|
|
|
```shell
|
|
|
|
|
# 设置保存路径,默认保存路径为./WebcamFrame
|
2021-12-29 18:39:29 +08:00
|
|
|
|
python opencv_webcam.py -fsd custom_dir -isasf # 以自动版为例
|
2021-12-29 10:51:27 +08:00
|
|
|
|
```
|
|
|
|
|
|
2022-01-02 14:38:46 +08:00
|
|
|
|
|
|
|
|
|
|
2022-01-26 08:04:48 +08:00
|
|
|
|
#### 💡 自定义帧目录名称
|
2022-01-08 10:07:42 +08:00
|
|
|
|
|
|
|
|
|
```shell
|
|
|
|
|
# 设置帧目录名称,默认保存路径为frames
|
|
|
|
|
python opencv_webcam.py -fdn frames_custom -isasf # 以自动版为例
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-01-26 08:04:48 +08:00
|
|
|
|
#### 💡 自定义帧名前缀
|
2022-01-05 16:44:24 +08:00
|
|
|
|
|
|
|
|
|
```shell
|
2022-01-05 22:06:00 +08:00
|
|
|
|
# 设置帧图片的前缀名称
|
2022-01-05 16:44:24 +08:00
|
|
|
|
python opencv_webcam.py -isasf -fnp webcam
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-01-26 08:04:48 +08:00
|
|
|
|
#### 💡 设置帧保存格式
|
2022-01-05 16:44:24 +08:00
|
|
|
|
|
|
|
|
|
```shell
|
2022-01-05 22:06:00 +08:00
|
|
|
|
# 设置JPG质量为100,默认为95
|
2022-01-05 16:44:24 +08:00
|
|
|
|
python opencv_webcam.py -isasf -fss jpg -jq 100
|
2022-01-05 22:06:00 +08:00
|
|
|
|
# 设置PNG质量为5,默认为3
|
2022-01-05 16:44:24 +08:00
|
|
|
|
python opencv_webcam.py -isasf -fss png -jq 5
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-01-26 08:04:48 +08:00
|
|
|
|
#### 💡 设置暂停键
|
2022-01-05 16:44:24 +08:00
|
|
|
|
|
|
|
|
|
```shell
|
2022-01-16 12:38:05 +08:00
|
|
|
|
# 设置w键为暂停键,默认为p键
|
|
|
|
|
python opencv_webcam.py -p w # 按任意键继续
|
2022-01-05 16:44:24 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-01-26 08:04:48 +08:00
|
|
|
|
#### 💡 设置保存帧数
|
2022-01-05 16:44:24 +08:00
|
|
|
|
|
|
|
|
|
```shell
|
2022-01-05 22:06:00 +08:00
|
|
|
|
# 设置保存100帧
|
2022-01-05 16:44:24 +08:00
|
|
|
|
python opencv_webcam.py -isasf -afn 100
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-01-26 08:04:48 +08:00
|
|
|
|
#### 💡 日志设置
|
2022-01-15 19:48:28 +08:00
|
|
|
|
|
|
|
|
|
```shell
|
2022-01-26 10:35:03 +08:00
|
|
|
|
# 日志文件默认保存在项目根目录,ows.log
|
2022-01-15 19:48:28 +08:00
|
|
|
|
python opencv_webcam.py
|
|
|
|
|
# 设置日志文件名称及类型,类型包括.log、.txt、.data
|
2022-01-26 10:35:03 +08:00
|
|
|
|
python opencv_webcam.py -ln ows02.txt
|
2022-01-15 19:48:28 +08:00
|
|
|
|
# 设置日志保存方式,,默认为追加模式
|
|
|
|
|
python opencv_webcam.py -lm w # 设置为覆盖模式
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-01-26 08:04:48 +08:00
|
|
|
|
#### 💡 视频帧压缩
|
2022-01-19 09:35:53 +08:00
|
|
|
|
|
|
|
|
|
```shell
|
2022-01-26 10:35:03 +08:00
|
|
|
|
# 常规压缩,默认ows.zip(以自动版为例)
|
2022-01-19 17:39:36 +08:00
|
|
|
|
python opencv_webcam.py -isasf -isc
|
2022-01-19 09:35:53 +08:00
|
|
|
|
# 自定义压缩文件名称
|
2022-01-26 10:35:03 +08:00
|
|
|
|
python opencv_webcam.py -isasf -isc -cn ows02
|
2022-01-19 09:35:53 +08:00
|
|
|
|
# 自动命名压缩文件
|
2022-01-20 08:46:04 +08:00
|
|
|
|
python opencv_webcam.py -isasf -isc -isacn
|
2022-01-19 10:10:55 +08:00
|
|
|
|
# 自定义压缩模式,默认为写覆盖
|
2022-01-25 21:07:33 +08:00
|
|
|
|
python opencv_webcam.py -isasf -isc -cm a # 追加模式(a模式仅限zip) 注:该指令仅限v0.4
|
2022-01-20 08:46:04 +08:00
|
|
|
|
python opencv_webcam.py -isasf -isc -cs tar -cm w:gz # tar压缩
|
2022-01-19 09:35:53 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-01-26 08:04:48 +08:00
|
|
|
|
#### 💡 指令查询
|
2022-01-02 14:38:46 +08:00
|
|
|
|
|
|
|
|
|
```shell
|
2022-01-05 22:06:00 +08:00
|
|
|
|
# 查询脚本参数
|
2022-01-02 15:46:29 +08:00
|
|
|
|
python opencv_webcam.py --help
|
2022-01-02 14:38:46 +08:00
|
|
|
|
```
|
|
|
|
|
|
2022-01-03 14:11:44 +08:00
|
|
|
|
<details open>
|
|
|
|
|
<summary>指令查询结果</summary>
|
|
|
|
|
|
2022-01-02 14:38:46 +08:00
|
|
|
|
```shell
|
2022-01-20 09:15:12 +08:00
|
|
|
|
usage: opencv_webcam.py [-h] [--device DEVICE] [--quit QUIT] [--is_autoSaveFrame] [--is_handSaveFrame] [--is_resizeFrame] [--frame_saveDir FRAME_SAVEDIR] [--frame_dirName FRAME_DIRNAME]
|
|
|
|
|
[--frame_nSave FRAME_NSAVE] [--frame_capKey FRAME_CAPKEY] [--resize_frame RESIZE_FRAME [RESIZE_FRAME ...]] [--resizeRatio_frame RESIZERATIO_FRAME]
|
|
|
|
|
[--frame_namePrefix FRAME_NAMEPREFIX] [--frame_saveStyle FRAME_SAVESTYLE] [--jpg_quality JPG_QUALITY] [--png_quality PNG_QUALITY] [--pause PAUSE]
|
|
|
|
|
[--auto_frameNum AUTO_FRAMENUM] [--logName LOGNAME] [--logMode LOGMODE] [--is_compress] [--compressStyle COMPRESSSTYLE] [--is_autoCompressName]
|
|
|
|
|
[--compressName COMPRESSNAME] [--compressMode COMPRESSMODE]
|
2022-01-02 14:38:46 +08:00
|
|
|
|
|
2022-01-20 09:15:12 +08:00
|
|
|
|
OpenCV Webcam Script v0.4
|
2022-01-02 14:38:46 +08:00
|
|
|
|
|
|
|
|
|
optional arguments:
|
|
|
|
|
-h, --help show this help message and exit
|
|
|
|
|
--device DEVICE, -dev DEVICE
|
2022-01-15 19:48:28 +08:00
|
|
|
|
device index for webcam, 0 or rtsp
|
2022-01-02 14:38:46 +08:00
|
|
|
|
--quit QUIT, -q QUIT quit key for webcam
|
|
|
|
|
--is_autoSaveFrame, -isasf
|
|
|
|
|
is auto save frame
|
2022-01-03 14:00:56 +08:00
|
|
|
|
--is_handSaveFrame, -ishsf
|
|
|
|
|
is hand save frame
|
2022-01-02 14:38:46 +08:00
|
|
|
|
--is_resizeFrame, -isrf
|
|
|
|
|
is resize frame
|
|
|
|
|
--frame_saveDir FRAME_SAVEDIR, -fsd FRAME_SAVEDIR
|
|
|
|
|
save frame dir
|
2022-01-15 19:48:28 +08:00
|
|
|
|
--frame_dirName FRAME_DIRNAME, -fdn FRAME_DIRNAME
|
|
|
|
|
save frame dir name
|
2022-01-02 14:38:46 +08:00
|
|
|
|
--frame_nSave FRAME_NSAVE, -fns FRAME_NSAVE
|
|
|
|
|
n frames save a frame (auto save frame)
|
|
|
|
|
--frame_capKey FRAME_CAPKEY, -fck FRAME_CAPKEY
|
2022-01-03 14:00:56 +08:00
|
|
|
|
frame capture key (hand save frame)
|
2022-01-02 14:38:46 +08:00
|
|
|
|
--resize_frame RESIZE_FRAME [RESIZE_FRAME ...], -rf RESIZE_FRAME [RESIZE_FRAME ...]
|
|
|
|
|
resize frame save
|
|
|
|
|
--resizeRatio_frame RESIZERATIO_FRAME, -rrf RESIZERATIO_FRAME
|
|
|
|
|
resize ratio frame save
|
2022-01-02 15:46:29 +08:00
|
|
|
|
--frame_namePrefix FRAME_NAMEPREFIX, -fnp FRAME_NAMEPREFIX
|
|
|
|
|
frame name prefix
|
|
|
|
|
--frame_saveStyle FRAME_SAVESTYLE, -fss FRAME_SAVESTYLE
|
|
|
|
|
frame save style
|
|
|
|
|
--jpg_quality JPG_QUALITY, -jq JPG_QUALITY
|
|
|
|
|
frame save jpg quality (0-100) default 95
|
|
|
|
|
--png_quality PNG_QUALITY, -pq PNG_QUALITY
|
|
|
|
|
frame save jpg quality (0-9) default 3
|
2022-01-03 14:00:56 +08:00
|
|
|
|
--pause PAUSE, -p PAUSE
|
|
|
|
|
webcam pause
|
2022-01-04 13:30:22 +08:00
|
|
|
|
--auto_frameNum AUTO_FRAMENUM, -afn AUTO_FRAMENUM
|
|
|
|
|
auto save number of frames
|
2022-01-15 19:48:28 +08:00
|
|
|
|
--logName LOGNAME, -ln LOGNAME
|
2022-01-20 09:15:12 +08:00
|
|
|
|
log save name
|
2022-01-15 19:48:28 +08:00
|
|
|
|
--logMode LOGMODE, -lm LOGMODE
|
2022-01-20 09:15:12 +08:00
|
|
|
|
log write mode
|
|
|
|
|
--is_compress, -isc is compress file
|
|
|
|
|
--compressStyle COMPRESSSTYLE, -cs COMPRESSSTYLE
|
|
|
|
|
compress style
|
|
|
|
|
--is_autoCompressName, -isacn
|
|
|
|
|
is auto compress name
|
|
|
|
|
--compressName COMPRESSNAME, -cn COMPRESSNAME
|
|
|
|
|
compress save name
|
|
|
|
|
--compressMode COMPRESSMODE, -cm COMPRESSMODE
|
|
|
|
|
compress save mode, tar w:gz
|
2022-01-02 14:38:46 +08:00
|
|
|
|
```
|
|
|
|
|
|
2022-01-03 14:11:44 +08:00
|
|
|
|
</details>
|