v05 plot update

This commit is contained in:
13339479676 2022-01-28 16:45:53 +08:00
parent 0c14b3c8d3
commit 94135e6d7f
3 changed files with 20 additions and 6 deletions

View File

@ -191,6 +191,8 @@ def webcam_opencv(device_index="0",
print(frameSaveMsg)
log_management(f'{frameSaveMsg}\n', logName, logMode) # 记录帧保存信息
date_time_frames(logTime, frame_hand_num)
else:
date_time_frames(logTime, 0) # 记录非帧保存状态
cap.release() # 释放缓存资源
cv2.destroyAllWindows() # 删除所有窗口
@ -213,9 +215,9 @@ def webcam_opencv(device_index="0",
log_management(f'{compress_msg}\n', logName, logMode) # 记录用时
# ------------------创建chart------------------
is_fonts(f'{ROOT_PATH}/fonts')
date_list, time_list, y = csv2list("./date_time_frames.csv")
createLineChart(y, date_list, time_list)
is_fonts(f'{ROOT_PATH}/fonts') # 检查字体文件
date_list, time_list, y = csv2list("./date_time_frames.csv") # 转换日期-帧数文件
createLineChart(y, date_list, time_list) # 创建日期-帧数图

View File

@ -5,6 +5,7 @@
import matplotlib.pyplot as plt
from matplotlib import font_manager
from matplotlib.ticker import MaxNLocator
import sys
import csv
@ -30,6 +31,16 @@ def createLineChart(frames_y, date_list, time_list):
plt.plot(time_list, frames_y, color=color_list[0], marker='o',
label='时间点', markerfacecolor=color_list[0], markersize=5)
# 纵坐标限定
plt.ylim(ymin=0)
plt.gca().yaxis.set_major_locator(MaxNLocator(integer=True)) # 纵坐标设置为整数
plt.grid(axis="y", ls='--') # 横向网格线
# 设置上边和右边无边框
ax = plt.gca()
ax.spines['right'].set_color('none')
ax.spines['top'].set_color('none')
# 标签
for a, b in zip(time_list, frames_y):
plt.text(a, b, b, ha='center', va='bottom', fontsize=10.5)
@ -45,8 +56,9 @@ def createLineChart(frames_y, date_list, time_list):
plt.yticks(fontproperties=TimesNesRoman, fontsize=12) # 纵轴刻度
plt.legend(prop=SimSun, fontsize=12, loc='best') # 图例
plt.savefig(f'{ROOT_PATH}/chart.png', dpi=300, bbox_inches='tight') # 保存图像
print(f'Chart保存成功')
# 保存图像
plt.savefig(f'{ROOT_PATH}/chart.png', dpi=300, bbox_inches='tight')
print(f'Chart已保存在{ROOT_PATH}/chart.png')
# csv2list

2
v05.md
View File

@ -11,7 +11,7 @@
- 加入opencv-webcam-script PyPi版 详细教程文件
- 加入bash安装脚本
- 加入字体管理模块
- 加入日志可视化
- 加入日期-帧数图,统计各个时间段保存的帧数情况