我目前正在制作一个设备,它使用MyoWare肌肉传感器收集数据,将其发送到mysql数据库,并使用matplotlib显示图形。由于这个设备是为了运动目的(在我的情况下举重),我想能够确定用户的重复次数。有谁知道或可以告诉我如何实现它?从matplotlib分析图
我的Python代码
conn = pymysql.connect(host="localhost", user="root", passwd="123456", db="XXX")
cur = conn.cursor()
query = """
SELECT CONVERT(data,SIGNED INTEGER),time FROM sensordata
"""
cur.execute(query)
data = cur.fetchall()
cur.close
cur =conn.cursor()
query1 = """
SELECT CONVERT(data1,SIGNED INTEGER),time1 FROM sensordata2
"""
cur.execute(query1)
data1= cur.fetchall()
cur.close
conn.close()
data,time= zip(*data)
data1,time1= zip(*data1)
data_moving_average = []
for initial_element_index in range(len(data)):
data_moving_average.append(sum(data[initial_element_index:initial_element_index+20])/5.)
data_moving_average1 = []
for initial_element_index in range(len(data1)):
data_moving_average1.append(sum(data1[initial_element_index:initial_element_index+20])/5.)
plt.plot(time,data_moving_average)
plt.plot(time1,data_moving_average1)
+-----+------+---------------------+----------------------------+
| id | data | time | analyzetime |
+-----+------+---------------------+----------------------------+
| 1 | 1 | 2017-06-22 08:23:09 | 2017-06-22 08:23:09.846534 |
| 2 | 0 | 2017-06-22 08:23:10 | 2017-06-22 08:23:10.048035 |
| 3 | 0 | 2017-06-22 08:23:10 | 2017-06-22 08:23:10.333497 |
| 4 | 0 | 2017-06-22 08:23:10 | 2017-06-22 08:23:10.656422 |
| 5 | 0 | 2017-06-22 08:23:10 | 2017-06-22 08:23:10.865791 |
| 6 | 0 | 2017-06-22 08:23:10 | 2017-06-22 08:23:10.954816 |
| 7 | 0 | 2017-06-22 08:23:11 | 2017-06-22 08:23:11.147128 |
| 8 | 0 | 2017-06-22 08:23:11 | 2017-06-22 08:23:11.402207 |
| 9 | 0 | 2017-06-22 08:23:11 | 2017-06-22 08:23:11.613567 |
| 10 | 0 | 2017-06-22 08:23:11 | 2017-06-22 08:23:11.867029 |
究竟红色和蓝色曲线在图形中是什么意思? –
@BatyrkhanSaduanov他们是我使用的两个传感器的个人图形 –
@BatyrkhanSaduanov但在我的情况下,现在我想专注于红色确定重复次数(4)。你有什么想法 ? –