from xml.etree import ElementTree as ET
def getSubDir(path):
dirname=list()
for file in os.listdir(path):
dirname.append(file)
return dirname
def get_xml_data(path):
xmlFileNames = getSubDir(path)
gesturePositionEndCount = 0
for xmlFileName in xmlFileNames:
if gesturePositionEndCount < int(str(xmlFileName).split("Skeleton ")[1].split(".xml")[0]):
gesturePositionEndCount = int(str(xmlFileName).split("Skeleton ")[1].split(".xml")[0])
gesture = np.zeros((gesturePositionEndCount+1, 24))
gesturePositionStartCount = gesturePositionEndCount
for xmlFileName in xmlFileNames:
xmlPath = path + xmlFileName
dom=ET.parse(xmlPath)
TrackStatus=dom.findall('./Skeleton/TrackingState')
isTracked = False
for trackStatu in TrackStatus:
if trackStatu.text=="Tracked":
isTracked=True
JointsPosition = np.zeros((24))
if isTracked==True:
gestureCount=int(str(xmlFileName).split("Skeleton ")[1].split(".xml")[0])
if gesturePositionStartCount > gestureCount:
gesturePositionStartCount = gestureCount
Joints = dom.findall('./Skeleton/Joints/Joint/Position')
JointType=dom.findall('./Skeleton/Joints/Joint/JointType'