def getFrameData(self, files): depthFilename = [] rgbFilename = [] skelFilename = [] # pdb.set_trace() # Get filenames if len(files) > 0: for i in files: if i[-5:] == 'depth': depthFilename = i self.depthFilename = depthFilename if i[-3:] == 'rgb': rgbFilename = i self.rgbFilename = rgbFilename if self.skelsEnabled: if i[-4:] == 'skel': skelFilename = i self.skelFilename = skelFilename displayUsers = [] skels = [] if len(skelFilename) > 0: users = SR.readUserData(skelFilename) skels = SR.readSkeletonData(skelFilename) for i in users: displayUsers.append(users[i]['Img']) #eliminate bad skeleton data (joint data is linked to old data) # pdb.set_trace() deleteInd = [] for i in users.keys(): # print users[i]['Img'] if users[i]['Img'][2] == 0: deleteInd.append(i) deleteInd.sort(reverse=1) for i in deleteInd: # print "Del", i del users[i] del skels[i] del displayUsers[i-1] if len(depthFilename) > 0: ## 1 # depthRaw = open(depthFilename, 'rb').read().split() # depthRaw = np.fromfile(depthFilename, dtype=np.uint16, sep=" ") # self.depthData = np.array(depthRaw, dtype=int).reshape([480,640])[:,::-1] # self.depthData = self.depthData[:,::-1] ## 2 # self.depthData = np.fromfile(depthFilename, dtype=np.uint16, sep=" ").reshape([480, 640])[:,::-1] # self.depthDataRaw = self.depthData ## 3 x = open(depthFilename).read() self.depthDataRaw = np.fromstring(x, dtype=np.uint16, sep=" ").reshape([480, 640])[:,::-1] # print "User count: ", len(displayUsers) # print displayUsers if self.viz: self.depthData = constrain(self.depthDataRaw) try: for i in displayUsers: if i[0] != 0: for x in xrange(-10,10): for j in xrange(-1,1): self.depthData[480 - i[1]+j, 640 - i[0]+x] = 30 for y in xrange(-10, 10): for j in xrange(-1,1): self.depthData[480 - i[1]+y, 640 - i[0]+j] = 30 except: print "Error adding cross at", i # self.depthData = cv.fromarray(np.array(self.depthData, dtype=np.uint8)) # print "Skels: ", len(skels) # print skels if skels != [] and self.vizSkel: self.depthData = cv.fromarray(np.array(self.depthData, dtype=np.uint8)) self.depthData = SR.displaySkeleton_CV(self.depthData, skels) if self.viz: self.depthData = cv.fromarray(np.array(self.depthData, dtype=np.uint8)) cv2.imshow(self.windowName, np.array(self.depthData, dtype=np.uint8)) if len(rgbFilename) > 0: imgData = np.fromfile(rgbFilename, dtype=np.uint8) imgData = imgData.reshape([480, 640, 3]) if self.viz: cv2.imshow("RGB", imgData) cv.WaitKey(1)
break # Get filenames if len(files) > 0: for i in files: if i[-5:] == 'depth': depthFilename = i if i[-3:] == 'rgb': rgbFilename = i if i[-4:] == 'skel': skelFilename = i displayUsers = [] skels = [] if len(skelFilename) > 0: users = SR.readUserData(skelFilename) skels = SR.readSkeletonData(skelFilename) for i in users: displayUsers.append(users[i]['Img']) if len(depthFilename) > 0: depthRaw = open(depthFilename, 'rb').read().split() depthData = np.array(depthRaw, dtype=int).reshape([480,640]) depthData = depthData[:,-1:0:-1] min_ = np.min(depthData[np.nonzero(depthData)]) max_ = depthData.max() #/2 # print min_, max_ depthData[np.nonzero(depthData)] -= min_ depthData /= ((max_-min_)/256.0) depthData = 256 - depthData