readme v04 zip update

This commit is contained in:
13339479676 2022-01-19 09:35:53 +08:00
parent 4ce6161761
commit d2e9293edf
4 changed files with 27 additions and 4 deletions

View File

@ -259,6 +259,19 @@ python opencv_webcam.py -lm w # 设置为覆盖模式
#### :bulb: 视频帧压缩
```shell
# 常规压缩默认test.zip以自动版为例
python opencv_webcam.py -isasf -ic
# 自定义压缩文件名称
python opencv_webcam.py -isasf -ic -zn test02.zip
# 自动命名压缩文件
python opencv_webcam.py -isasf -ic -isazn
```
#### :bulb: 指令查询

View File

@ -65,6 +65,8 @@ def parse_args(known=False):
# 压缩
parser.add_argument('--is_compress', '-ic',
action='store_true', help='is compress file')
parser.add_argument('--is_autoZipName', '-isazn',
action='store_true', help='is auto zip name')
parser.add_argument('--zipName', '-zn',
default="test.zip", type=str, help='zip save name')
args = parser.parse_known_args()[0] if known else parser.parse_args()
@ -92,6 +94,7 @@ def webcam_opencv(device_index="0",
logName="test.log",
logMode="a",
is_compress=False,
is_autoZipName=False,
zipName="test.zip"):
keyList = [quit_key, frame_capKey, pause_key] # 快捷键列表
@ -186,7 +189,7 @@ def webcam_opencv(device_index="0",
# ------------------压缩文件------------------
if (is_compress):
webcam_zip(f'{ROOT_PATH}/{zipName}', frame_savePath) # 自定义压缩文件名称
webcam_zip(is_autoZipName, f'{ROOT_PATH}/{zipName}', frame_savePath) # 自定义压缩文件名称
def main(args):
@ -214,6 +217,7 @@ def main(args):
# 压缩
is_compress = args.is_compress
is_autoZipName = args.is_autoZipName
zipName = args.zipName
argsYaml(args) # 脚本参数
@ -239,6 +243,7 @@ def main(args):
logName,
logMode,
is_compress,
is_autoZipName,
zipName)

View File

@ -18,10 +18,14 @@ def is_zipFile(zipName):
# zip压缩
def webcam_zip(zipName, preZipFilePath):
is_zipFile(zipName)
def webcam_zip(is_autoZipName, zipName, preZipFilePath):
if (is_autoZipName):
auto_zipName = str(preZipFilePath).split('/')[-1]
zip_file = zipfile.ZipFile(f'{auto_zipName}.zip', 'a')
zip_file = zipfile.ZipFile(zipName, 'a')
else:
is_zipFile(zipName)
zip_file = zipfile.ZipFile(zipName, 'a')
# ----------压缩开始----------
file_list = os.listdir(preZipFilePath)

1
v04.md
View File

@ -10,6 +10,7 @@
- 加入docker vim编辑器
- 加入视频帧压缩功能
- 加入自定义压缩文件名称
- 加入自动命名压缩文件名称
### BUG修复