v05 log update 03

This commit is contained in:
13339479676 2022-01-28 10:24:42 +08:00
parent 7d1297599b
commit 1bb1054651
4 changed files with 27 additions and 11 deletions

2
.gitignore vendored
View File

@ -10,9 +10,9 @@ __pycache__
# 日志格式
*.log
*.csv
*.data
*.txt
*.csv
*.yaml
*.json

View File

@ -16,6 +16,7 @@ from utils.log import is_logSuffix, log_management
from utils.args_yaml import argsYaml
from utils.compress import webcam_compress, is_compressFile
from utils.time_format import time_format
from utils.log import date_time_frames
ROOT_PATH = sys.path[0] # 项目根目录
@ -145,6 +146,7 @@ def webcam_opencv(device_index="0",
frame_num = 0 # 总帧数
frame_hand_num = 0 # 手动保存帧数
frame_n_num = 0 # 每隔n帧保存一次
while(is_capOpened):
wait_key = cv2.waitKey(20) & 0xFF # 键盘监听
_, frame = cap.read() # 捕获画面
@ -158,6 +160,7 @@ def webcam_opencv(device_index="0",
frame_num -= 1 # 修复帧数显示问题
break
if (frame_num % frame_nSave == 0): # 每隔n帧保存一次
frame_n_num += 1
frame_opt(frame, frame_savePath, frame_num, is_resizeFrame, resize_frame, resizeRatio_frame,
frame_namePrefix, frame_saveStyle, jpg_quality, png_quality)
elif (is_handSaveFrame): # 手动保存
@ -174,14 +177,18 @@ def webcam_opencv(device_index="0",
if (is_autoSaveFrame):
# 帧保存信息(自动版)
if (frame_n_num != 0):
frame_num = frame_n_num # 每隔n帧保存一次
frameSaveMsg = f'自动版:共计{frame_num}帧,已保存在:{frame_savePath}'
print(frameSaveMsg)
log_management(f'{frameSaveMsg}\n', logName, logMode) # 记录帧保存信息
date_time_frames(logTime, frame_num)
elif (is_handSaveFrame):
# 帧保存信息(手动版)
frameSaveMsg = f'手动版:共计{frame_hand_num}帧,已保存在:{frame_savePath}'
print(frameSaveMsg)
log_management(f'{frameSaveMsg}\n', logName, logMode) # 记录帧保存信息
date_time_frames(logTime, frame_hand_num)
cap.release() # 释放缓存资源
cv2.destroyAllWindows() # 删除所有窗口

View File

@ -24,17 +24,25 @@ def log_management(logContent, logName, logSaveMode):
logFile.write(logContent) # 日志写入
# 日期时间&帧数
def date_time_frames(date_time, frames):
f = open(f'{ROOT_PATH}/date_time_frames.csv', 'a')
f.write(f'{date_time},{frames}\n')
# print(f'csv保存成功')
# 日志读取时间和帧数
def log2date_frames(log_path="../ows.log"):
f = open(log_path, 'r') # 读取日志
f_list = f.read().split('\n')[:-1] # 转换成列表
# def log2date_frames(log_path="../ows.log"):
# f = open(log_path, 'r') # 读取日志
# f_list = f.read().split('\n')[:-1] # 转换成列表
for i in range(len(f_list)):
mat = re.search(
r"(\d{4}-\d{1,2}-\d{1,2}\s\d{1,2}:\d{1,2}:\d{1,2})", f_list[i])
if (mat != None):
print(f'{i, f_list[i]}')
# for i in range(len(f_list)):
# mat = re.search(
# r"(\d{4}-\d{1,2}-\d{1,2}\s\d{1,2}:\d{1,2}:\d{1,2})", f_list[i])
# if (mat != None):
# print(f'{i, f_list[i]}')
if __name__ == '__main__':
log2date_frames()
# if __name__ == '__main__':
# log2date_frames()

View File

@ -38,6 +38,7 @@ def createLineChart(frames_y, today):
for a, b in zip(today_time, frames_y):
plt.text(a, b, b, ha='center', va='bottom', fontsize=10.5)
# -----------标题、横纵轴、图例等-----------
plt.title(OWS_VERSION, fontsize=12, fontproperties=TimesNesRoman) # 标题
plt.xlabel(today_date[0], fontsize=12,