从安卓log中抓取想要的内容

import numpy as np
import os
import matplotlib.pyplot as plt

dir = "..\\noise\\3.15\\"
lFile = os.listdir(dir)

def LoadData(path):
    f = open(path)
    center = []
    LeftUp = []
    LeftDown = []
    RightUp = []
    RightDown = []
    for str in f.readlines():
        if str.find('FN:0314Depth center') != -1:
            list = str.split()
            if list[-1] != '0':
                center.append(list[-1])
        if str.find('FN:0314Depth LeftUp') != -1:
            list = str.split()
            if list[-1] != '0':
                LeftUp.append(list[-1])
        if str.find('FN:0314Depth LeftDown') != -1:
            list = str.split()
            if list[-1] != '0':
                LeftDown.append(list[-1])
        if str.find('FN:0314Depth RightUp') != -1:
            list = str.split()
            if list[-1] != '0':
                RightUp.append(list[-1])
        if str.find('FN:0314Depth RightDown') != -1:
            list = str.split()
            if list[-1] != '0':
                RightDown.append(list[-1])
    f.close()
    return  center, LeftUp, LeftDown, RightUp, RightDown

if __name__ == '__main__':
    for FileName in lFile:
        print (FileName)
        path = os.path.join(dir, FileName)
        lcenter, lLeftUp, lLeftDown, lRightUp, lRightDown = LoadData(path)
        arrCenter = np.array(lcenter,dtype='float32')
        arrLeftUp = np.array(lLeftUp, dtype='float32')
        arrLeftDown = np.array(lLeftDown, dtype='float32')
        arrRightUp = np.array(lRightUp, dtype='float32')
        arrRightDown = np.array(lRightDown, dtype='float32')

        print ("center std , per, aver : ", arrCenter.std(), arrCenter.std()/np.average(arrCenter)*100, np.average(arrCenter))
        print("LeftUp std , per, aver  : ", arrLeftUp.std(), arrLeftUp.std()/np.average(arrLeftUp)*100, np.average(arrLeftUp))
        print("LeftDown std , per, aver  : ", arrLeftDown.std(), arrLeftDown.std()/np.average(arrLeftDown)*100, np.average(arrLeftDown))
        print("RightUp std , per, aver  : ", arrRightUp.std(), arrRightUp.std()/np.average(arrRightUp)*100, np.average(arrRightUp))
        print("RightDown std , per, aver  : ", arrRightDown.std(), arrRightDown.std()/np.average(arrRightDown)*100, np.average(arrRightDown))

log样式

02-25 11:23:49.557  2618  3175 E PreProcess: Fn:ComputeRealDepthByMap 0.193125 
02-25 11:23:49.557  2618  3175 E PreProcess: Fn:2-box_filter 0.000209 
02-25 11:23:49.557  2618  3175 E PreProcess: Fn:edgeSmoothing 0.000365 
02-25 11:23:49.557  2618  3175 E PreProcess: FN:0314Depth center 1980
02-25 11:23:49.557  2618  3175 E PreProcess: FN:0314Depth LeftUp 2070
02-25 11:23:49.557  2618  3175 E PreProcess: FN:0314Depth LeftDown 1762
02-25 11:23:49.557  2618  3175 E PreProcess: FN:0314Depth RightUp 2265
02-25 11:23:49.557  2618  3175 E PreProcess: FN:0314Depth RightDown 1875
02-25 11:23:49.557  2618  3175 E PreProcess: Fn:Depth 2.137239 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值