From 1d8195543f8ac0f56ca76d5981c2afc90d5fcd01 Mon Sep 17 00:00:00 2001 From: 13339479676 Date: Thu, 10 Feb 2022 19:04:10 +0800 Subject: [PATCH] v06 fix time format --- opencv_webcam.py | 8 ++++---- utils/plot.py | 2 +- utils/time_format.py | 11 +++++++---- v06.md | 12 ++++++++++++ 4 files changed, 24 insertions(+), 9 deletions(-) create mode 100644 v06.md diff --git a/opencv_webcam.py b/opencv_webcam.py index b66a343..119a356 100644 --- a/opencv_webcam.py +++ b/opencv_webcam.py @@ -1,6 +1,6 @@ -# OpenCV Webcam Script v0.5 +# OpenCV Webcam Script v0.6 # 创建人:曾逸夫 -# 创建时间:2022-01-25 +# 创建时间:2022-02-10 import cv2 import sys @@ -20,11 +20,11 @@ from utils.fonts_opt import is_fonts ROOT_PATH = sys.path[0] # 项目根目录 -OWS_VERSION = 'OpenCV Webcam Script v0.5' # 项目名称与版本号 +OWS_VERSION = 'OpenCV Webcam Script v0.6' # 项目名称与版本号 def parse_args(known=False): - parser = argparse.ArgumentParser(description='OpenCV Webcam Script v0.5') + parser = argparse.ArgumentParser(description='OpenCV Webcam Script v0.6') parser.add_argument('--device', '-dev', default='0', type=str, help='device index for webcam, 0 or rtsp') parser.add_argument('--quit', '-q', default="q", diff --git a/utils/plot.py b/utils/plot.py index 716f1ca..756e1a1 100644 --- a/utils/plot.py +++ b/utils/plot.py @@ -67,7 +67,7 @@ def createLineChart(frames_y, date_list, time_list): plt.savefig(date_frames_chart_path, dpi=300, bbox_inches='tight') # -----------作图结束----------- - chart_endTime = time.time() # 作图开始时间 + chart_endTime = time.time() # 作图结束时间 chart_totalTime = chart_endTime - chart_startTime # 作图用时 print( f'日期-帧数图创建成功!用时:{time_format(chart_totalTime)},已保存在{date_frames_chart_path},总帧数:{sum(frames_y)}') diff --git a/utils/time_format.py b/utils/time_format.py index a9a9955..de512cb 100644 --- a/utils/time_format.py +++ b/utils/time_format.py @@ -17,8 +17,8 @@ def time_format(preTime): is_time(preTime) # 判断时间格式 m, s = divmod(preTime, 60) # 获取秒 h, m = divmod(m, 60) # 获取时、分 - h = int(h) - m = int(m) + h = int(h) # 转整型 + m = int(m) # 转整型 if (0 < s < 1): time_str = f'{s:.3f}秒' @@ -31,8 +31,11 @@ def time_format(preTime): return time_str elif (h > 0): if (h >= 24): - h = int(h / 24) - time_str = f'{h}时{m}分{s:.3f}秒' + d = int(h / 24) # 以天为单位 + h2 = h - 24 + time_str = f'{d}天{h2}时{m}分{s:.3f}秒' + else: + time_str = f'{h}时{m}分{s:.3f}秒' return time_str else: print(f'时间格式化失败!程序结束!') diff --git a/v06.md b/v06.md new file mode 100644 index 0000000..0098755 --- /dev/null +++ b/v06.md @@ -0,0 +1,12 @@ +# OpenCV Webcam Script v0.6 +## 创建人:曾逸夫 + + + +### 💡 功能更新 + + + +### 🔧 BUG修复 + +- 修复时间格式化以天为单位的计算 \ No newline at end of file