2021-12-29 10:51:27 +08:00
|
|
|
|
# :fire: OpenCV Webcam 脚本
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-12-29 18:10:01 +08:00
|
|
|
|
### :sparkles: 更新
|
|
|
|
|
|
|
|
|
|
- `2021-12-29` **OpenCV Webcam v0.1.0正式上线**
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-12-29 16:47:23 +08:00
|
|
|
|
### :zap: 安装教程
|
|
|
|
|
|
2021-12-29 17:44:09 +08:00
|
|
|
|
#### :white_check_mark: 方法一:Linux Shell版
|
2021-12-29 16:47:23 +08:00
|
|
|
|
|
|
|
|
|
```shell
|
2021-12-29 18:07:09 +08:00
|
|
|
|
# 克隆项目
|
|
|
|
|
git clone https://gitee.com/CV_Lab/opencv-webcam.git
|
2021-12-29 16:47:23 +08:00
|
|
|
|
# 创建conda虚拟环境,以python 3.8为例
|
|
|
|
|
conda create -n ow python==3.8 # 虚拟环境名称为ow
|
|
|
|
|
conda activate ow # 激活虚拟环境
|
|
|
|
|
pip install -r ./requirements.txt -U # 安装OpenCV Webcam脚本
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-12-29 18:07:09 +08:00
|
|
|
|
#### :white_check_mark: 方法二:pip 快速安装
|
2021-12-29 16:47:23 +08:00
|
|
|
|
|
|
|
|
|
```shell
|
2021-12-29 18:07:09 +08:00
|
|
|
|
# 第一步:创建ow虚拟环境,参见方法一
|
|
|
|
|
# 第二步:执行pip指令
|
2021-12-29 18:39:29 +08:00
|
|
|
|
pip install opencv_webcam
|
2021-12-29 16:47:23 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
2021-12-29 10:51:27 +08:00
|
|
|
|
|
2021-12-29 16:47:23 +08:00
|
|
|
|
### :zap: 使用教程
|
2021-12-29 10:51:27 +08:00
|
|
|
|
#### :bulb: 常规调用
|
|
|
|
|
|
|
|
|
|
```shell
|
|
|
|
|
# 默认按q键退出
|
2021-12-29 18:39:29 +08:00
|
|
|
|
python opencv_webcam.py
|
2021-12-29 10:51:27 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#### :bulb: 设置退出键
|
|
|
|
|
|
|
|
|
|
```shell
|
|
|
|
|
# 默认按q键退出
|
|
|
|
|
# 设置z键退出
|
2021-12-29 18:39:29 +08:00
|
|
|
|
python opencv_webcam.py -q z
|
2021-12-29 10:51:27 +08:00
|
|
|
|
# 设置k键退出
|
2021-12-29 18:39:29 +08:00
|
|
|
|
python opencv_webcam.py -q k
|
2021-12-29 10:51:27 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#### :bulb: 自动保存帧
|
|
|
|
|
|
|
|
|
|
```shell
|
2021-12-29 18:39:29 +08:00
|
|
|
|
python opencv_webcam.py -isasf
|
2021-12-29 10:51:27 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#### :bulb: 每隔n帧保存一次帧
|
|
|
|
|
|
|
|
|
|
```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
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#### :bulb: 手动保存帧
|
|
|
|
|
|
|
|
|
|
```shell
|
|
|
|
|
# 默认按a键捕获一帧
|
2021-12-29 18:39:29 +08:00
|
|
|
|
python opencv_webcam.py -ishsf
|
2021-12-29 10:51:27 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#### :bulb: 自定义捕获键
|
|
|
|
|
|
|
|
|
|
```shell
|
|
|
|
|
# 设置z键为捕获键
|
2021-12-29 18:39:29 +08:00
|
|
|
|
python opencv_webcam.py -ishsf -fck z
|
2021-12-29 10:51:27 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#### :bulb: 重塑帧尺寸(自定义宽高)
|
|
|
|
|
|
|
|
|
|
```shell
|
|
|
|
|
# 重塑宽度300 高度200
|
|
|
|
|
# 自动版
|
2021-12-29 18:39:29 +08:00
|
|
|
|
python opencv_webcam.py -isasf -isrf -rf 300 200
|
2021-12-29 10:51:27 +08:00
|
|
|
|
# 手动版
|
2021-12-29 18:39:29 +08:00
|
|
|
|
python opencv_webcam.py -ishsf -isrf -rf 300 200
|
2021-12-29 10:51:27 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#### :bulb: 重塑帧尺寸(自定义宽高缩放比)
|
|
|
|
|
|
|
|
|
|
```shell
|
|
|
|
|
# 宽高缩放比为0.5
|
|
|
|
|
# 自动版
|
2021-12-29 18:39:29 +08:00
|
|
|
|
python opencv_webcam.py -isasf -isrf -rrf 0.5
|
2021-12-29 10:51:27 +08:00
|
|
|
|
# 手动版
|
2021-12-29 18:39:29 +08:00
|
|
|
|
python opencv_webcam.py -ishsf -isrf -rrf 0.5
|
2021-12-29 10:51:27 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-12-29 16:47:23 +08:00
|
|
|
|
#### :bulb: 设置保存路径
|
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
|
|
|
|
```
|
|
|
|
|
|