def forwardKinematics(fullpose, trans, beta): ''' MANO parameters --> 3D pts, mesh :param fullpose: :param trans: :param beta: :return: 3D pts of size (21,3) ''' assert fullpose.shape == (48, ) assert trans.shape == (3, ) assert beta.shape == (10, ) m = load_model(MANO_MODEL_PATH, ncomps=6, flat_hand_mean=True) m.fullpose[:] = fullpose m.trans[:] = trans m.betas[:] = beta return m.J_transformed.r, m
# total number of synthetic image SYNTHETIC_NUM = 10 # total number of bg images model_pth = '/home/workspace/yy_ws/code/manopth/manopth/mano/models/MANO_RIGHT.pkl' bg_pth = '/home/workspace/yy_ws/code/3dhand/data/backgrounds/' output_path = '/home/workspace2/dataset/3dhand/syn/raw/' if os.path.exists(output_path): shutil.rmtree(output_path) os.makedirs(output_path) ls = sorted(get_img_path_list(bg_pth)) bg_number = len(ls) print('the total number of background images : %d' % (bg_number)) m = load_model(model_pth, ncomps=6, flat_hand_mean=False) # load all colors colors = [] for i in xrange(0, 27): f = open('/home/workspace/yy_ws/code/3dhand/data/meshes_colored/%d.obj' % i) cont = f.readlines() f.close() col = [] for x in cont: a = x[:len(x) - 1].split(" ") if (a[0] == 'v'): col.append(np.array([float(a[4]), float(a[5]), float(a[6])])) col = np.expand_dims(np.vstack(col), 0)
for theta in thetas.values(): thetaID = theta['id'] minThetaVals[thetaID] = theta['min'] maxThetaVals[thetaID] = theta['max'] if theta['optimize']: validThetaIDs.append(thetaID) else: invalidThetaIDs.append(thetaID) validThetaIDs = np.array(validThetaIDs, dtype=np.int32) invalidThetaIDs = np.array(invalidThetaIDs, dtype=np.int32) return validThetaIDs, invalidThetaIDs, minThetaVals, maxThetaVals m = load_model(MANO_MODEL_PATH, ncomps=6, flat_hand_mean=True) def forwardKinematics(fullpose, trans, beta): ''' MANO parameters --> 3D pts, mesh :param fullpose: :param trans: :param beta: :return: 3D pts of size (21,3) ''' assert fullpose.shape == (48, ) assert trans.shape == (3, ) assert beta.shape == (10, )