v06 fix time format
This commit is contained in:
parent
80e2dabe84
commit
1d8195543f
|
@ -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",
|
||||
|
|
|
@ -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)}')
|
||||
|
|
|
@ -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'时间格式化失败!程序结束!')
|
||||
|
|
Loading…
Reference in New Issue