Answer To: Make 3D animation for data visualization of NTU RGB+D Skeleton dataset so we can ZOOM in/out rotate...
Uttam answered on Sep 25 2021
Skeleton_3D/Screenshot (47).png
Skeleton_3D/Screenshot (48).png
Skeleton_3D/Screenshot (49).png
Skeleton_3D/Skeleton_3D.docx
Student should run the whole file with one single shot, that means, using CMD or Pycharm or any other IDE and give the proper file path, visualization will come up automatically.
Rest the code will work fine.
Skeleton_3D/Skeleton_3D.py
import os
import numpy as np
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
from os import listdir
trunk_joints = [0, 1, 20, 2, 3]
arm_joints = [23, 24, 11, 10, 9, 8, 20, 4, 5, 6, 7, 22, 21]
leg_joints = [19, 18, 17, 16, 0, 12, 13, 14, 15]
body = [trunk_joints, arm_joints, leg_joints]
# Show 3D Skeleton with Axes3D for NTU RGB+D
class Draw3DSkeleton(object):
def __init__(self, file, save_path=None, init_horizon=-45,
init_vertical=20, x_rotation=None,
y_rotation=None, pause_step=0.2):
self.file = file
self.save_path = save_path
if not os.path.exists(self.save_path):
os.mkdir(self.save_path)
self.xyz = self.read_xyz(self.file)
self.init_horizon = init_horizon
self.init_vertical = init_vertical
self.x_rotation = x_rotation
self.y_rotation = y_rotation
self._pause_step = pause_step
def _read_skeleton(self, file):
with open(file, 'r') as f:
skeleton_sequence = {}
skeleton_sequence['numFrame'] = int(f.readline())
skeleton_sequence['frameInfo'] = []
for t in range(skeleton_sequence['numFrame']):
frame_info = {}
frame_info['numBody'] = int(f.readline())
frame_info['bodyInfo'] = []
for m in range(frame_info['numBody']):
body_info = {}
body_info_key = [
'bodyID', 'clipedEdges', 'handLeftConfidence',
'handLeftState', 'handRightConfidence', 'handRightState',
'isResticted', 'leanX', 'leanY', 'trackingState'
...