v06 fix time format

This commit is contained in:
13339479676 2022-02-10 19:04:10 +08:00
parent 80e2dabe84
commit 1d8195543f
4 changed files with 24 additions and 9 deletions

View File

@ -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",

View File

@ -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)}')

View File

@ -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'时间格式化失败!程序结束!')

12
v06.md Normal file
View File

@ -0,0 +1,12 @@
# OpenCV Webcam Script v0.6
## 创建人:曾逸夫
### 💡 功能更新
### 🔧 BUG修复
- 修复时间格式化以天为单位的计算