├── .gitattributes ├── .gitignore ├── LICENSE ├── README.md ├── bvh.py ├── dataset └── music_feature │ └── librosa │ └── samples │ ├── gudianwu.csv │ ├── gudianwu.wav │ ├── sample_music1.csv │ └── sample_music1.wav ├── generate_dance.py ├── generate_dance.sh ├── images ├── chacha.gif └── gudianwu.gif ├── inlib ├── __init__.py ├── models.py └── ops.py ├── m2m_config.py ├── m2m_evaluation ├── csv_visualization.m └── matlab-file │ ├── bvh2quat.m │ ├── calcluate_error.m │ ├── capg_skel.mat │ ├── changeCoordinateSpace.m │ ├── cmu_bvh2exp.m │ ├── cmu_bvh2quat.m │ ├── cmu_bvh2xyz.m │ ├── cmu_capg_header.m │ ├── cmu_downsample_bvh.m │ ├── cmu_exp2xyz.m │ ├── cmu_exp_play.m │ ├── cmu_exp_skel.mat │ ├── cmu_retarget_skel.mat │ ├── cmu_xyz_play.m │ ├── exp2bvh.m │ ├── exp2euler.m │ ├── getExpmapFromSkeleton.m │ ├── h36m_skel.mat │ ├── mat2bvh.m │ ├── matlab │ ├── Contents.m │ ├── acclaim2xyz.m │ ├── acclaimGradient.m │ ├── acclaimLoadChannels.m │ ├── acclaimNumberOfFrames.m │ ├── acclaimPlayFile.m │ ├── acclaimReadSkel.m │ ├── acclaimSemiLoadChannels.m │ ├── additionalfiles.txt │ ├── ankurAngle2XYZ.m │ ├── bvh2xyz.m │ ├── bvhConnectionMatrix.m │ ├── bvhModify.m │ ├── bvhPlayData.m │ ├── bvhPlayFile.m │ ├── bvhReadFile.m │ ├── bvhVisualise.m │ ├── bvhWriteFile.m │ ├── clutterDir │ │ ├── bvhLoadData.m │ │ ├── bvhLoadResult.m │ │ ├── bvhModel.m │ │ ├── bvhOptions.m │ │ ├── bvhResults.m │ │ ├── bvhResultsDynamic.m │ │ ├── classVisualise.m │ │ ├── demBvh1.m │ │ ├── demEa.m │ │ ├── demEa1.m │ │ ├── demEa2.m │ │ ├── demEaStick.m │ │ ├── demHorse.m │ │ ├── demManuel1.m │ │ ├── demMocapReconstruct.m │ │ ├── demSwagger1.m │ │ ├── face2DModify.m │ │ ├── face2DVisualise.m │ │ ├── faceCallback.m │ │ ├── faceModify.m │ │ ├── facePatchCallback.m │ │ ├── facePatchModify.m │ │ ├── facePatchVisualise.m │ │ ├── faceScript.m │ │ ├── faceVisualise.m │ │ ├── fgplvmFit.m │ │ ├── gradientDescent.m │ │ ├── manifoldOutputs.m │ │ ├── manifoldOutputsManuel.m │ │ ├── mocapClassVisualise.m │ │ ├── mocapConnections.m │ │ ├── mocapDataDir.m │ │ ├── mocapFaceConnections.m │ │ ├── mocapFacePatches.m │ │ ├── mocapFaceVisualise.m │ │ ├── mocapLoadData.m │ │ ├── mocapLoadResult.m │ │ ├── mocapManuelRead.m │ │ ├── mocapParseText.m │ │ ├── mocapPath.m │ │ ├── mocapPlayData.m │ │ ├── mocapPlayFace.m │ │ ├── mocapPlayFaceFile.m │ │ ├── mocapResultsCpp.m │ │ ├── mocapResultsDynamic.m │ │ ├── mocapVers.m │ │ ├── mocapVisualise.m │ │ ├── pointNegGrad.m │ │ ├── pointNegLogLikelihood.m │ │ ├── read_bvh03.m │ │ ├── rotationMatrixGrad.m │ │ ├── runB.m │ │ ├── runEric.m │ │ ├── stickmanGplvmScript3.m │ │ ├── thetaConstrain.m │ │ ├── vectorModify.m │ │ └── vectorVisualise.m │ ├── computeGradient.m │ ├── convertxyz2Vect.m │ ├── diagnostics.dat │ ├── mocapResultsCppBvh.m │ ├── mocapToolboxes.m │ ├── orn │ │ └── stickman │ │ │ ├── AnimateSM.m │ │ │ ├── GPLVM_walking.mat │ │ │ ├── StickManPlot.m │ │ │ ├── plotJointConnections.m │ │ │ ├── stickmanGplvmModify.m │ │ │ ├── stickmanGplvmScriptBVH.m │ │ │ ├── stickmanGplvmVisualise.m │ │ │ └── stickmanResample.m │ ├── pseudoGradient.m │ ├── pseudoRotation.m │ ├── readme.txt │ ├── romain │ │ ├── compareGradient.m │ │ ├── computeGradient.m │ │ ├── convertxyz2Vect.m │ │ ├── demoFgplvmStep1.m │ │ ├── demoFgplvmStep2.m │ │ ├── demoGradientDescent.m │ │ ├── gradientDescent.m │ │ ├── gradientxyzBisTest.m │ │ ├── pseudoGradient.m │ │ └── rotationMatrixGradient.m │ ├── rotationMatrix.m │ ├── rotationMatrixGradient.m │ ├── skel2xyz.m │ ├── skelConnectionMatrix.m │ ├── skelModify.m │ ├── skelPlayData.m │ ├── skelReverseLookup.m │ ├── skelVisualise.m │ ├── skelWriteAvi.m │ ├── smoothAngleChannels.m │ ├── sneer.eps │ ├── stickModify.m │ ├── stickVisualise.m │ ├── xyzModify.m │ ├── xyzVisualise.m │ ├── xyzankur2joint.m │ ├── xyzankurAnim.m │ ├── xyzankurAnimCompare.m │ ├── xyzankurAnimCompareMultiple.m │ ├── xyzankurDraw.m │ ├── xyzankurError.m │ ├── xyzankurModify.m │ ├── xyzankurVisualise.m │ ├── xyzankurVisualise2.m │ ├── xyzhumaneva2joint.m │ ├── xyzhumanevaAlign.m │ ├── xyzhumanevaAnim.m │ ├── xyzhumanevaDraw.m │ ├── xyzhumanevaGenerateMovie.m │ ├── xyzhumanevaHeadingAngle.m │ ├── xyzhumanevaJoint2pos.m │ ├── xyzhumanevaModify.m │ ├── xyzhumanevaModify2.m │ ├── xyzhumanevaRemovePart.m │ ├── xyzhumanevaVisualise.m │ ├── xyzhumanevaVisualise2.m │ ├── xyzhumanevaVisualise3d.m │ ├── xyzhumanevaVisualiseModes.m │ ├── xyzpoppe2joint.m │ ├── xyzpoppeAnim.m │ ├── xyzpoppeDraw.m │ ├── xyzpoppeModify.m │ └── xyzpoppeVisualise.m │ ├── mhmublv │ ├── Data │ │ └── data.mat │ ├── LICENSE │ ├── Motion │ │ ├── RotMat2Euler.m │ │ ├── batchConvertCMU.m │ │ ├── buildskel_mit.m │ │ ├── dropframes.m │ │ ├── euler2expmap.m │ │ ├── exp2xyz.m │ │ ├── expModify.m │ │ ├── expPlayData.m │ │ ├── expVisualise.m │ │ ├── expmap2rotmat.m │ │ ├── postprocess.m │ │ ├── postprocess1.m │ │ ├── postprocess2.m │ │ ├── preprocess1.m │ │ ├── preprocess2.m │ │ ├── quat2expmap.m │ │ ├── rotationMatrix.m │ │ ├── rotmat2expmap.m │ │ ├── rotmat2quat.m │ │ └── skelConnectionMatrix.m │ ├── README.md │ ├── README.txt │ ├── Results │ │ ├── layer1.mat │ │ └── layer2.mat │ ├── binarycrbm.m │ ├── gaussiancrbm.m │ ├── gen.m │ ├── gen2.m │ ├── getfilteringdist.m │ ├── motiondemo.m │ ├── paramcount.m │ └── weightreport.m │ ├── mocap │ ├── Contents.m │ ├── NDLUTIL-161 │ │ ├── Contents.m │ │ ├── centeringMatrix.m │ │ ├── cumGamma.m │ │ ├── cumGaussian.m │ │ ├── defaultOptions.m │ │ ├── deg2rad.m │ │ ├── fileVersions.dat │ │ ├── gammaPdf.m │ │ ├── gaussOverDiffCumGaussian.m │ │ ├── gaussSamp.m │ │ ├── getSymbols.m │ │ ├── getline.m │ │ ├── gradLnDiffErfs.m │ │ ├── gradLogCumGaussian.m │ │ ├── gradientCheck.m │ │ ├── hessianCheck.m │ │ ├── html │ │ │ └── index.html │ │ ├── invCumGaussian.m │ │ ├── invSigmoid.m │ │ ├── isoctave.m │ │ ├── jitChol.m │ │ ├── kldivGaussian.m │ │ ├── lnCumGaussSum.m │ │ ├── lnCumGaussian.m │ │ ├── lnDiffCumGaussian.m │ │ ├── lnDiffErfs.c │ │ ├── lnDiffErfs.m │ │ ├── logdet.m │ │ ├── ndlutilToolboxes.m │ │ ├── negLogLogit.m │ │ ├── ngaussian.m │ │ ├── numsf2str.m │ │ ├── pdinv.m │ │ ├── preparePlot.m │ │ ├── printPlot.m │ │ ├── readBinaryDoubles.m │ │ ├── readBoolFromFID.m │ │ ├── readDoubleFromFID.m │ │ ├── readIntFromFID.m │ │ ├── readStringFromFID.m │ │ ├── readVersionFromFID.m │ │ ├── readme.txt │ │ ├── rocCurve.m │ │ ├── scatterPlot.m │ │ ├── sigmoid.m │ │ ├── sparseDiag.m │ │ ├── stack.m │ │ ├── stringSigFigs.m │ │ ├── stringSplit.m │ │ ├── tableRead.m │ │ ├── tokenise.m │ │ ├── traceProduct.m │ │ ├── treeFindChildren.m │ │ ├── treeFindLeaves.m │ │ ├── treeFindParents.m │ │ ├── treeFindRoots.m │ │ ├── treeGetWidths.m │ │ ├── treeSwapNode.m │ │ ├── writeBoolToFID.m │ │ ├── writeDoubleToFID.m │ │ ├── writeIntToFID.m │ │ ├── writeStringToFID.m │ │ ├── writeVersionToFID.m │ │ ├── xlogy.m │ │ └── zeroAxes.m │ ├── README.md │ ├── acclaim2xyz.m │ ├── acclaimGradient.m │ ├── acclaimLoadChannels.m │ ├── acclaimNumberOfFrames.m │ ├── acclaimPlayFile.m │ ├── acclaimReadSkel.m │ ├── acclaimSemiLoadChannels.m │ ├── additionalfiles.txt │ ├── ankurAngle2XYZ.m │ ├── bvh2xyz.m │ ├── bvhConnectionMatrix.m │ ├── bvhModify.m │ ├── bvhPlayData.m │ ├── bvhPlayFile.m │ ├── bvhReadFile.m │ ├── bvhVisualise.m │ ├── bvhWriteFile.m │ ├── clutterDir │ │ ├── bvhLoadData.m │ │ ├── bvhLoadResult.m │ │ ├── bvhModel.m │ │ ├── bvhOptions.m │ │ ├── bvhResults.m │ │ ├── bvhResultsDynamic.m │ │ ├── classVisualise.m │ │ ├── demBvh1.m │ │ ├── demEa.m │ │ ├── demEa1.m │ │ ├── demEa2.m │ │ ├── demEaStick.m │ │ ├── demHorse.m │ │ ├── demManuel1.m │ │ ├── demMocapReconstruct.m │ │ ├── demSwagger1.m │ │ ├── face2DModify.m │ │ ├── face2DVisualise.m │ │ ├── faceCallback.m │ │ ├── faceModify.m │ │ ├── facePatchCallback.m │ │ ├── facePatchModify.m │ │ ├── facePatchVisualise.m │ │ ├── faceScript.m │ │ ├── faceVisualise.m │ │ ├── fgplvmFit.m │ │ ├── gradientDescent.m │ │ ├── manifoldOutputs.m │ │ ├── manifoldOutputsManuel.m │ │ ├── mocapClassVisualise.m │ │ ├── mocapConnections.m │ │ ├── mocapDataDir.m │ │ ├── mocapFaceConnections.m │ │ ├── mocapFacePatches.m │ │ ├── mocapFaceVisualise.m │ │ ├── mocapLoadData.m │ │ ├── mocapLoadResult.m │ │ ├── mocapManuelRead.m │ │ ├── mocapParseText.m │ │ ├── mocapPath.m │ │ ├── mocapPlayData.m │ │ ├── mocapPlayFace.m │ │ ├── mocapPlayFaceFile.m │ │ ├── mocapResultsCpp.m │ │ ├── mocapResultsDynamic.m │ │ ├── mocapVers.m │ │ ├── mocapVisualise.m │ │ ├── pointNegGrad.m │ │ ├── pointNegLogLikelihood.m │ │ ├── read_bvh03.m │ │ ├── rotationMatrixGrad.m │ │ ├── runB.m │ │ ├── runEric.m │ │ ├── stickmanGplvmScript3.m │ │ ├── thetaConstrain.m │ │ ├── vectorModify.m │ │ └── vectorVisualise.m │ ├── computeGradient.m │ ├── convertxyz2Vect.m │ ├── diagnostics.dat │ ├── mocapResultsCppBvh.m │ ├── mocapToolboxes.m │ ├── orn │ │ └── stickman │ │ │ ├── AnimateSM.m │ │ │ ├── GPLVM_walking.mat │ │ │ ├── StickManPlot.m │ │ │ ├── plotJointConnections.m │ │ │ ├── stickmanGplvmModify.m │ │ │ ├── stickmanGplvmScriptBVH.m │ │ │ ├── stickmanGplvmVisualise.m │ │ │ └── stickmanResample.m │ ├── pseudoGradient.m │ ├── pseudoRotation.m │ ├── readme.txt │ ├── romain │ │ ├── compareGradient.m │ │ ├── computeGradient.m │ │ ├── convertxyz2Vect.m │ │ ├── demoFgplvmStep1.m │ │ ├── demoFgplvmStep2.m │ │ ├── demoGradientDescent.m │ │ ├── gradientDescent.m │ │ ├── gradientxyzBisTest.m │ │ ├── pseudoGradient.m │ │ └── rotationMatrixGradient.m │ ├── rotationMatrix.m │ ├── rotationMatrixGradient.m │ ├── skel2xyz.m │ ├── skelConnectionMatrix.m │ ├── skelModify.m │ ├── skelPlayData.m │ ├── skelReverseLookup.m │ ├── skelVisualise.m │ ├── skelWriteAvi.m │ ├── smoothAngleChannels.m │ ├── sneer.eps │ ├── stickModify.m │ ├── stickVisualise.m │ ├── xyzModify.m │ ├── xyzVisualise.m │ ├── xyzankur2joint.m │ ├── xyzankurAnim.m │ ├── xyzankurAnimCompare.m │ ├── xyzankurAnimCompareMultiple.m │ ├── xyzankurDraw.m │ ├── xyzankurError.m │ ├── xyzankurModify.m │ ├── xyzankurVisualise.m │ ├── xyzankurVisualise2.m │ ├── xyzhumaneva2joint.m │ ├── xyzhumanevaAlign.m │ ├── xyzhumanevaAnim.m │ ├── xyzhumanevaDraw.m │ ├── xyzhumanevaGenerateMovie.m │ ├── xyzhumanevaHeadingAngle.m │ ├── xyzhumanevaJoint2pos.m │ ├── xyzhumanevaModify.m │ ├── xyzhumanevaModify2.m │ ├── xyzhumanevaRemovePart.m │ ├── xyzhumanevaVisualise.m │ ├── xyzhumanevaVisualise2.m │ ├── xyzhumanevaVisualise3d.m │ ├── xyzhumanevaVisualiseModes.m │ ├── xyzpoppe2joint.m │ ├── xyzpoppeAnim.m │ ├── xyzpoppeDraw.m │ ├── xyzpoppeModify.m │ └── xyzpoppeVisualise.m │ ├── net_res2exp.m │ ├── plot_loss.m │ ├── plot_mot_fig.m │ ├── pre2truth.m │ ├── quat2bvh.m │ ├── read_json.m │ ├── revertCoordinateSpace.m │ ├── see_forecast.m │ ├── vec2quat.m │ ├── xyz2bvh.m │ ├── xyz2euler.m │ ├── xyzModify.m │ ├── xyzPlayData.m │ └── xyzVisualise.m ├── model ├── __init__.py └── base_model.py ├── music_feature_extract.py ├── requirement.txt ├── sample_list.json ├── statistic_features ├── ignore_dimensions.csv ├── mot_data_max.csv ├── mot_data_mean.csv ├── mot_data_min.csv ├── mot_data_std.csv ├── mus_data_max.csv ├── mus_data_min.csv └── new_idx.csv └── utils ├── __init__.py └── reader.py /.gitattributes: -------------------------------------------------------------------------------- 1 | *.m linguist-language=Python -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | /training_results/models/* 3 | /training_results/motions/* -------------------------------------------------------------------------------- /bvh.py: -------------------------------------------------------------------------------- 1 | class Node: 2 | def __init__(self, root=False): 3 | self.name = None 4 | self.channels = [] 5 | self.offset = (0, 0, 0) 6 | self.children = [] 7 | self._is_root = root 8 | self.order = "" 9 | self.pos_idx = [] 10 | self.exp_idx = [] 11 | self.rot_idx = [] 12 | self.quat_idx = [] 13 | self.parent = [] 14 | -------------------------------------------------------------------------------- /dataset/music_feature/librosa/samples/gudianwu.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/computer-animation-perception-group/DeepDance/28be6b7ad6232b86e80524ba28d673154b643bcf/dataset/music_feature/librosa/samples/gudianwu.wav -------------------------------------------------------------------------------- /dataset/music_feature/librosa/samples/sample_music1.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/computer-animation-perception-group/DeepDance/28be6b7ad6232b86e80524ba28d673154b643bcf/dataset/music_feature/librosa/samples/sample_music1.wav -------------------------------------------------------------------------------- /generate_dance.sh: -------------------------------------------------------------------------------- 1 | model_path=./training_results/models/chaoxianzu/cnn-erd_14_model.ckpt.meta 2 | CUDA_VISIBLE_DEVICES=0 \ 3 | python3 generate_dance.py \ 4 | --rnn_keep_list 0.95 0.9 1.0\ 5 | --kernel_size 1 3 \ 6 | --stride 1 2\ 7 | --act_type lrelu \ 8 | --seg_len 90 \ 9 | --seq_shift 1 \ 10 | --gen_hop 90 \ 11 | --model_path ${model_path%.*} \ 12 | --mot_scale 100. \ 13 | --norm_way zscore \ 14 | --mus_ebd_dim 72 \ 15 | --has_random_seed False \ 16 | --add_info ./training_results/motions/ -------------------------------------------------------------------------------- /images/chacha.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/computer-animation-perception-group/DeepDance/28be6b7ad6232b86e80524ba28d673154b643bcf/images/chacha.gif -------------------------------------------------------------------------------- /images/gudianwu.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/computer-animation-perception-group/DeepDance/28be6b7ad6232b86e80524ba28d673154b643bcf/images/gudianwu.gif -------------------------------------------------------------------------------- /inlib/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/computer-animation-perception-group/DeepDance/28be6b7ad6232b86e80524ba28d673154b643bcf/inlib/__init__.py -------------------------------------------------------------------------------- /m2m_evaluation/csv_visualization.m: -------------------------------------------------------------------------------- 1 | fname = 'gudianwu.csv'; 2 | src_path = ['..\training_results\motions\gudianwu\', fname]; 3 | load('cmu_retarget_skel.mat'); 4 | frame_rate = 0.03; 5 | src_chls = dlmread(src_path); 6 | max_length = 5000; 7 | if size(src_chls, 1) > max_length 8 | src_chls = src_chls(1:max_length, :); 9 | end 10 | dance_length = min(size(src_chls, 1), max_length); 11 | global md 12 | global fs 13 | [mus, fss] = audioread(['..\dataset\music_feature\librosa\samples\', strrep(fname, '.csv', '.wav')]); 14 | md = mus(1:int32((dance_length/30)*fss), :); 15 | fs = fss; 16 | exp2bvh(skel, src_chls, frame_rate); -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/bvh2quat.m: -------------------------------------------------------------------------------- 1 | function quat_data = bvh2quat(bvh_data) 2 | 3 | % quat_data = bvh2quat(bvh_data), for capg skel 4 | 5 | bvh_len = size(bvh_data, 1); 6 | quat_data = zeros(bvh_len, 79); 7 | for r = 1 : bvh_len 8 | bvh_line = bvh_data(r, :); 9 | quat_data(r, 1:3) = bvh_line(1:3); 10 | col = 4; 11 | for j = 4 : 3 : 58 12 | zr = deg2rad(bvh_line(j)); 13 | xr = deg2rad(bvh_line(j+1)); 14 | yr = deg2rad(bvh_line(j+2)); 15 | q = angle2quat(zr, xr, yr, 'ZXY'); 16 | quat_data(r, col: col+3) = q; 17 | col = col + 4; 18 | end 19 | end 20 | 21 | end 22 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/capg_skel.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/computer-animation-perception-group/DeepDance/28be6b7ad6232b86e80524ba28d673154b643bcf/m2m_evaluation/matlab-file/capg_skel.mat -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/changeCoordinateSpace.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/computer-animation-perception-group/DeepDance/28be6b7ad6232b86e80524ba28d673154b643bcf/m2m_evaluation/matlab-file/changeCoordinateSpace.m -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/cmu_bvh2quat.m: -------------------------------------------------------------------------------- 1 | clear; 2 | src_dir = 'F:\CAPG\mm_lzj\code\retarget_bvh\cmu\retarget\30hz\bvh\'; 3 | res_dir = 'F:\CAPG\mm_lzj\code\retarget_bvh\cmu\retarget\30hz\quat\'; 4 | list_bvh = dir([src_dir, '/*.bvh']); 5 | 6 | if ~exist(res_dir, 'dir') 7 | mkdir(res_dir); 8 | end 9 | 10 | for i = 600 : length(list_bvh) 11 | src_path = [src_dir, list_bvh(i).name]; 12 | [~, fname, ext] = fileparts(src_path); 13 | res_path = [res_dir, fname, '.csv']; 14 | fprintf('Loading %d/%d bvh: %s\n', i, length(list_bvh), src_path); 15 | [src_skel, src_chls, src_len] = bvhReadFile(src_path); 16 | src_skel.tree(1).offset = [0, 0, 0]; 17 | fprintf('Loading done.\n'); 18 | quat_chls = bvh2quat(src_chls); 19 | dlmwrite(res_path, quat_chls, 'delimiter', ',', 'newline', 'unix', 'precision', '%4.7f'); 20 | fprintf('Success, save:%s\n\n', res_path); 21 | end 22 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/cmu_bvh2xyz.m: -------------------------------------------------------------------------------- 1 | % convert cmu bvh data to xyz data. 2 | clc; 3 | src_dir = 'F:/CAPG/mm_lzj/code/retarget_bvh/cmu/retarget/120hz/bvh/'; 4 | res_dir = 'F:/CAPG/mm_lzj/code/retarget_bvh/cmu/retarget/120hz/xyz/'; 5 | list_bvh = dir([src_dir, '/*.bvh']); 6 | 7 | if ~exist(res_dir, 'dir') 8 | mkdir(res_dir); 9 | end 10 | 11 | for i = 1 : 2 12 | src_path = [src_dir, list_bvh(i).name]; 13 | [~, fname, ext] = fileparts(src_path); 14 | res_path = [res_dir, fname, '.csv']; 15 | fprintf('Loading %d/%d bvh: %s\n', i, length(list_bvh), src_path); 16 | [src_skel, src_chls, src_len] = bvhReadFile(src_path); 17 | src_skel.tree(1).offset = [0, 0, 0]; 18 | fprintf('Loading done.\n'); 19 | bvh_len = size(src_chls, 1); 20 | joint_num = length(src_skel.tree); 21 | xyz_data = zeros(bvh_len, joint_num * 3); 22 | fprintf('xyz data size:(%d %d). Converting bvh to xyz...\n', bvh_len, length(src_skel.tree)*3); 23 | for j = 1 : bvh_len 24 | xyz = bvh2xyz(src_skel, src_chls(j, :)); 25 | xyz = reshape(xyz', 1, joint_num * 3); 26 | xyz_data(j, :) = xyz; 27 | end 28 | dlmwrite(res_path, xyz_data, 'delimiter', ',', 'newline', 'unix', 'precision', '%.9f'); 29 | fprintf('Success, save:%s\n\n', res_path); 30 | end 31 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/cmu_capg_header.m: -------------------------------------------------------------------------------- 1 | clear; 2 | load('capg_skel.mat'); 3 | src_dir = 'F:/CAPG/mm_lzj/code/retarget_bvh/cmu/retarget/move_hip/'; 4 | res_dir = 'F:/CAPG/mm_lzj/code/retarget_bvh/cmu/retarget/capg_header/'; 5 | list_bvh = dir([src_dir, '/*.bvh']); 6 | 7 | if ~exist(res_dir, 'dir') 8 | mkdir(res_dir); 9 | end 10 | 11 | for i = 1 : length(list_bvh) 12 | src_path = [src_dir, list_bvh(i).name]; 13 | [~, fname, ext] = fileparts(src_path); 14 | res_path = [res_dir, fname, '.bvh']; 15 | fprintf('Loading %d/%d bvh: %s\n', i, length(list_bvh), src_path); 16 | [src_skel, src_chls, src_len] = bvhReadFile(src_path); 17 | bvhWriteFile(res_path, capg_skel, src_chls, 1/120); 18 | fprintf('Success, save:%s\n\n', res_path); 19 | end -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/cmu_exp2xyz.m: -------------------------------------------------------------------------------- 1 | % H3.6m/dataParser/playGenerateMotion.m 2 | % getExpmapFromSkeleton(getSkeleton) -> playVideo -> revertCoordinateSpace -> 3 | % expPlayData2 -> expVisualise -> exp2xyz 4 | 5 | R0 = [1,0,0;0,1,0;0,0,1]; 6 | T0 = [49.985066666700000,95.302933333300000,-92.372266666700000]; 7 | load('cmu_exp_skel.mat'); 8 | src_path = 'F:/CAPG/mm_lzj/code/retarget_bvh/cmu/retarget/exp_data/01_01.csv'; 9 | exp_chls = dlmread(src_path); 10 | recon = revertCoordinateSpace(exp_chls, R0, T0); 11 | % rec_xyz = exp2xyz(exp_skel, recon); 12 | expPlayData(exp_skel, recon); -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/cmu_exp_play.m: -------------------------------------------------------------------------------- 1 | % H3.6m/dataParser/playGenerateMotion.m 2 | % getExpmapFromSkeleton(getSkeleton) -> playVideo -> revertCoordinateSpace -> 3 | % expPlayData2 -> expVisualise -> exp2xyz 4 | clear; 5 | R0 = [1,0,0;0,1,0;0,0,1]; 6 | T0 = [49.985066666700000,95.302933333300000,-92.372266666700000]; 7 | load('cmu_exp_skel.mat'); 8 | src_path = 'F:/CAPG/mm_lzj/code/retarget_bvh/cmu/retarget/exp_data/01_01.csv'; 9 | exp_chls = dlmread(src_path); 10 | recon = revertCoordinateSpace(exp_chls, R0, T0); 11 | % rec_xzy = exp2xyz(exp_skel, recon(1, :)); 12 | % expPlayData(exp_skel, recon); 13 | 14 | 15 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/cmu_exp_skel.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/computer-animation-perception-group/DeepDance/28be6b7ad6232b86e80524ba28d673154b643bcf/m2m_evaluation/matlab-file/cmu_exp_skel.mat -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/cmu_retarget_skel.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/computer-animation-perception-group/DeepDance/28be6b7ad6232b86e80524ba28d673154b643bcf/m2m_evaluation/matlab-file/cmu_retarget_skel.mat -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/cmu_xyz_play.m: -------------------------------------------------------------------------------- 1 | clear; 2 | src_path = 'F:/CAPG/mm_lzj/code/retarget_bvh/cmu/retarget/xyz_data/13_18.csv'; 3 | load('cmu_exp_skel.mat'); 4 | xyz_data = dlmread(src_path); 5 | xyzPlayData(exp_skel, xyz_data, 1./120); -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/exp2euler.m: -------------------------------------------------------------------------------- 1 | % return a vector of eluer degree (in degrees) 2 | function euler = exp2euler(skel, channels) 3 | euler = []; 4 | for j = 1 : length(skel.tree) 5 | if isempty(skel.tree(j).rotInd) 6 | continue; 7 | end 8 | if skel.tree(j).posInd 9 | euler = [euler, channels(skel.tree(j).posInd)]; 10 | end 11 | exp = channels(skel.tree(j).expmapInd); 12 | rot = expmap2rotmat(exp); 13 | [e1, e2, e3] = dcm2angle(rot, skel.tree(j).order); 14 | eul = [e1, e2, e3]; 15 | % eul = RotMat2Euler(rot); 16 | eul = rad2deg(eul); 17 | euler = [euler, eul]; 18 | end -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/getExpmapFromSkeleton.m: -------------------------------------------------------------------------------- 1 | function [ skel_expmap,expmapchannels ] = getExpmapFromSkeleton( skel,channels ) 2 | expmapchannels = []; 3 | for i = 1:size(channels,1) 4 | [skel_expmap, channel] = euler2expmap(skel,channels(i,:)); 5 | expmapchannels = [expmapchannels;channel]; 6 | end; 7 | end 8 | 9 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/h36m_skel.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/computer-animation-perception-group/DeepDance/28be6b7ad6232b86e80524ba28d673154b643bcf/m2m_evaluation/matlab-file/h36m_skel.mat -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mat2bvh.m: -------------------------------------------------------------------------------- 1 | function mat2bvh(mot_mat, header_path, des_path, frameRate) 2 | % Write motion data to bvh file 3 | if nargin < 4 4 | frameRate = 1/60; 5 | end 6 | des_dir = fileparts(des_path); 7 | if ~exist(des_dir, 'dir') 8 | mkdir(des_dir); 9 | end 10 | 11 | if exist(des_path, 'file') 12 | delete(des_path); 13 | end 14 | 15 | mot_len = size(mot_mat, 1); 16 | sh_id = fopen(header_path); 17 | dh_id = fopen(des_path, 'w+'); 18 | header_rows = numel(textread(header_path,'%1c%*[^\n]')); 19 | for i = 1 : header_rows 20 | hline = fgetl(sh_id); 21 | fprintf(dh_id, '%s\n', hline); 22 | end 23 | fprintf(dh_id, '%s\n', ['Frames: ', num2str(mot_len)]); 24 | fprintf(dh_id, '%s%.6f\n', 'Frame Time: ', frameRate); 25 | fclose(sh_id); 26 | fclose(dh_id); 27 | 28 | dlmwrite(des_path, mot_mat, '-append', 'delimiter', ' ', 'newline', 'unix', 'precision', '%.6f'); 29 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/acclaimNumberOfFrames.m: -------------------------------------------------------------------------------- 1 | function nFrames = acclaimNumberOfFrames(fileName) 2 | 3 | % ACCLAIMNUMBEROFFRAMES Extract the number of frames. 4 | % FORMAT 5 | % DESC counts the total number of frames from an acclaim motion capture 6 | % file. 7 | % ARG fileName : the file name to load in. 8 | % RETURN nFrames : the total number of frames in the file. 9 | % 10 | % COPYRIGHT : Alfredo A. Kalaitzis, 2012 11 | % 12 | % SEEALSO : 13 | 14 | % MOCAP 15 | 16 | fid = fopen(fileName, 'rt'); 17 | 18 | % Assumes the number of lines in each frame is fixed. 19 | a = cell(textscan(fid, '%s')); 20 | a = a{1}; 21 | nFrames = str2double(a{end-91}); % 91 strings from eof to last frame # 22 | 23 | fclose(fid); 24 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/acclaimPlayFile.m: -------------------------------------------------------------------------------- 1 | function acclaimPlayFile(fileNameAsf, fileNameAmc, frameLength) 2 | 3 | % ACCLAIMPLAYFILE Play motion capture data from a asf and amc file. 4 | % FORMAT 5 | % DESC plays motion capture data by reading in a asf and amc files from disk. 6 | % ARG fileNameAsf : the name of the ASF file to read in. 7 | % ARG fileNameAmc : the name of the AMC file to read in. 8 | % ARG frameLength : the length of the frames. 9 | % 10 | % COPYRIGHT : Neil D. Lawrence, 2006 11 | % 12 | % SEEALSO : acclaimPlayFile, bvhReadFile, skelPlayData 13 | 14 | % MOCAP 15 | 16 | skel = acclaimReadSkel(fileNameAsf); 17 | [channels, skel] = acclaimLoadChannels(fileNameAmc, skel); 18 | skelPlayData(skel, channels, frameLength); 19 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/additionalfiles.txt: -------------------------------------------------------------------------------- 1 | # These are files that should be packaged for gplvm C++ software 2 | dir: examples 3 | ~/datasets/mocap/Swagger.bvh 4 | dir: html 5 | ~/mlprojects/mocap/html/index.html 6 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/ankurAngle2XYZ.m: -------------------------------------------------------------------------------- 1 | function X = ankurAngle2XYZ(X) 2 | 3 | if(size(X,2)~=54) 4 | error('Wrong Dimensionality of Data'); 5 | end 6 | 7 | matrix_to_bvh(X','tmp.bvh'); 8 | X = bvh_to_3dmatrix('tmp.bvh'); 9 | 10 | % clean up 11 | system('rm tmp.bvh'); 12 | 13 | return; -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/bvhConnectionMatrix.m: -------------------------------------------------------------------------------- 1 | function connection = bvhConnectionMatrix(skel); 2 | 3 | % BVHCONNECTIONMATRIX Compute the connection matrix for the structure. 4 | % FORMAT 5 | % DESC computes the connection matrix for the structure. Returns a matrix 6 | % which has zeros at all entries except those that are connected in the 7 | % skeleton. 8 | % ARG skel : the skeleton for which the connectivity is required. 9 | % RETURN connection : connectivity matrix. 10 | % 11 | % COPYRIGHT : Neil D. Lawrence, 2005, 2006 12 | % 13 | % SEEALSO : skelConnectionMatrix 14 | 15 | % MOCAP 16 | 17 | connection = skelConnectionMatrix(skel); 18 | 19 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/bvhModify.m: -------------------------------------------------------------------------------- 1 | function bvhModify(handle, channels, skel, padding) 2 | 3 | % BVHMODIFY Helper code for visualisation of bvh data. 4 | % FORMAT 5 | % DESC updates a bvh representation in a 3-D plot. 6 | % ARG handle : a vector of handles to the structure to be updated. 7 | % ARG channels : the channels to update the skeleton with. 8 | % ARG skel : the skeleton structure. 9 | % 10 | % SEEALSO : skelModify, bvhVisualise 11 | % 12 | % COPYRIGHT : Neil D. Lawrence, 2005, 2006 13 | 14 | % MOCAP 15 | 16 | 17 | if nargin<4 18 | padding = 0; 19 | end 20 | 21 | skelModify(handle, channels, skel, padding); 22 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/bvhPlayData.m: -------------------------------------------------------------------------------- 1 | function bvhPlayData(skel, channels, frameLength) 2 | 3 | % BVHPLAYDATA Play bvh motion capture data. 4 | % FORMAT 5 | % DESC plays channels from the bvh motion capture format. 6 | % ARG skel : the skeleton for the motion. 7 | % ARG channels : the channels for the motion. 8 | % ARG frameLength : the framelength for the motion. 9 | % 10 | % COPYRIGHT : Neil D. Lawrence, 2005, 2006 11 | % 12 | % SEEALSO : skelPlayData 13 | 14 | % MOCAP 15 | 16 | skelPlayData(skel, channels, frameLength); 17 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/bvhPlayFile.m: -------------------------------------------------------------------------------- 1 | function bvhPlayFile(fileName) 2 | 3 | % BVHPLAYFILE Play motion capture data from a bvh file. 4 | % FORMAT 5 | % DESC plays motion capture data by reading in a bvh file from disk. 6 | % ARG fileName : the name of the file to read in, in bvh format. 7 | % 8 | % COPYRIGHT : Neil D. Lawrence, 2005 9 | % 10 | % SEEALSO : acclaimPlayFile, bvhReadFile, skelPlayData 11 | 12 | % MOCAP 13 | 14 | [skel, channels, frameLength] = bvhReadFile(fileName); 15 | skelPlayData(skel, channels, frameLength); 16 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/bvhVisualise.m: -------------------------------------------------------------------------------- 1 | function handle = bvhVisualise(channels, skel, padding) 2 | 3 | % BVHVISUALISE For updating a bvh representation of 3-D data. 4 | % FORMAT 5 | % DESC draws a bvh representation in a 3-D plot. 6 | % ARG channels : the channels to update the skeleton with. 7 | % ARG skel : the skeleton structure. 8 | % RETURN handle : a vector of handles to the plotted structure. 9 | % 10 | % SEEALSO : bvhModify, skelVisualise 11 | % 12 | % COPYRIGHT : Neil D. Lawrence, 2005, 2006 13 | 14 | % MOCAP 15 | 16 | if nargin < 3 17 | padding = 0; 18 | end 19 | handle = skelVisualise(channels, skel, padding); 20 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/clutterDir/bvhLoadData.m: -------------------------------------------------------------------------------- 1 | function [bvhStruct, channels, frameLength, velocityIndices] = bvhLoadData(dataSet, velocityIndices) 2 | 3 | % BVHLOADDATA Load a motion capture data set. 4 | 5 | if nargin < 2 6 | % By default consider x and y motion as velocity 7 | velocityIndices = [1 3 6]; 8 | end 9 | dataDir = mocapDataDir; 10 | switch dataSet 11 | otherwise 12 | % assume the data set is a bvh filename. 13 | fileName = [mocapDataDir dataSet '.bvh']; 14 | 15 | if exist(fileName) == 2 16 | [bvhStruct, channels, frameLength] = bvhReadFile(fileName); 17 | % Convert specified channels into velocities 18 | for i = 2:size(channels, 1) 19 | for j = velocityIndices 20 | channels(i-1, j) = channels(i, j) - channels(i-1, j); 21 | end 22 | end 23 | else 24 | error([fileName ' does not exist.']) 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/clutterDir/bvhLoadResult.m: -------------------------------------------------------------------------------- 1 | function [model, bvhStruct, frameLength] = bvhLoadResult(dataSet, number) 2 | 3 | % BVHLOADRESULT Load a previously saved result. 4 | 5 | [bvhStruct, channels, frameLength] = bvhLoadData(dataSet); 6 | 7 | dataSet(1) = upper(dataSet(1)); 8 | load(['dem' dataSet num2str(number)]) 9 | model = ivmReconstruct(kern, noise, ivmInfo, X, channels); 10 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/clutterDir/bvhModel.m: -------------------------------------------------------------------------------- 1 | function bvhModel(dataSet, experimentNo) 2 | 3 | % BVHMODEL Model Demonstration of modelling of BVH files. 4 | 5 | rand('seed', 1e5) 6 | randn('seed', 1e5) 7 | colordef white 8 | 9 | [bvhStruct, Y, frameLength, velocityIndices] = bvhLoadData(dataSet); 10 | 11 | numActive = min([50 size(Y, 1)]); 12 | % Fit the GP latent variable model 13 | switch experimentNo 14 | case 1 15 | kernelType = {'rbf', 'bias', 'white'}; 16 | case 2 17 | kernelType = {'mlp', 'bias', 'white'}; 18 | end 19 | options = bvhOptions; 20 | 21 | model = gplvmFit(Y, 2, options, kernelType, 'gaussian', ... 22 | 'entropy', numActive) 23 | 24 | % Save the results. 25 | X = model.X; 26 | [kern, noise, ivmInfo] = ivmDeconstruct(model); 27 | capName = dataSet; 28 | capName(1) = upper(capName(1)); 29 | save(['dem' capName num2str(experimentNo) '.mat'], 'X', 'kern', ... 30 | 'noise', 'ivmInfo'); 31 | 32 | %bvhResultsDynamic(dataSet, experimentNo, 'bvh', bvhStruct, velocityIndices) -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/clutterDir/bvhOptions.m: -------------------------------------------------------------------------------- 1 | function options = bvhOptions 2 | 3 | % BVHOPTIONS The default options for modelling bvh data. 4 | 5 | options = gplvmOptions; 6 | options.gplvmKern = 1; 7 | options.initX = 'sppca'; 8 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/clutterDir/bvhResults.m: -------------------------------------------------------------------------------- 1 | function bvhResults(dataSet, experimentNo) 2 | 3 | % BVHRESULTS Model Demonstration of modelling of BVH files. 4 | 5 | [bvhStruct, Y, frameLength, velocityIndices] = bvhLoadData(dataSet); 6 | bvhResultsDynamic(dataSet, experimentNo, 'bvh', bvhStruct, velocityIndices) 7 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/clutterDir/bvhResultsDynamic.m: -------------------------------------------------------------------------------- 1 | function bvhResultsDynamic(dataSet, number, dataType, bvhStruct, velocityIndices) 2 | 3 | % BVHRESULTSDYNAMIC Load a results file and visualise them. 4 | 5 | [model, bvhStruct, frameLength] = bvhLoadResult(dataSet, number); 6 | 7 | if size(model.X, 2) ~=2 8 | error('Visualisation only works for 2-D latent spaces.') 9 | end 10 | mocapVisualise(model, ones(size(model.X, 1), 1), ... 11 | str2func([dataType 'Visualise']), ... 12 | str2func([dataType 'Modify']), ... 13 | bvhStruct, velocityIndices); 14 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/clutterDir/demEa.m: -------------------------------------------------------------------------------- 1 | % DEMEA Show the saved results of demEa1. 2 | 3 | load demEa1 4 | labelInfo(1).text = 'Neutral'; 5 | labelInfo(1).indices = [1:20]'; 6 | labelInfo(2).text = 'Happy'; 7 | labelInfo(2).indices = [21:27 96:105]'; 8 | labelInfo(3).text = 'Sad'; 9 | labelInfo(3).indices = [30:38]'; 10 | labelInfo(4).text = 'Fear'; 11 | labelInfo(4).indices = [40:47]'; 12 | labelInfo(5).text = 'Suprise'; 13 | labelInfo(5).indices = [49:58]'; 14 | labelInfo(6).text = 'Anger'; 15 | labelInfo(6).indices = [60:68]'; 16 | labelInfo(7).text = 'Disgust'; 17 | labelInfo(7).indices = [70:78]'; 18 | labelInfo(8).text = 'Maniac'; 19 | labelInfo(8).indices = [80:95]'; 20 | labelInfo(9).text = 'Transition'; 21 | labelInfo(9).indices = [28:29 39 48 59 69 79]'; 22 | 23 | numData = size(Y, 1); 24 | % Visualise the results 25 | mocapFaceVisualise(X, Y, invK, theta, [], meanData, 1:numData, ... 26 | labelInfo, 'face2DVisualise', 'face2DModify', patches); 27 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/clutterDir/demMocapReconstruct.m: -------------------------------------------------------------------------------- 1 | function demMocapReconstruct(fileName) 2 | 3 | % MOCAPPLAYFACEFILE Play a face file of motion capture data. 4 | 5 | % Load patches 6 | 7 | % connections = mocapFaceConnections('../data/manuel/connections.txt'); 8 | % connections(:, 73:end) = []; 9 | % connections(73:end, :) = []; 10 | patches = mocapFacePatches('../data/manuel/patches.txt'); 11 | for i = 1:4 12 | patches(i).colour = zeros(size(patches(i).colour)); 13 | end 14 | indToDel = []; 15 | for i = 1:length(patches) 16 | if any(patches(i).index > 72) 17 | indToDel = [indToDel i]; 18 | end 19 | end 20 | load ../data/2_2.mat 21 | lastMarker = 72*3+1; 22 | points{1} = vals(:, 2:3:lastMarker); 23 | points{2} = vals(:, 3:3:lastMarker); 24 | points{3} = vals(:, 4:3:lastMarker); 25 | for i = 1:3 26 | vals = points{i}(:, 3) + points{i}(:, 50) + points{i}(:, 60); 27 | vals = vals/3; 28 | for j = 1:size(points{i}, 2); 29 | points{i}(:, j) = points{i}(:, j) - vals; 30 | end 31 | end 32 | patches(indToDel) = []; 33 | Y = [points{1} points{3} points{2}]*4; 34 | 35 | pause 36 | fprintf('Press any key.\n'); 37 | mocapPlayFace(Y); 38 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/clutterDir/face2DModify.m: -------------------------------------------------------------------------------- 1 | function face2DModify(handle, vals, patches) 2 | 3 | % FACE2DMODIFY Helper code for visualisation of a face. 4 | 5 | global PATCHINFO 6 | numMark = size(vals, 2)/3; 7 | valsx = vals(1, 1:numMark); 8 | valsy = vals(1, numMark+1:2*numMark); 9 | valsz = vals(1, 2*numMark+1:3*numMark); 10 | PATCHINFO.points = [valsx' valsy' valsz']; 11 | 12 | set(handle(1), 'Xdata', valsx, 'Ydata', valsz); 13 | for i = 1:length(patches) 14 | X = zeros(1, length(patches(i).index)); 15 | % Y = zeros(1, length(patches(i).index)); 16 | Z = zeros(1, length(patches(i).index)); 17 | for j = 1:length(X) 18 | X(j) = valsx(patches(i).index(j)); 19 | % Y(j) = valsy(patches(i).index(j)); 20 | Z(j) = valsz(patches(i).index(j)); 21 | end 22 | 23 | set(handle(i+1), 'Xdata', X, ... 24 | 'Ydata', Z); 25 | end 26 | drawnow -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/clutterDir/faceModify.m: -------------------------------------------------------------------------------- 1 | function faceModify(handle, values, connect) 2 | 3 | % FACEMODIFY Helper code for visualisation of a face. 4 | 5 | vals = reshape(values, size(values, 2)/3, 3); 6 | 7 | indices = find(connect); 8 | [I, J] = ind2sub(size(connect), indices); 9 | set(handle(1), 'Xdata', vals(:, 1), 'Ydata', vals(:, 3));%, 'Zdata', ... 10 | % vals(:, 3)); 11 | 12 | 13 | for i = 1:length(indices) 14 | set(handle(i+1), 'Xdata', [vals(I(i), 1) vals(J(i), 1)], ... 15 | 'Ydata', [vals(I(i), 3) vals(J(i), 3)]);%, ... 16 | % 'Zdata', [vals(I(i), 3) vals(J(i), 3)]); 17 | end 18 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/clutterDir/facePatchModify.m: -------------------------------------------------------------------------------- 1 | function facePatchModify(handle, vals, patches) 2 | 3 | % FACEPATCHMODIFY Helper code for visualisation of a face. 4 | 5 | numMark = size(vals, 2)/3; 6 | valsx = vals(1, 1:numMark); 7 | valsy = vals(1, numMark+1:2*numMark); 8 | valsz = vals(1, 2*numMark+1:3*numMark); 9 | PATCHINFO.points = [valsx' valsy' valsz']; 10 | 11 | set(handle(1), 'Xdata', valsx, 'Ydata', valsy, 'Zdata', ... 12 | valsz); 13 | %set(handle(1), 'visible', 'on'); 14 | for i = 1:length(patches) 15 | X = zeros(1, length(patches(i).index)); 16 | Y = zeros(1, length(patches(i).index)); 17 | Z = zeros(1, length(patches(i).index)); 18 | for j = 1:length(X) 19 | X(j) = valsx(patches(i).index(j)); 20 | Y(j) = valsy(patches(i).index(j)); 21 | Z(j) = valsz(patches(i).index(j)); 22 | end 23 | 24 | set(handle(i+1), 'Xdata', X, ... 25 | 'Ydata', Y, ... 26 | 'Zdata', Z); 27 | end 28 | drawnow -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/clutterDir/faceVisualise.m: -------------------------------------------------------------------------------- 1 | function handle = faceVisualise(vals, connect) 2 | 3 | % FACEVISUALISE For updateing a face representation of 3-D data. 4 | 5 | numMark = size(vals, 2)/3; 6 | valsx = vals(1, 1:numMark); 7 | valsy = vals(1, numMark+1:2*numMark); 8 | valsz = vals(1, 2*numMark+1:3*numMark); 9 | 10 | indices = find(connect); 11 | [I, J] = ind2sub(size(connect), indices); 12 | %handle(1) = plot3(valsx, valsy, valsz, '.'); 13 | handle(1) = plot(valsx, valsz, '.'); 14 | set(handle(1), 'markersize', 12); 15 | set(handle(1), 'visible', 'off') 16 | hold on 17 | grid on 18 | for i = 1:length(indices) 19 | handle(i+1) = line([valsx(I(i)) valsx(J(i))], ... 20 | [valsz(I(i)) valsz(J(i))]); ... 21 | % [valsz(I(i)) valsz(J(i))]); 22 | set(handle(i+1), 'linewidth', 2); 23 | % set(handle(i+1), 'visible', 'off') 24 | end 25 | axis equal 26 | %set(gca, 'zlim', [-2 2]) 27 | set(gca, 'ylim', [-4 4]) 28 | set(gca, 'xlim', [-2 2]) 29 | xlabel('x') 30 | ylabel('z') 31 | zlabel('y') 32 | %set(gca, 'cameraposition', [-1.3954 -91.5992 46.0000]) 33 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/clutterDir/manifoldOutputs.m: -------------------------------------------------------------------------------- 1 | function [meanOut, varOut] = manifoldOutputs(X2, X, Y, theta, invK) 2 | 3 | % MANIFOLDOUTPUTS Evaluate the manifold output for datapoints X. 4 | 5 | global LINEAR 6 | 7 | dataDim = size(Y, 2); 8 | numData = size(Y, 1); 9 | numDataTest = size(X2, 1); 10 | 11 | alpha = zeros(numData, dataDim); 12 | 13 | kbold = kernel(X2, X, theta)'; 14 | 15 | A = Y'*invK; 16 | meanOut = A*kbold; 17 | meanOut = meanOut'; 18 | varOut = zeros(numDataTest, 1); 19 | for i = 1:numDataTest 20 | varOut(i) = theta(2) +1/theta(end) - kbold(:, i)'*invK*kbold(:, i); 21 | end 22 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/clutterDir/mocapConnections.m: -------------------------------------------------------------------------------- 1 | function connect = mocapConnections(fileName, pointNames); 2 | 3 | % MOCAPCONNECTIONS Give a connection matrix for the motion capture data. 4 | 5 | fid = fopen(fileName); 6 | i = 1; 7 | rem = fgets(fid); 8 | while(rem ~= -1) 9 | [token, rem] = strtok(rem, ','); 10 | connections{i, 1} = fliplr(deblank(fliplr(deblank(token)))); 11 | [token, rem] = strtok(rem, ','); 12 | connections{i, 2} = fliplr(deblank(fliplr(deblank(token)))); 13 | i = i + 1; 14 | rem = fgets(fid); 15 | end 16 | 17 | connect = zeros(length(pointNames)); 18 | fclose(fid); 19 | for i = 1:size(connections, 1); 20 | for j = 1:length(pointNames) 21 | if strcmp(pointNames{j}, connections{i, 1}) | ... 22 | strcmp(pointNames{j}, connections{i, 2}) 23 | for k = 1:length(pointNames) 24 | if k == j 25 | break 26 | end 27 | if strcmp(pointNames{k}, connections{i, 1}) | ... 28 | strcmp(pointNames{k}, connections{i, 2}) 29 | connect(j, k) = 1; 30 | end 31 | end 32 | end 33 | end 34 | end 35 | connect = sparse(connect); -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/clutterDir/mocapDataDir.m: -------------------------------------------------------------------------------- 1 | function directory = mocapDataDir 2 | 3 | % MOCAPDATADIR Return the directory where the data is stored. 4 | 5 | dirSep = filesep; 6 | directory = ['..' dirSep 'data' dirSep]; -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/clutterDir/mocapFaceConnections.m: -------------------------------------------------------------------------------- 1 | function connect = mocapFaceConnections(fileName); 2 | 3 | % MOCAPFACECONNECTIONS Give a connection matrix for the motion capture data. 4 | 5 | fid = fopen(fileName); 6 | i = 1; 7 | rem = fgets(fid); 8 | while(rem ~= -1) 9 | [token, rem] = strtok(rem, ','); 10 | row = str2num(fliplr(deblank(fliplr(deblank(token)))))+1; 11 | [token, rem] = strtok(rem, ','); 12 | col = str2num(fliplr(deblank(fliplr(deblank(token)))))+1; 13 | i = i + 1; 14 | connect(row, col) = 1; 15 | rem = fgets(fid); 16 | end 17 | connect = connect + connect'; 18 | connect(find(connect)) = 1; 19 | connect = tril(connect); 20 | connect = sparse(connect); -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/clutterDir/mocapFacePatches.m: -------------------------------------------------------------------------------- 1 | function patches = mocapFacePatches(fileName); 2 | 3 | % MOCAPFACEPATCHES Give a connection matrix for the motion capture data. 4 | 5 | fid = fopen(fileName); 6 | i = 1; 7 | rem = fgets(fid); 8 | while(rem ~= -1) 9 | patches(i) = struct('index', [], 'colour', []); 10 | patches(i).index = sscanf(rem, '%d')+1; 11 | i = i+1; 12 | rem = fgets(fid); 13 | end 14 | colour = ones(1, 1, 3); 15 | for i = 1:length(patches) 16 | patches(i).colour = colour; 17 | end -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/clutterDir/mocapLoadData.m: -------------------------------------------------------------------------------- 1 | function mocapData = mocapLoadData(dataSet, velocity) 2 | 3 | % MOCAPLOADDATA Load a motion capture data set. 4 | 5 | dataDir = mocapDataDir; 6 | if nargin < 2 7 | velocity = 1; 8 | end 9 | switch dataSet 10 | otherwise 11 | % assume the data set is a bvh filename. 12 | fileName = [mocapDataDir dataSet '.bvh']; 13 | 14 | if exist(fileName) == 7 15 | [bvhStruct, channels, frameLength] = bvhReadFile(fileName); 16 | if velocity 17 | % Convert root's channels into velocities 18 | rootIndices = 1; 19 | for i = 2:size(channels, 1) 20 | for j = rootIndices 21 | for k = bvhStruct(j).posInd 22 | channels(i-1, k) = channels(i, k) - channels(i-1, k); 23 | end 24 | for k = bvhStruct(j).rotInd 25 | channels(i-1, k) = channels(i, k) - channels(i-1, k); 26 | end 27 | end 28 | end 29 | end 30 | end 31 | end 32 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/clutterDir/mocapLoadResult.m: -------------------------------------------------------------------------------- 1 | function [model, connect] = mocapLoadResult(dataSet, number) 2 | 3 | % MOCAPLOADRESULT Load a previously saved result. 4 | 5 | [Y, connect] = mocapLoadData(dataSet); 6 | 7 | dataSet(1) = upper(dataSet(1)); 8 | load(['dem' dataSet num2str(number)]) 9 | model = ivmReconstruct(kern, noise, ivmInfo, X, Y); 10 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/clutterDir/mocapManuelRead.m: -------------------------------------------------------------------------------- 1 | function [columnNames, data] = mocapManuelRead(fileName) 2 | 3 | % MOCAPMANUELREAD Read in data which has column titles in the first line and separated values in each other line. 4 | 5 | if nargin < 2 6 | separator = ','; 7 | end 8 | 9 | 10 | 11 | fid = fopen(fileName); 12 | numMarkers = str2num(fgetl(fid)); 13 | numLines = str2num(fgetl(fid)); 14 | framesPerSecond = str2num(fgetl(fid)); 15 | 16 | lin = fgetl(fid); 17 | columnNames = stringSplit(lin, ';'); 18 | numCol = length(columnNames); 19 | i = 0; 20 | data = zeros(numLines, (numCol - 1)*3+1); 21 | delim = sprintf('\t'); 22 | while 1 23 | i = i+1; 24 | lin=fgetl(fid); 25 | if ~ischar(lin), break, end 26 | split = stringSplit(deblank(lin), delim); 27 | % if length(split) ~= numMarkers*3 28 | % error(['Error at line ' num2str(i) ' of file ' fileName ': wrong ' ... 29 | % 'number of columns']) 30 | % end 31 | for j = 2:length(split); 32 | data(i, j) = str2num(split{j}); 33 | end 34 | end 35 | fclose(fid); -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/clutterDir/mocapParseText.m: -------------------------------------------------------------------------------- 1 | function [points, pointNames, times] = mocapParseText(fileName); 2 | 3 | % MOCAPPARSETEXT Parse a motion capture text file. 4 | 5 | fid = fopen(fileName); 6 | readLine = fgets(fid); 7 | 8 | [token, rem] = strtok(readLine); 9 | [token, rem] = strtok(rem); % skipping the 'field' field 10 | [token, rem] = strtok(rem); % skipping the 'time' field 11 | 12 | i = 1; 13 | while (~isempty(token)) 14 | pointNames{i}= token(1:end-2); 15 | i = i+1; 16 | [token, rem] = strtok(rem); 17 | [token, rem] = strtok(rem); 18 | [token, rem] = strtok(rem); 19 | end 20 | 21 | numPoints = length(pointNames); 22 | S = fscanf(fid, '%f '); 23 | numData = length(S)/(numPoints*3+2); 24 | S = reshape(S, numPoints*3+2, numData)'; 25 | field = S(:, 1); 26 | times = S(:, 2); 27 | S(find(S==-9999.99)) = NaN; 28 | points{1} = S(:, 3:3:end); 29 | points{2} = S(:, 4:3:end); 30 | points{3} = S(:, 5:3:end); 31 | 32 | fclose(fid); -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/clutterDir/mocapPath.m: -------------------------------------------------------------------------------- 1 | % MOCAPATH The toolboxes for the mocap toolbox. 2 | 3 | 4 | importTool('ivm', 0.31) 5 | importTool('kern', 0.13) 6 | importTool('noise', 0.12) 7 | importTool('prior', 0.12) 8 | importTool('optimi', 0.12) 9 | importTool('ndlutil', 0.12) 10 | importTool('rochol', 0.12) 11 | importTool('gplvm') -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/clutterDir/mocapPlayData.m: -------------------------------------------------------------------------------- 1 | function mocapPlayData(fileName) 2 | 3 | % MOCAPPLAYDATA 4 | 5 | [Y, connections] = mocapLoadData(fileName); 6 | 7 | pauseVal = 0.01; 8 | handle = stickVisualise(Y(1, :), connections); 9 | pause 10 | disp('Press a key') 11 | for j = 1:20 12 | for i = 1:size(Y, 1) 13 | pause(pauseVal); 14 | stickModify(handle, Y(i, :), connections); 15 | end 16 | end -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/clutterDir/mocapPlayFace.m: -------------------------------------------------------------------------------- 1 | function mocapPlayFace(Y, patches, model) 2 | 3 | % MOCAPPLAYDATA 4 | 5 | % Load patches 6 | % Compute any missing values 7 | 8 | playY = Y; 9 | if nargin > 2 10 | x = randn(2, 1); 11 | for i = 1:size(playY, 1) 12 | if any(isnan(playY(i, :))) 13 | x = scg('pointNegLogLikelihood', ... 14 | x, options, 'pointNegGrad', ... 15 | yval, model.X, ... 16 | model.A, ... 17 | model.theta, ... 18 | model.invSigma); 19 | playY(i, :) = manifoldOutputs(x, model.X, model.Y, ... 20 | model.theta, model.invSigma); 21 | notMissing = find(~isnan(Y(i, :))); 22 | playY(i, notMissing) = Y(i, notMissing); 23 | end 24 | end 25 | end 26 | 27 | pauseVal = 0.0001; 28 | handle = facePatchVisualise(playY(1, :), patches); 29 | for i = 1:size(playY, 1) 30 | facePatchModify(handle, playY(i, :), patches); 31 | drawnow 32 | end 33 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/clutterDir/mocapPlayFaceFile.m: -------------------------------------------------------------------------------- 1 | % MOCAPPLAYFACEFILE Play a face file of motion capture data. 2 | 3 | % Load patches 4 | 5 | % connections = mocapFaceConnections('../data/manuel/connections.txt'); 6 | % connections(:, 73:end) = []; 7 | % connections(73:end, :) = []; 8 | patches = mocapFacePatches('../data/manuel/patches.txt'); 9 | for i = 1:4 10 | patches(i).colour = zeros(size(patches(i).colour)); 11 | end 12 | indToDel = []; 13 | for i = 1:length(patches) 14 | if any(patches(i).index > 72) 15 | indToDel = [indToDel i]; 16 | end 17 | end 18 | load ../data/2_2.mat 19 | lastMarker = 72*3+1; 20 | points{1} = vals(:, 2:3:lastMarker); 21 | points{2} = vals(:, 3:3:lastMarker); 22 | points{3} = vals(:, 4:3:lastMarker); 23 | for i = 1:3 24 | vals = points{i}(:, 3) + points{i}(:, 50) + points{i}(:, 60); 25 | vals = vals/3; 26 | for j = 1:size(points{i}, 2); 27 | points{i}(:, j) = points{i}(:, j) - vals; 28 | end 29 | end 30 | patches(indToDel) = []; 31 | Y = [points{1} points{3} points{2}]*4; 32 | 33 | pause 34 | fprintf('Press any key.\n'); 35 | mocapPlayFace(Y(1:5:end, :), patches); 36 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/clutterDir/mocapResultsCpp.m: -------------------------------------------------------------------------------- 1 | function mocapResultsCpp(dataSet, number, dataType, varargin) 2 | 3 | % MOCAPRESULTSDYNAMIC Load a results file and visualise them. 4 | 5 | [model, connect] = mocapLoadResult(dataSet, number); 6 | 7 | % Visualise the results 8 | switch size(model.X, 2) 9 | case 1 10 | gplvmVisualise1D(model, [dataType 'Visualise'], [dataType 'Modify'], ... 11 | connect, varargin{:}); 12 | 13 | case 2 14 | gplvmVisualise(model, ones(size(model.X, 1)), [dataType 'Visualise'], [dataType 'Modify'], ... 15 | connect, varargin{:}); 16 | 17 | otherwise 18 | error('No visualisation code for data of this latent dimension.'); 19 | end -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/clutterDir/mocapResultsDynamic.m: -------------------------------------------------------------------------------- 1 | function mocapResultsDynamic(dataSet, number, dataType, varargin) 2 | 3 | % MOCAPRESULTSDYNAMIC Load a results file and visualise them. 4 | 5 | [model, connect] = mocapLoadResult(dataSet, number); 6 | 7 | % Visualise the results 8 | switch size(model.X, 2) 9 | case 1 10 | gplvmVisualise1D(model, [dataType 'Visualise'], [dataType 'Modify'], ... 11 | connect, varargin{:}); 12 | 13 | case 2 14 | gplvmVisualise(model, ones(size(model.X, 1)), [dataType 'Visualise'], [dataType 'Modify'], ... 15 | connect, varargin{:}); 16 | 17 | otherwise 18 | error('No visualisation code for data of this latent dimension.'); 19 | end -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/clutterDir/mocapVers.m: -------------------------------------------------------------------------------- 1 | function [vers, depend] = mocapVers 2 | 3 | % MOCAPPATH Brings dependent toolboxes into the path. 4 | 5 | vers = 0.001; 6 | if nargout > 2 7 | depend(1).name = 'gplvm'; 8 | depend(1).vers = 2.02; 9 | depend(1).required = 0; 10 | end 11 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/clutterDir/pointNegLogLikelihood.m: -------------------------------------------------------------------------------- 1 | function e = pointNegLogLikelihood(x, y, X, A, theta, invK, m, C) 2 | 3 | % POINTNEGLOGLIKELIHOOD Wrapper function for calling noise likelihoods. 4 | 5 | L = modelLogLikelihood(x, y, X, A, theta, invK); 6 | if nargin < 7 7 | m = [0 0]; 8 | C = [1 0; 0 1]; 9 | end 10 | L = L - .5*(x-m)*pdinv(C)*(x-m)'; 11 | e = -L; 12 | 13 | function logLike = modelLogLikelihood(x, y, X, A, theta, invK); 14 | 15 | presentInd = find(~isnan(y)); 16 | Atemp = A(presentInd, :); 17 | 18 | kbold = kernel(x, X, theta)'; 19 | meanOut = Atemp*kbold; 20 | meanOut = meanOut'; 21 | varOut = theta(2) +1/theta(end) - kbold'*invK*kbold; 22 | ycent = (y(presentInd) - meanOut); 23 | logLike = -0.5*length(presentInd)*log(varOut) - ycent*ycent'/(2*varOut); 24 | 25 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/clutterDir/rotationMatrixGrad.m: -------------------------------------------------------------------------------- 1 | function rotMat = rotationMatrixGrad(xangle, yangle, zangle, order); 2 | 3 | % ROTATIONMATRIX Compute the rotation matrix for an angle in each direction. 4 | 5 | if nargin < 4 6 | order = 'zxy'; 7 | end 8 | if isempty(order) 9 | order = 'zxy'; 10 | end 11 | % Here we assume we rotate z, then x then y. 12 | c1 = cos(xangle); % The x angle 13 | c2 = cos(yangle); % The y angle 14 | c3 = cos(zangle); % the z angle 15 | s1 = sin(xangle); 16 | s2 = sin(yangle); 17 | s3 = sin(zangle); 18 | 19 | % see http://mathworld.wolfram.com/RotationMatrix.html for 20 | % additional info. 21 | 22 | switch order 23 | case 'zxy' 24 | rotMat = [c2*c3-s1*s2*s3 c2*s3+s1*s2*c3 -s2*c1 25 | -c1*s3 c1*c3 s1 26 | s2*c3+c2*s1*s3 s2*s3-c2*s1*c3 c2*c1]; 27 | otherwise 28 | rotMat = eye(3); 29 | for i = 1:length(order) 30 | switch order(i) 31 | case 'x' 32 | rotMat = [1 0 0 33 | 0 c1 s1 34 | 0 -s1 c1]*rotMat; 35 | case 'y' 36 | rotMat = [c2 0 -s2 37 | 0 1 0 38 | s2 0 c2]*rotMat; 39 | case 'z' 40 | rotMat = [c3 s3 0 41 | -s3 c3 0 42 | 0 0 1]*rotMat; 43 | 44 | end 45 | end 46 | 47 | end 48 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/clutterDir/runB.m: -------------------------------------------------------------------------------- 1 | bvhModel('b', 1); 2 | bvhModel('b', 2); -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/clutterDir/runEric.m: -------------------------------------------------------------------------------- 1 | bvhModel('eric1', 1); 2 | bvhModel('eric1', 2); 3 | bvhModel('ericr1', 1); 4 | bvhModel('ericr1', 2); 5 | bvhModel('ericrun', 1); 6 | bvhModel('ericrun', 2); 7 | bvhModel('ericdog', 1); 8 | bvhModel('ericdog', 2); -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/clutterDir/thetaConstrain.m: -------------------------------------------------------------------------------- 1 | function theta = thetaConstrain(theta) 2 | 3 | % THETACONSTRAIN Prevent kernel parameters from getting too big or small. 4 | 5 | minTheta = 1e-6; 6 | maxTheta = 1/minTheta; 7 | 8 | if any(theta < minTheta) 9 | theta(find(thetamaxTheta) 11 | theta(find(theta>maxTheta)) = maxTheta; 12 | end 13 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/clutterDir/vectorModify.m: -------------------------------------------------------------------------------- 1 | function vectorModify(handle, values, names, connect) 2 | 3 | % VECTORMODIFY Helper code for visualisation of vectorial data. 4 | 5 | vals = reshape(values, size(values, 2)/3, 3); 6 | 7 | indices = find(connect); 8 | [I, J] = ind2sub(size(connect), indices); 9 | set(handle(1), 'Xdata', vals(:, 1), 'Ydata', vals(:, 2), 'Zdata', ... 10 | vals(:, 3)); 11 | 12 | 13 | for i = 1:length(indices) 14 | set(handle(i+1), 'Xdata', [vals(I(i), 1) vals(J(i), 1)], ... 15 | 'Ydata', [vals(I(i), 2) vals(J(i), 2)], ... 16 | 'Zdata', [vals(I(i), 3) vals(J(i), 3)]); 17 | end 18 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/clutterDir/vectorVisualise.m: -------------------------------------------------------------------------------- 1 | function handle = vectorVisualise(vals, names, connect) 2 | 3 | % VECTORVISUALISE Helper code for plotting a vector during 2-D visualisation.Plot the oil data 4 | 5 | vals = reshape(vals, size(vals, 2)/3, 3); 6 | 7 | indices = find(connect); 8 | [I, J] = ind2sub(size(connect), indices); 9 | handle(1) = plot3(vals(:, 1), vals(:, 2), vals(:, 3), 'ro'); 10 | hold on 11 | for i = 1:length(indices) 12 | handle(i+1) = line([vals(I(i), 1) vals(J(i), 1)], ... 13 | [vals(I(i), 2) vals(J(i), 2)], ... 14 | [vals(I(i), 3) vals(J(i), 3)]); 15 | end 16 | %for i = 1:size(vals, 1) 17 | % handle = [handle text(vals(i, 1), vals(i, 2), vals(i, 3), names{i})]; 18 | %end 19 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/convertxyz2Vect.m: -------------------------------------------------------------------------------- 1 | function vect = convertxyz2Vect(xyz) 2 | 3 | % CONVERTXYZ2VECT convert an xyz matrix into a vector. 4 | % 5 | % Description: 6 | % 7 | % channelsFinal = gradientDescent(skel, initialChannels, finalChannels, 8 | % error,step) 9 | % 10 | % Returns: 11 | % VECT - a line vector 12 | % Arguments: 13 | % XYZ - the xyz matrix to be transformed 14 | 15 | for i=1:size(xyz,1) 16 | for j=1:size(xyz,2) 17 | vect((i-1)*3 + j) = xyz(i,j); 18 | end 19 | end -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/diagnostics.dat: -------------------------------------------------------------------------------- 1 | Files not tagged as in toolbox: 2 | 3 | Files not commented: 4 | 5 | Files not in CVS or SVN: 6 | 7 | Dependent toolbox problems 8 | File Comments Removed 9 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/mocapToolboxes.m: -------------------------------------------------------------------------------- 1 | % MOCAPTOOLBOXES Toolboxes required by the MOCAP toolbox. 2 | importLatest('ndlutil') -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/orn/stickman/AnimateSM.m: -------------------------------------------------------------------------------- 1 | 2 | noCoordinates = length(points(1,:)); 3 | noFrames = length(points(:,1)); 4 | noPoints = noCoordinates / 3; 5 | 6 | points_x = zeros(noFrames, noPoints); 7 | points_y = zeros(noFrames, noPoints); 8 | points_z = zeros(noFrames, noPoints); 9 | 10 | line = zeros(1, noCoordinates); 11 | 12 | frameNo = 1; 13 | 14 | while( frameNo <= noFrames ) 15 | line = points(frameNo,:); 16 | 17 | points_x(frameNo,:) = line(1:noPoints); 18 | points_y(frameNo,:) = line(noPoints+1:2*noPoints); 19 | points_z(frameNo,:) = line(2*noPoints+1:3*noPoints); 20 | 21 | frameNo = frameNo + 1; 22 | end 23 | 24 | % Animate 25 | frame_x = zeros(1, noPoints); 26 | frame_y = zeros(1, noPoints); 27 | frame_z = zeros(1, noPoints); 28 | 29 | t = timer('TimerFcn','StickManPlot(frame_x,frame_z,frame_y,connection)', 'StartDelay', 0.01); 30 | 31 | frameNo = 1; 32 | 33 | while( frameNo <= noFrames ) 34 | frame_x = points_x(frameNo, :); 35 | frame_y = points_y(frameNo, :); 36 | frame_z = points_z(frameNo, :); 37 | 38 | start(t); 39 | frameNo = frameNo + 1; 40 | wait(t); 41 | end 42 | 43 | delete(t); -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/orn/stickman/GPLVM_walking.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/computer-animation-perception-group/DeepDance/28be6b7ad6232b86e80524ba28d673154b643bcf/m2m_evaluation/matlab-file/matlab/orn/stickman/GPLVM_walking.mat -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/orn/stickman/StickManPlot.m: -------------------------------------------------------------------------------- 1 | function StickManPlot(frame_x, frame_z, frame_y, connection) 2 | 3 | plot3(frame_x, frame_z, frame_y, 'o', 'LineWidth', 2); 4 | 5 | noJoints = length(connection(1,:)); 6 | twoPoints = zeros(2, 3); 7 | 8 | hold on; 9 | 10 | for i = 1:noJoints; 11 | for j = 1:noJoints; 12 | if connection(i,j) == 1 13 | twoPoints(1,1) = frame_x(1,i); 14 | twoPoints(2,1) = frame_x(1,j); 15 | twoPoints(1,2) = frame_z(1,i); 16 | twoPoints(2,2) = frame_z(1,j); 17 | twoPoints(1,3) = frame_y(1,i); 18 | twoPoints(2,3) = frame_y(1,j); 19 | plot3(twoPoints(:,1), twoPoints(:,2), twoPoints(:,3), 'LineWidth', 2); 20 | end 21 | end 22 | end 23 | 24 | hold off; 25 | 26 | set(gca, 'XLim', [-100 100]); 27 | set(gca, 'YLim', [-100 100]); 28 | set(gca, 'ZLim', [-100 100]); 29 | campos([20 80 60]); 30 | camtarget([0 0 0]); 31 | set(gca, 'DataAspectRatio', [1 1 1]); 32 | grid on; 33 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/orn/stickman/plotJointConnections.m: -------------------------------------------------------------------------------- 1 | function plotJointConnections(frame_x, frame_y, frame_z, connection) 2 | 3 | noJoints = length(connection(1,:)); 4 | twoPoints = zeros(2, 3); 5 | somethingPlotted = 0; 6 | 7 | for i = 1:noJoints; 8 | for j = 1:noJoints; 9 | if connection(i,j) == 1 10 | twoPoints(1,1) = frame_x(1,i); 11 | twoPoints(2,1) = frame_x(1,j); 12 | twoPoints(1,2) = frame_z(1,i); 13 | twoPoints(2,2) = frame_z(1,j); 14 | twoPoints(1,3) = frame_y(1,i); 15 | twoPoints(2,3) = frame_y(1,j); 16 | plot3(twoPoints(:,1), twoPoints(:,2), twoPoints(:,3), '-o', 'LineWidth', 2); 17 | 18 | if somethingPlotted == 0 19 | hold on; 20 | somethingPlotted = 1; 21 | end 22 | end 23 | end 24 | end 25 | 26 | hold off; 27 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/orn/stickman/stickmanGplvmModify.m: -------------------------------------------------------------------------------- 1 | function stickmanGplvmModify(handle, vals, connection) 2 | 3 | numPoints = size(vals, 2) / 3; 4 | 5 | frame_x = vals(1:numPoints); 6 | frame_y = vals(numPoints+1:2*numPoints); 7 | frame_z = vals(2*numPoints+1:3*numPoints); 8 | 9 | figure(2) 10 | 11 | plotJointConnections(frame_x, frame_y, frame_z, connection); 12 | % feval(handle, frame_x, frame_y, frame_z, connection); 13 | 14 | set(gca, 'DataAspectRatio', [1 1 1]); 15 | grid on; 16 | 17 | figure(1) -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/orn/stickman/stickmanGplvmVisualise.m: -------------------------------------------------------------------------------- 1 | function handle = stickmanGplvmVisualise(vals, connection) 2 | 3 | numPoints = size(vals, 2) / 3; 4 | 5 | frame_x = vals(1:numPoints); 6 | frame_y = vals(numPoints+1:2*numPoints); 7 | frame_z = vals(2*numPoints+1:3*numPoints); 8 | 9 | plotJointConnections(frame_x, frame_y, frame_z, connection); 10 | set(gca, 'DataAspectRatio', [1 1 1]); 11 | grid on; 12 | 13 | % handle = @plotJointConnections; 14 | 15 | handle = plot3(frame_x, frame_y, frame_z, 'o'); 16 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/orn/stickman/stickmanResample.m: -------------------------------------------------------------------------------- 1 | function [resampledPoints] = stickmanResample(points, sampleSize) 2 | 3 | indices = randperm(size(points, 1)); 4 | resampledPoints = zeros(sampleSize, size(points, 2)); 5 | 6 | for i = 1:sampleSize 7 | resampledPoints(i, :) = points(indices(i), :); 8 | end -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/romain/compareGradient.m: -------------------------------------------------------------------------------- 1 | %test Gradient 2 | 3 | skel = acclaimReadSkel('07.asf'); 4 | [channels, skel] = acclaimLoadChannels('07_01.amc', skel); 5 | 6 | gradient = computeGradient(skel,channels(1,:)); 7 | 8 | epsilon = 0.0000001; 9 | [lin siz] = size(gradient); 10 | 11 | result = zeros(lin,siz); 12 | 13 | vect = zeros(lin,siz); 14 | 15 | for k=1:siz 16 | 17 | channels_epsilonPlus = channels(1,:); 18 | channels_epsilonPlus(1,k) = channels_epsilonPlus(1,k) + epsilon ; 19 | channels_epsilonMoins = channels(1,:); 20 | channels_epsilonMoins(1,k) = channels_epsilonMoins(1,k) - epsilon ; 21 | 22 | 23 | 24 | xyz = skel2xyz(skel, channels_epsilonPlus); 25 | xyz2 = skel2xyz(skel, channels_epsilonMoins); 26 | 27 | toCompare = (xyz - xyz2)/(2*epsilon); 28 | 29 | vect(:,k) = convertxyz2Vect(toCompare)'; 30 | 31 | 32 | %This is the matrix where the values are the comparison between the real 33 | %gradient and the variation rate (all the values should be close to 1 34 | result(:,k) = vect(:,k) ./ gradient(:,k); 35 | 36 | end 37 | 38 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/romain/convertxyz2Vect.m: -------------------------------------------------------------------------------- 1 | function vect = convertxyz2Vect(xyz) 2 | 3 | % CONVERTXYZ2VECT convert an xyz matrix into a vector. 4 | % 5 | % Description: 6 | % 7 | % channelsFinal = gradientDescent(skel, initialChannels, finalChannels, 8 | % error,step) 9 | % 10 | % Returns: 11 | % VECT - a line vector 12 | % Arguments: 13 | % XYZ - the xyz matrix to be transformed 14 | 15 | for i=1:size(xyz,1) 16 | for j=1:size(xyz,2) 17 | vect((i-1)*3 + j) = xyz(i,j); 18 | end 19 | end -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/romain/demoGradientDescent.m: -------------------------------------------------------------------------------- 1 | % DEMOGRADIENTDESCENT compute a gradient descent for an initial position 2 | % and an end position of a human body 3 | 4 | 5 | %you can modify the error value to make the channels get closer to the 6 | %wanted channels 7 | error = 10; 8 | step = 0.01; 9 | 10 | 11 | skel = acclaimReadSkel('07.asf'); 12 | [channels, skel] = acclaimLoadChannels('07_01.amc', skel); 13 | 14 | channels(1,[1 2 3]) = [ 0 0 0 ]; 15 | channels(200,[1 2 3])= [ 0 0 0 ]; 16 | test = zeros(1,62); 17 | 18 | %channelsFinal = gradientDescent(skel, channels(1,:), channels(200,:),error,step); 19 | channelsFinal = gradientDescent(skel, channels(1,:), test,error,step); 20 | 21 | 22 | figure(1) 23 | subplot(2,2,1) 24 | skelVisualise(channels(1,:), skel, -1); 25 | title('initial position') 26 | subplot(2,2,2) 27 | %skelVisualise(channels(200,:), skel, -1); 28 | skelVisualise(test, skel, -1); 29 | title('final position') 30 | subplot(2,2,3) 31 | skelVisualise(channels(1,:), skel, -1); 32 | %skelVisualise(channels(200,:), skel, -1); 33 | skelVisualise(test, skel, -1); 34 | title('initial and final position') 35 | 36 | 37 | figure(2) 38 | skelPlayData(skel,channelsFinal,1/60); 39 | %skelVisualise(channels(200,:), skel, -1); 40 | skelVisualise(test, skel, -1); -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/skel2xyz.m: -------------------------------------------------------------------------------- 1 | function xyz = skel2xyz(skel, channels) 2 | 3 | % SKEL2XYZ Compute XYZ values given skeleton structure and channels. 4 | % FORMAT 5 | % DESC Computes X, Y, Z coordinates given a BVH or acclaim skeleton 6 | % structure and an associated set of channels. 7 | % ARG skel : a skeleton for the bvh file. 8 | % ARG channels : the channels for the bvh file. 9 | % RETURN xyz : the point cloud positions for the skeleton. 10 | % 11 | % COPYRIGHT : Neil D. Lawrence, 2006 12 | % 13 | % SEEALSO : acclaim2xyz, bvh2xyz 14 | 15 | % MOCAP 16 | 17 | fname = str2func([skel.type '2xyz']); 18 | xyz = fname(skel, channels); 19 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/skelConnectionMatrix.m: -------------------------------------------------------------------------------- 1 | function connection = skelConnectionMatrix(skel); 2 | 3 | % SKELCONNECTIONMATRIX Compute the connection matrix for the structure. 4 | % FORMAT 5 | % DESC computes the connection matrix for the structure. Returns a matrix 6 | % which has zeros at all entries except those that are connected in the 7 | % skeleton. 8 | % ARG skel : the skeleton for which the connectivity is required. 9 | % RETURN connection : connectivity matrix. 10 | % 11 | % COPYRIGHT : Neil D. Lawrence, 2006 12 | % 13 | % SEEALSO : skelVisualise, skelModify 14 | 15 | % MOCAP 16 | 17 | connection = zeros(length(skel.tree)); 18 | for i = 1:length(skel.tree); 19 | for j = 1:length(skel.tree(i).children) 20 | connection(i, skel.tree(i).children(j)) = 1; 21 | end 22 | end 23 | 24 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/skelReverseLookup.m: -------------------------------------------------------------------------------- 1 | function index = skelReverseLookup(skel, jointName) 2 | 3 | % SKELREVERSELOOKUP Return the number associated with the joint name. 4 | % FORMAT 5 | % DESC returns the number associated with a particular joint name in a 6 | % given skeleton. 7 | % ARG skel : the skeleton to look up. 8 | % ARG jointName : the joint name to look up. 9 | % RETURN index : the index of the joint name in the skeleton. 10 | % 11 | % COPYRIGHT : Neil D. Lawrence, 2006 12 | % 13 | 14 | % MOCAP 15 | 16 | for i=1:length(skel.tree) 17 | if strcmp(skel.tree(i).name, jointName) 18 | index = i; 19 | return 20 | end 21 | end 22 | 23 | error('Reverse look up of name failed.') 24 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/skelVisualise.m: -------------------------------------------------------------------------------- 1 | function handle = skelVisualise(channels, skel, padding) 2 | 3 | % SKELVISUALISE For drawing a skel representation of 3-D data. 4 | % FORMAT 5 | % DESC draws a skeleton representation in a 3-D plot. 6 | % ARG channels : the channels to update the skeleton with. 7 | % ARG skel : the skeleton structure. 8 | % RETURN handle : a vector of handles to the plotted structure. 9 | % 10 | % SEEALSO : skelModify 11 | % 12 | % COPYRIGHT : Neil D. Lawrence, 2005, 2006 13 | 14 | % MOCAP 15 | 16 | if nargin<3 17 | padding = 0; 18 | end 19 | channels = [channels zeros(1, padding)]; 20 | vals = skel2xyz(skel, channels); 21 | connect = skelConnectionMatrix(skel); 22 | 23 | indices = find(connect); 24 | [I, J] = ind2sub(size(connect), indices); 25 | handle(1) = plot3(vals(:, 1), vals(:, 3), vals(:, 2), '.'); 26 | axis ij % make sure the left is on the left. 27 | set(handle(1), 'markersize', 20); 28 | %/~ 29 | %set(handle(1), 'visible', 'off') 30 | %~/ 31 | hold on 32 | grid on 33 | for i = 1:length(indices) 34 | handle(i+1) = line([vals(I(i), 1) vals(J(i), 1)], ... 35 | [vals(I(i), 3) vals(J(i), 3)], ... 36 | [vals(I(i), 2) vals(J(i), 2)]); 37 | set(handle(i+1), 'linewidth', 2); 38 | end 39 | axis equal 40 | xlabel('x') 41 | ylabel('z') 42 | zlabel('y') 43 | axis on 44 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/smoothAngleChannels.m: -------------------------------------------------------------------------------- 1 | function channels = smoothAngleChannels(channels, skel); 2 | 3 | % SMOOTHANGLECHANNELS Try and remove artificial discontinuities associated with angles. 4 | 5 | % MOCAP 6 | 7 | for i=1:length(skel.tree) 8 | for j=1:length(skel.tree(i).rotInd) 9 | col = skel.tree(i).rotInd(j); 10 | if col 11 | for k=2:size(channels, 1) 12 | diff=channels(k, col)-channels(k-1, col); 13 | if abs(diff+360)0) 34 | alpha(i) = -alpha(i); 35 | end 36 | 37 | if(display) 38 | waitbar(i/size(Z,1)); 39 | end 40 | 41 | end 42 | if(display) 43 | close(handle_waitbar); 44 | end 45 | 46 | return 47 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/xyzhumanevaJoint2pos.m: -------------------------------------------------------------------------------- 1 | function pos = xyzhumanevaJoint2pos(joint) 2 | 3 | % XYZHUMANEVAJOINT2POS 4 | % 5 | % COPYRIGHT : Carl Henrik Ek and Neil Lawrence, 2008 6 | 7 | % MOCAP 8 | 9 | 10 | pos = zeros(1,prod(size(joint))); 11 | 12 | pos(1:3:end) = joint(:,1); 13 | pos(2:3:end) = joint(:,2); 14 | pos(3:3:end) = joint(:,3); 15 | 16 | return 17 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/xyzhumanevaModify.m: -------------------------------------------------------------------------------- 1 | function handle = xyzhumanevaModify(handle,pos) 2 | 3 | % XYZHUMANEVAMODIFY 4 | % 5 | % COPYRIGHT : Carl Henrik Ek and Neil Lawrence, 2008 6 | 7 | % MOCAP 8 | 9 | 10 | joint = xyzhumaneva2joint(pos); 11 | 12 | if(iscell(handle)) 13 | for(i = 1:1:length(handle)) 14 | xyzhumanevaDraw(joint,handle{i}); 15 | end 16 | else 17 | xyzhumanevaDraw(joint,handle); 18 | end 19 | 20 | return 21 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/xyzhumanevaModify2.m: -------------------------------------------------------------------------------- 1 | function handle = xyzhumanevaModify2(handle,pos) 2 | 3 | % XYZHUMANEVAMODIFY2 4 | % 5 | % COPYRIGHT : Carl Henrik Ek and Neil Lawrence, 2008 6 | 7 | % MOCAP 8 | 9 | 10 | joint = xyzhumaneva2joint(pos); 11 | xyzhumanevaDraw(joint,handle{1}); 12 | xyzhumanevaDraw(joint,handle{2}); 13 | 14 | return 15 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/xyzhumanevaRemovePart.m: -------------------------------------------------------------------------------- 1 | function out = xyzhumanevaRemovePart(Z,type,limb_type) 2 | 3 | % XYZHUMANEVAREMOVEPART 4 | % 5 | % COPYRIGHT : Carl Henrik Ek and Neil Lawrence, 2008 6 | 7 | % MOCAP 8 | 9 | 10 | if(nargin<3) 11 | limb_type = 'head'; 12 | end 13 | 14 | switch type 15 | case 'jon' 16 | limb{1} = [1 2;2 3;3 4;4 5]; % left leg 17 | limb{2} = [1 6;6 7;7 8;8 9]; % right leg 18 | limb{3} = [19 10;10 11;11 12;12 13]; % left arm 19 | limb{4} = [19 14;14 15;15 16;16 17]; % right arm 20 | limb{5} = [1 19;19 18]; % head 21 | case 'raquel' 22 | limb{1} = [1 2;2 3;3 4;4 5]; % left leg 23 | limb{2} = [1 6;6 7;7 8;8 9]; % right leg 24 | limb{3} = [19 10;10 11;11 12;12 13]; % left arm 25 | limb{4} = [19 14;14 15;15 16;16 17]; % right arm 26 | limb{5} = [1 19;19 18]; % head 27 | otherwise 28 | error('Unkown parametrization'); 29 | end 30 | 31 | 32 | switch limb_type 33 | case 'head' 34 | limb_index = 19; 35 | end 36 | 37 | for(i = 1:1:size(Z,1)) 38 | pos = xyzhumaneva2joint(Z(i,:)); 39 | pos = pos(setdiff(1:1:size(pos,1),limb_index),:); 40 | out(i,:) = xyzhumanevaJoint2pos(pos); 41 | end 42 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/xyzhumanevaVisualise.m: -------------------------------------------------------------------------------- 1 | function handle = xyzhumanevaVisualise(pos,fid) 2 | 3 | % XYZHUMANEVAVISUALISE 4 | % 5 | % COPYRIGHT : Carl Henrik Ek and Neil Lawrence, 2008 6 | 7 | % MOCAP 8 | 9 | 10 | if(nargin<2) 11 | fid = 2; 12 | end 13 | 14 | figure(fid); 15 | 16 | % determine parametrization 17 | if(max(max(abs(pos)))<100) 18 | type = 'jon'; 19 | else 20 | type = 'raquel'; 21 | end 22 | 23 | switch type 24 | case 'raquel' 25 | if(size(pos(1,:),2)==54); 26 | type = 'raquelS3'; 27 | end 28 | end 29 | 30 | 31 | joint = xyzhumaneva2joint(pos); 32 | handle = xyzhumanevaDraw(joint,[],type);axis equal;view([1 0 0]); 33 | switch type 34 | case 'raquel' 35 | set(gca,'XLim',[-300 300],'YLim',[-300 300],'ZLim',[-800 800]); 36 | case 'jon' 37 | % Jon Parametrization 38 | set(gca,'XLim',[-0.35 0.35],'YLim',[-0.35 0.35],'ZLim',[-1 0.3]); 39 | end 40 | 41 | 42 | return 43 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/xyzhumanevaVisualise2.m: -------------------------------------------------------------------------------- 1 | function handle = xyzhumanevaVisualise2(pos,fid) 2 | 3 | % XYZHUMANEVAVISUALISE2 4 | % 5 | % COPYRIGHT : Carl Henrik Ek and Neil Lawrence, 2008 6 | 7 | % MOCAP 8 | 9 | 10 | if(nargin<2) 11 | fid = 2; 12 | end 13 | 14 | figure(fid); 15 | 16 | % determine parametrization 17 | if(max(max(abs(pos)))<100) 18 | type = 'jon'; 19 | else 20 | type = 'raquel'; 21 | end 22 | 23 | joint = xyzhumaneva2joint(pos); 24 | handle{1} = xyzhumanevaDraw(joint);axis equal;view([1 0 0]); 25 | switch type 26 | case 'raquel' 27 | set(gca,'XLim',[-300 300],'YLim',[-300 300],'ZLim',[-800 800]); 28 | case 'jon' 29 | set(gca,'XLim',[-0.35 0.35],'YLim',[-0.35 0.35],'ZLim',[-1 0.3]); 30 | end 31 | 32 | figure(fid+2); 33 | handle{2} = xyzhumanevaDraw(joint);axis equal;view([1 1 1]); 34 | switch type 35 | case 'raquel' 36 | set(gca,'XLim',[-300 300],'YLim',[-300 300],'ZLim',[-800 800]); 37 | case 'jon' 38 | set(gca,'XLim',[-0.35 0.35],'YLim',[-0.35 0.35],'ZLim',[-1 0.3]); 39 | end 40 | 41 | return 42 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/xyzhumanevaVisualise3d.m: -------------------------------------------------------------------------------- 1 | function handle = xyzhumanevaVisualise3d(pos,fid) 2 | 3 | % XYZHUMANEVAVISUALISE3D 4 | % 5 | % COPYRIGHT : Carl Henrik Ek and Neil Lawrence, 2008 6 | 7 | % MOCAP 8 | 9 | 10 | if(nargin<2) 11 | fid = 2; 12 | end 13 | 14 | figure(fid); 15 | 16 | % determine parametrization 17 | if(max(max(abs(pos)))<100) 18 | type = 'jon'; 19 | else 20 | type = 'raquel'; 21 | end 22 | 23 | joint = xyzhumaneva2joint(pos); 24 | figure(fid); 25 | handle = xyzhumanevaDraw(joint);axis equal;view([1 1 1]); 26 | switch type 27 | case 'raquel' 28 | set(gca,'XLim',[-300 300],'YLim',[-300 300],'ZLim',[-800 800]); 29 | case 'jon' 30 | set(gca,'XLim',[-0.35 0.35],'YLim',[-0.35 0.35],'ZLim',[-1 0.3]); 31 | end 32 | 33 | return 34 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/xyzpoppeAnim.m: -------------------------------------------------------------------------------- 1 | function xyzpoppeAnim(X, fps) 2 | 3 | % XYZPOPPEANIM Animate point cloud of stick man from Poppe dataset. 4 | % FORMAT 5 | % DESC animates a matrix of x,y,z point clound positions representing the 6 | % motion of the figure used to generate the silhouttes for Poppe 7 | % Silhouette data 8 | % ARG y : the data to animate. 9 | % ARG fps : the number of frames per second to animate (defaults to 24). 10 | % 11 | % SEEALSO : xyzpoppeVisualise, xyzpoppeModify 12 | % 13 | % COPYRIGHT : Carl Henrik Ek and Neil Lawrence, 2008 14 | 15 | % MOCAP 16 | 17 | if(nargin<3) 18 | fps = 24; 19 | if(nargin<2) 20 | fid = 1; 21 | if(nargin<1) 22 | error('Too few arguments'); 23 | end 24 | end 25 | end 26 | 27 | for(i = 1:1:size(X,1)) 28 | if(i==1) 29 | handle = xyzpoppeVisualise(X(i,:),1); 30 | else 31 | xyzpoppeModify(handle,X(i,:)); 32 | end 33 | pause(1/fps); 34 | end 35 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/xyzpoppeModify.m: -------------------------------------------------------------------------------- 1 | function handle = xyzpoppeModify(handle,pos) 2 | 3 | % XYZPOPPEMODIFY 4 | % 5 | % COPYRIGHT : Carl Henrik Ek and Neil Lawrence, 2008 6 | 7 | % MOCAP 8 | 9 | 10 | joint = xyzpoppe2joint(pos); 11 | 12 | if(iscell(handle)) 13 | for(i = 1:1:length(handle)) 14 | xyzpoppeDraw(joint,handle{i}); 15 | end 16 | else 17 | xyzpoppeDraw(joint,handle); 18 | end 19 | 20 | return 21 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/matlab/xyzpoppeVisualise.m: -------------------------------------------------------------------------------- 1 | function handle = xyzpoppeVisualise(pos,fid) 2 | 3 | % XYZPOPPEVISUALISE Draw the Poppe figure return the graphics handle. 4 | % FORMAT 5 | % DESC draws the stick figure from the Poppe silhouette 6 | % data. 7 | % ARG pos : the positions of the joints. 8 | % ARG v : the view point for the figure (defaults to standard 3D view). 9 | % RETURN handle : the graphics handle of the drawn object. 10 | % 11 | % SEEALSO : xyzpoppeDraw, xyzpoppeModify 12 | % 13 | % COPYRIGHT : Carl Henrik Ek and Neil Lawrence, 2008 14 | 15 | % MOCAP 16 | 17 | if(nargin<2); 18 | fid = 1; 19 | end 20 | 21 | % Convert positions for plotting. 22 | joint = xyzpoppe2joint(pos); 23 | handle = xyzpoppeDraw(joint); 24 | axis equal 25 | view(3); 26 | 27 | xlabel('x'); 28 | ylabel('z'); 29 | zlabel('y'); 30 | axis on 31 | 32 | return; 33 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mhmublv/Data/data.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/computer-animation-perception-group/DeepDance/28be6b7ad6232b86e80524ba28d673154b643bcf/m2m_evaluation/matlab-file/mhmublv/Data/data.mat -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mhmublv/Motion/batchConvertCMU.m: -------------------------------------------------------------------------------- 1 | % Version 1.01 2 | % 3 | % Code provided by Graham Taylor, Geoff Hinton and Sam Roweis 4 | % 5 | % For more information, see: 6 | % http://www.cs.toronto.edu/~gwtaylor/publications/nips2006mhmublv 7 | % 8 | % Permission is granted for anyone to copy, use, modify, or distribute this 9 | % program and accompanying programs and documents for any purpose, provided 10 | % this copyright notice is retained and prominently displayed, along with 11 | % a note saying that the original programs are available from our 12 | % web page. 13 | % The programs and documents are distributed without any warranty, express or 14 | % implied. As the programs were written for research purposes only, they have 15 | % not been tested to the degree that would be advisable in any important 16 | % application. All use of these programs is entirely at the user's own risk. 17 | 18 | % For a series of sequences stored in the cell array Motion 19 | % Go through each, and convert CMU "Euler" data to exponential maps 20 | 21 | for jj = 1:length(Motion) 22 | for ii=1:size(Motion{jj},1) 23 | [skel1,Motion1{jj}(ii,:)] = euler2expmap(skel,Motion{jj}(ii,:)); 24 | end 25 | end -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mhmublv/Motion/dropframes.m: -------------------------------------------------------------------------------- 1 | % Version 1.01 2 | % 3 | % Code provided by Graham Taylor, Geoff Hinton and Sam Roweis 4 | % 5 | % For more information, see: 6 | % http://www.cs.toronto.edu/~gwtaylor/publications/nips2006mhmublv 7 | % 8 | % Permission is granted for anyone to copy, use, modify, or distribute this 9 | % program and accompanying programs and documents for any purpose, provided 10 | % this copyright notice is retained and prominently displayed, along with 11 | % a note saying that the original programs are available from our 12 | % web page. 13 | % The programs and documents are distributed without any warranty, express or 14 | % implied. As the programs were written for research purposes only, they have 15 | % not been tested to the degree that would be advisable in any important 16 | % application. All use of these programs is entirely at the user's own risk. 17 | 18 | % Drop frames in cell array Motion so that we only take every 4th frame 19 | % A dirty downsampling from 120fps to 30fps 20 | 21 | for ii=1:length(Motion) 22 | Motion{ii}=Motion{ii}(1:dropRate:end,:); 23 | end 24 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mhmublv/Motion/expmap2rotmat.m: -------------------------------------------------------------------------------- 1 | function R=expmap2rotmat(r); 2 | 3 | % Software provided by Hao Zhang 4 | % http://www.cs.berkeley.edu/~nhz/software/rotations 5 | % 6 | % function R=expmap2rotmat(r); 7 | % convert exponential map r into a rotation matrix R 8 | % 9 | % denote the axis of rotation by unit vector r0, the angle by theta 10 | % r is of the form r0*theta 11 | 12 | theta=norm(r); 13 | r0=r/(norm(r)+eps); 14 | %if (theta>pi) 15 | % warning('expmap2rotmat: exp map rotation angle > pi, not in canonical form'); 16 | %end 17 | r0x=[0 -r0(3) r0(2);0 0 -r0(1); 0 0 0]; 18 | r0x=r0x-r0x'; 19 | R=eye(3,3)+sin(theta)*r0x+(1-cos(theta))*r0x*r0x; 20 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mhmublv/Motion/postprocess.m: -------------------------------------------------------------------------------- 1 | % Version 1.01 2 | % 3 | % Code provided by Graham Taylor, Geoff Hinton and Sam Roweis 4 | % 5 | % For more information, see: 6 | % http://www.cs.toronto.edu/~gwtaylor/publications/nips2006mhmublv 7 | % 8 | % Permission is granted for anyone to copy, use, modify, or distribute this 9 | % program and accompanying programs and documents for any purpose, provided 10 | % this copyright notice is retained and prominently displayed, along with 11 | % a note saying that the original programs are available from our 12 | % web page. 13 | % The programs and documents are distributed without any warranty, express or 14 | % implied. As the programs were written for research purposes only, they have 15 | % not been tested to the degree that would be advisable in any important 16 | % application. All use of these programs is entirely at the user's own risk. 17 | % 18 | % This program calls the two post-processing 19 | % It is intended to be called after generating a sequence 20 | % It assumes the generated sequence is in "visible" 21 | % It writes the post-processed sequence to "newdata" 22 | 23 | %assemble the data back into the "body-centred" coordinates and scale back 24 | postprocess1 25 | %back into reference coordinate system 26 | postprocess2 -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mhmublv/Motion/quat2expmap.m: -------------------------------------------------------------------------------- 1 | function [r]=quat2expmap(q) 2 | 3 | % Software provided by Hao Zhang 4 | % http://www.cs.berkeley.edu/~nhz/software/rotations 5 | % 6 | % function [r]=quat2expmap(q) 7 | % convert quaternion q into exponential map r 8 | % 9 | % denote the axis of rotation by unit vector r0, the angle by theta 10 | % q is of the form (cos(theta/2), r0*sin(theta/2)) 11 | % r is of the form r0*theta 12 | 13 | if (abs(norm(q)-1)>1E-3) 14 | error('quat2expmap: input quaternion is not norm 1'); 15 | end 16 | sinhalftheta=norm(q(2:4)); 17 | coshalftheta=q(1); 18 | r0=q(2:4)/(norm(q(2:4))+eps); 19 | theta=2*atan2(sinhalftheta,coshalftheta); 20 | theta=mod(theta+2*pi,2*pi); 21 | %if (theta>pi), theta=2*pi-theta; r0=-r0; end 22 | if (theta>pi) 23 | theta=2*pi-theta; 24 | r0=-r0; 25 | end 26 | r=r0*theta; 27 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mhmublv/Motion/rotmat2expmap.m: -------------------------------------------------------------------------------- 1 | function r=rotmat2expmap(R) 2 | 3 | % Software provided by Hao Zhang 4 | % http://www.cs.berkeley.edu/~nhz/software/rotations 5 | 6 | r=quat2expmap(rotmat2quat(R)); 7 | 8 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mhmublv/Motion/rotmat2quat.m: -------------------------------------------------------------------------------- 1 | % Software provided by Hao Zhang 2 | % http://www.cs.berkeley.edu/~nhz/software/rotations 3 | 4 | function q=rotmat2quat(R) 5 | % function q=rotmat2quat(R) 6 | % convert a rotation matrix R into unit quaternion q 7 | % 8 | % denote the axis of rotation by unit vector r0, the angle by theta 9 | % q is of the form (cos(theta/2), r0*sin(theta/2)) 10 | 11 | %if (norm(R*R'-eye(3,3))>1E-10 || det(R)<0), 12 | % error('rotmat2quat: input matrix is not a rotation matrix'); 13 | %end 14 | d=R-R'; 15 | r(1)=-d(2,3); 16 | r(2)=d(1,3); 17 | r(3)=-d(1,2); 18 | sintheta=norm(r)/2; 19 | r0=r/(norm(r)+eps); 20 | costheta=(trace(R)-1)/2; 21 | 22 | theta=atan2(sintheta,costheta); 23 | q=[cos(theta/2) r0*sin(theta/2)]; 24 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mhmublv/Motion/skelConnectionMatrix.m: -------------------------------------------------------------------------------- 1 | function connection = skelConnectionMatrix(skel); 2 | 3 | % SKELCONNECTIONMATRIX Compute the connection matrix for the structure. 4 | % 5 | % connection = skelConnectionMatrix(skel); 6 | % 7 | 8 | % Copyright (c) 2006 Neil D. Lawrence 9 | % skelConnectionMatrix.m version 1.1 10 | 11 | connection = zeros(length(skel.tree)); 12 | for i = 1:length(skel.tree); 13 | for j = 1:length(skel.tree(i).children) 14 | connection(i, skel.tree(i).children(j)) = 1; 15 | end 16 | end 17 | 18 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mhmublv/Results/layer1.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/computer-animation-perception-group/DeepDance/28be6b7ad6232b86e80524ba28d673154b643bcf/m2m_evaluation/matlab-file/mhmublv/Results/layer1.mat -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mhmublv/Results/layer2.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/computer-animation-perception-group/DeepDance/28be6b7ad6232b86e80524ba28d673154b643bcf/m2m_evaluation/matlab-file/mhmublv/Results/layer2.mat -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/NDLUTIL-161/centeringMatrix.m: -------------------------------------------------------------------------------- 1 | function H = centeringMatrix(dim) 2 | 3 | % CENTERINGMATRIX returns the centering matrix for the given dimensionality. 4 | % 5 | % Description: 6 | % 7 | % H = CENTERINGMATRIX(DIM) returns the centering matrix for the given 8 | % dimensionality. 9 | % Returns: 10 | % H - the centering matrix for the given dimensionality. 11 | % Arguments: 12 | % DIM - the dimensionality of the centering matrix. 13 | % 14 | % 15 | % See also 16 | % EYE 17 | 18 | 19 | % Copyright (c) 2008 Neil D. Lawrence 20 | % centeringMatrix.m CVS version 1.1 21 | % centeringMatrix.m SVN version 22 22 | % last update 2008-01-10T15:50:21.000000Z 23 | 24 | H = -repmat(1./dim, dim, dim) + speye(dim); -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/NDLUTIL-161/cumGamma.m: -------------------------------------------------------------------------------- 1 | function y = cumGamma(x, a, b) 2 | 3 | % CUMGAMMA Cumulative distribution for gamma. 4 | % 5 | % Description: 6 | % 7 | % P = CUMGAMMA(X) computes the cumulative gamma distribution. 8 | % Returns: 9 | % P - output probability. 10 | % Arguments: 11 | % X - input value. 12 | % 13 | % 14 | % See also 15 | % GAMMAINC, GAMMA 16 | 17 | 18 | % Copyright (c) 2008 Neil D. Lawrence 19 | % cumGamma.m SVN version 22 20 | % last update 2008-06-27T13:16:15.000000Z 21 | 22 | y = gammainc(x*b, a); 23 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/NDLUTIL-161/cumGaussian.m: -------------------------------------------------------------------------------- 1 | function y = cumGaussian(x) 2 | 3 | % CUMGAUSSIAN Cumulative distribution for Gaussian. 4 | % 5 | % Description: 6 | % 7 | % P = CUMGAUSSIAN(X) computes the cumulative Gaussian distribution. 8 | % Returns: 9 | % P - output probability. 10 | % Arguments: 11 | % X - input value. 12 | % 13 | % 14 | % See also 15 | % LNCUMGAUSSIAN, LNDIFFCUMGAUSSIAN, ERF 16 | 17 | 18 | % Copyright (c) 2004 Neil D. Lawrence 19 | % cumGaussian.m CVS version 1.2 20 | % cumGaussian.m SVN version 22 21 | % last update 2007-11-03T14:25:21.000000Z 22 | 23 | y = 0.5*(1+erf(sqrt(2)/2*x)); 24 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/NDLUTIL-161/defaultOptions.m: -------------------------------------------------------------------------------- 1 | function options = defaultOptions; 2 | 3 | % DEFAULTOPTIONS The default options for optimisation. 4 | % 5 | % Description: 6 | % 7 | % OPTIONS = DEFAULTOPTIONS returns a default options vector for 8 | % optimisation. 9 | % Returns: 10 | % OPTIONS - the default options vector. 11 | % 12 | % 13 | % See also 14 | % SCG, CONJGRAD, QUASINEW 15 | 16 | 17 | % Copyright (c) 2005, 2006 Neil D. Lawrence 18 | % defaultOptions.m CVS version 1.2 19 | % defaultOptions.m SVN version 22 20 | % last update 2007-11-03T14:25:21.000000Z 21 | 22 | options = [0, 1e-4, 1e-4, 1e-6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1e-8, 0.1, 0]; -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/NDLUTIL-161/deg2rad.m: -------------------------------------------------------------------------------- 1 | function theta = deg2rad(omega) 2 | 3 | % DEG2RAD Transform degrees to radians. 4 | % 5 | % Description: 6 | % 7 | % DEG2RAD(OMEGA, THETA) onverts degrees to radians. 8 | % Arguments: 9 | % OMEGA - angle in degrees. 10 | % THETA - angle in radians. 11 | 12 | 13 | % Copyright (c) 2005 Neil D. Lawrence 14 | % deg2rad.m CVS version 1.2 15 | % deg2rad.m SVN version 22 16 | % last update 2007-11-03T14:26:20.000000Z 17 | 18 | theta = omega/180*pi; -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/NDLUTIL-161/gammaPdf.m: -------------------------------------------------------------------------------- 1 | function [p, lnp] = gammaPdf(x, a, b) 2 | 3 | % GAMMAPDF PDF for the Gamma distribution. 4 | % 5 | % Description: 6 | % 7 | % [P, LNP] = GAMMAPDF(X, A, B) computes the pdf of the gamma 8 | % distribution. 9 | % Returns: 10 | % P - probability of the gamma distribution. 11 | % LNP - log of the probability. 12 | % Arguments: 13 | % X - locations where the PDF is to be computed. 14 | % A - shape parameter of the gamma distribution. 15 | % B - rate parameter of the gamma distribuion (inverse scale). 16 | % 17 | % 18 | % See also 19 | % % SEEALSO CUMGAMMA 20 | 21 | 22 | % Copyright (c) 2008 Neil D. Lawrence 23 | % gammaPdf.m SVN version 23 24 | % last update 2008-07-11T15:19:45.000000Z 25 | 26 | 27 | lnp = a*log(b) - gammaln(a) + (a-1)*log(x) - b*x; 28 | p = exp(lnp); -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/NDLUTIL-161/gaussSamp.m: -------------------------------------------------------------------------------- 1 | function y = gaussSamp(Sigma, numSamps) 2 | 3 | % GAUSSSAMP Sample from a Gaussian with a given covariance. 4 | % 5 | % Description: 6 | % 7 | % Y = GAUSSSAMP(SIGMA, NUMSAMPS) samples a given number of samples 8 | % from a Gaussian with a given covariance matrix. 9 | % Returns: 10 | % Y - the samples from the Gaussian 11 | % Arguments: 12 | % SIGMA - the covariance of the Gaussian to sample from. 13 | % NUMSAMPS - the number of samples to take from Gaussian. 14 | % 15 | % 16 | % See also 17 | % RANDN, EIG 18 | 19 | 20 | % Copyright (c) 2005 Neil D. Lawrence 21 | % gaussSamp.m CVS version 1.2 22 | % gaussSamp.m SVN version 22 23 | % last update 2007-11-03T14:25:21.000000Z 24 | 25 | [U, V] = eig(Sigma); 26 | dims = size(Sigma, 1); 27 | y = randn(numSamps, dims); 28 | y = y*diag(sqrt(diag(V))); 29 | y = y*U'; -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/NDLUTIL-161/getSymbols.m: -------------------------------------------------------------------------------- 1 | function symbol = getSymbols(number) 2 | 3 | % GETSYMBOLS Get a cell array of different plot symbols. 4 | % 5 | % Description: 6 | % 7 | % SYMBOL = GETSYMBOLS(NUMBER) returns a cell array of different plot 8 | % symbols. A maximum of 66 distinct symbols will be created. 9 | % Returns: 10 | % SYMBOL - cell array of the different symbols. 11 | % Arguments: 12 | % NUMBER - the number of different plot symbols required. 13 | % 14 | % 15 | % See also 16 | % PLOT 17 | 18 | 19 | % Copyright (c) 2005 Neil D. Lawrence 20 | % getSymbols.m CVS version 1.3 21 | % getSymbols.m SVN version 22 22 | % last update 2009-01-11T09:28:55.000000Z 23 | 24 | symbolColour = {'r', 'g', 'b', 'c', 'm'}; %, 'y'}; 25 | symbolShape = {'x', 'o', '+', '*', 's', 'd', 'v', '^', '<', '>', 'p'}; 26 | counter = 0; 27 | while counter < number 28 | symbol{counter+1} = [symbolColour{rem(counter, length(symbolColour))+1} ... 29 | symbolShape{rem(counter, length(symbolShape))+1}]; 30 | counter = counter +1; 31 | end -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/NDLUTIL-161/getline.m: -------------------------------------------------------------------------------- 1 | function lineStr = getline(FID, comment) 2 | 3 | % GETLINE Get a line from a file. 4 | % 5 | % Description: 6 | % 7 | % LINESTR = GETLINE(FID, COMMENT) gets a line from a file, but ignore 8 | % it if it starts with a comment character. 9 | % Returns: 10 | % LINESTR - the next line in the file. 11 | % Arguments: 12 | % FID - the identity of the file to load from. 13 | % COMMENT - the character that indicates a line is a comment 14 | % (default #). 15 | % 16 | % 17 | % See also 18 | % FGETL, FOPEN 19 | 20 | 21 | % Copyright (c) 2005 Neil D. Lawrence 22 | % getline.m CVS version 1.3 23 | % getline.m SVN version 22 24 | % last update 2007-11-03T14:25:21.000000Z 25 | 26 | 27 | if nargin < 2 28 | comment = '#'; 29 | end 30 | if length(comment)~=1 31 | error('Comment can only be one character in length'); 32 | end 33 | lineStr = fgetl(FID); 34 | if length(lineStr)==0 35 | return 36 | end 37 | while lineStr(1)==comment 38 | lineStr = fgetl(FID); 39 | end -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/NDLUTIL-161/gradLnDiffErfs.m: -------------------------------------------------------------------------------- 1 | function [dlnPart, m] = gradLnDiffErfs(x1, x2, fact1, fact2), 2 | 3 | % GRADLNDIFFERFS Compute the gradient of the log difference of two erfs. 4 | % 5 | % Description: 6 | % 7 | % 8 | 9 | 10 | % Copyright (c) 2007 Antti Honkela 11 | % gradLnDiffErfs.m CVS version 1.1 12 | % gradLnDiffErfs.m SVN version 22 13 | % last update 2007-12-18T12:39:23.000000Z 14 | 15 | m = min(x1.^2, x2.^2); 16 | dlnPart = 2/sqrt(pi) * (exp(-x1.^2 + m) .* fact1 ... 17 | - exp(-x2.^2 + m) .* fact2); 18 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/NDLUTIL-161/gradLogCumGaussian.m: -------------------------------------------------------------------------------- 1 | function y = gradLogCumGaussian(x) 2 | 3 | % GRADLOGCUMGAUSSIAN Gradient of the log of the cumulative Gaussian. 4 | % 5 | % Description: 6 | % 7 | % GRADLOGCUMGAUSSIAN(X, Y) returns the gradient of the logarithm of 8 | % the cumulative Gaussian. Theoretically this is simply 9 | % ngaussian(x)/cumGaussian(x) but there are problems in the tails of 10 | % the distribution. This function attempts to deal with these problems 11 | % without numerical error creeping in. 12 | % Arguments: 13 | % X - the input to the function. 14 | % Y - the gradient of the log cumulative Gaussian. 15 | % 16 | % 17 | % See also 18 | % NGAUSSIAN, CUMGAUSSIAN, ERFCX 19 | 20 | 21 | % Copyright (c) 2005 Neil D. Lawrence 22 | % gradLogCumGaussian.m CVS version 1.2 23 | % gradLogCumGaussian.m SVN version 22 24 | % last update 2007-11-03T14:25:21.000000Z 25 | 26 | 27 | y = zeros(size(x)); 28 | index = find(x>0); 29 | y(index) = ngaussian(x(index))./cumGaussian(x(index)); 30 | index = find(x<=0); 31 | y(index) = 1./(sqrt(2*pi)*0.5*erfcx(-sqrt(2)/2*x(index))); 32 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/NDLUTIL-161/invCumGaussian.m: -------------------------------------------------------------------------------- 1 | function y = invCumGaussian(x) 2 | 3 | % INVCUMGAUSSIAN Computes inverse of the cumulative Gaussian. 4 | % 5 | % Description: 6 | % 7 | % Y = INVCUMGAUSSIAN(X) computes the inverse of the cumulative 8 | % Gaussian. 9 | % Returns: 10 | % Y - the inverse of the cumulative Gaussian. 11 | % Arguments: 12 | % X - value between 0 and 1 to map onto the real line. 13 | % 14 | % 15 | % See also 16 | % CUMGAUSSIAN, ERFINV 17 | 18 | 19 | % Copyright (c) 2005 Neil D. Lawrence 20 | % invCumGaussian.m CVS version 1.3 21 | % invCumGaussian.m SVN version 22 22 | % last update 2008-04-01T11:00:23.000000Z 23 | 24 | y = erfinv(x*2 - 1)*2/sqrt(2); -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/NDLUTIL-161/invSigmoid.m: -------------------------------------------------------------------------------- 1 | function y=invSigmoid(x) 2 | 3 | % INVSIGMOID The inverse of the sigmoid function. 4 | % 5 | % Description: 6 | % 7 | % INVSIGMOID(X, Y) returns the inverse of the sigmoid function (which 8 | % takes the form y=log(x/(1-x)). 9 | % Arguments: 10 | % X - the input to the inverse of the sigmoid (should be between 0 11 | % and 1). 12 | % Y - the inverse of the sigmoid. 13 | % 14 | % 15 | % See also 16 | % SIGMOID 17 | 18 | 19 | % Copyright (c) 2004 Neil D. Lawrence 20 | % invSigmoid.m CVS version 1.2 21 | % invSigmoid.m SVN version 22 22 | % last update 2007-11-03T14:26:20.000000Z 23 | 24 | y = log(x./(1-x)); -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/NDLUTIL-161/isoctave.m: -------------------------------------------------------------------------------- 1 | function answer = isoctave 2 | 3 | % ISOCTAVE Returns true if the software running is Octave. 4 | % 5 | % Description: 6 | % 7 | % ANSWER = ISOCTAVE tests if the software is octave or not. 8 | % Returns: 9 | % ANSWER - true if the software is octave. 10 | 11 | 12 | % Copyright (c) 2008 Neil D. Lawrence 13 | % isoctave.m SVN version 22 14 | % last update 2008-05-11T07:08:04.000000Z 15 | 16 | try 17 | v = OCTAVE_VERSION; 18 | answer = true; 19 | catch 20 | answer = false; 21 | return 22 | end -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/NDLUTIL-161/kldivGaussian.m: -------------------------------------------------------------------------------- 1 | function kl = kldivGaussian(mean1, cov1, mean2, cov2) 2 | 3 | % KLDIVGAUSSIAN Give the KL divergence between two Gaussians. 4 | % 5 | % Description: 6 | % 7 | % KLDIVGAUSSIAN(MEAN1, COV1, MEAN2, COV2) returns the Kullback-Leibler 8 | % divergence between two Gaussians with given means and covariances. 9 | % Arguments: 10 | % MEAN1 - mean of the first Gaussian. 11 | % COV1 - covariance of the first Gaussian. 12 | % MEAN2 - mean of the second Gaussian. 13 | % COV2 - covariance of the second Gaussian. 14 | % 15 | % 16 | % See also 17 | % LOGDET, PDINV 18 | 19 | 20 | % Copyright (c) 2005 Neil D. Lawrence 21 | % kldivGaussian.m CVS version 1.3 22 | % kldivGaussian.m SVN version 22 23 | % last update 2007-11-03T14:25:20.000000Z 24 | 25 | [invCov2, U] = pdinv(cov2); 26 | logDet2 = logdet(cov2, U); 27 | logDet1 = logdet(cov1); 28 | N = size(cov1, 1); 29 | meanDiff = mean1 - mean2; 30 | if size(meanDiff, 1) == 1 31 | meanDiff = meanDiff'; 32 | end 33 | kl = -0.5*(logDet1 - logDet2 - trace(cov1*invCov2) ... 34 | + N - meanDiff'*invCov2*meanDiff); 35 | 36 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/NDLUTIL-161/lnCumGaussian.m: -------------------------------------------------------------------------------- 1 | function y = lnCumGaussian(x) 2 | 3 | % LNCUMGAUSSIAN log cumulative distribution for the normalised Gaussian. 4 | % 5 | % Description: 6 | % 7 | % Y = LNCUMGAUSSIAN(X) computes the logarithm of the cumulative 8 | % Gaussian distribution. 9 | % Returns: 10 | % Y - log probability of the value under the cumulative Gaussian. 11 | % Arguments: 12 | % X - input position. 13 | % 14 | % 15 | % See also 16 | % ERF, ERFCX, CUMGAUSSIAN, LNDIFFCUMGAUSSIAN, GAUSSOVERDIFFCUMGAUSSIAN 17 | 18 | 19 | % Copyright (c) 2004, 2005, 2006 Neil D. Lawrence 20 | % lnCumGaussian.m CVS version 1.2 21 | % lnCumGaussian.m SVN version 22 22 | % last update 2007-11-03T14:26:20.000000Z 23 | 24 | index = find(x< 0); 25 | if length(index) 26 | y(index) = -.5*x(index).*x(index) + log(.5) + log(erfcx(-sqrt(2)/2* ... 27 | x(index))); 28 | end 29 | index = find(x>=0); 30 | if length(index) 31 | y(index) = log(cumGaussian(x(index))); 32 | end 33 | y=reshape(y, size(x)); -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/NDLUTIL-161/lnDiffCumGaussian.m: -------------------------------------------------------------------------------- 1 | function f = lnDiffCumGaussian(u, uprime) 2 | 3 | % LNDIFFCUMGAUSSIAN Log of the difference between two cumulative Gaussians. 4 | % 5 | % Description: 6 | % 7 | % F = LNDIFFCUMGAUSSIAN(U1, U2) computes the logarithm of the 8 | % difference between two cumulative Gaussian distributions. 9 | % Returns: 10 | % F - where f = log(cumGaussian(u1) - cumGaussian(u2)). 11 | % Arguments: 12 | % U1 - the argument of the first (positive) cumulative Gaussian. 13 | % U2 - the argument of the second (negative) cumulative Gaussian. 14 | % 15 | % 16 | % See also 17 | % CUMGAUSSIAN, GAUSSOVERDIFFCUMGAUSSIAN, LNCUMGAUSSIAN 18 | 19 | 20 | % Copyright (c) 2005, 2006 Neil D. Lawrence 21 | % lnDiffCumGaussian.m CVS version 1.2 22 | % lnDiffCumGaussian.m SVN version 22 23 | % last update 2007-11-03T14:25:20.000000Z 24 | 25 | f = log(gaussOverDiffCumGaussian(u, uprime, 1)+1e-300) ... 26 | + .5*u.*u + .5*log(2*pi); 27 | f=-f; -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/NDLUTIL-161/ndlutilToolboxes.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/computer-animation-perception-group/DeepDance/28be6b7ad6232b86e80524ba28d673154b643bcf/m2m_evaluation/matlab-file/mocap/NDLUTIL-161/ndlutilToolboxes.m -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/NDLUTIL-161/negLogLogit.m: -------------------------------------------------------------------------------- 1 | function y = negLogLogit(x) 2 | 3 | % NEGLOGLOGIT Function which returns the negative log of the logistic function. 4 | % 5 | % Description: 6 | % 7 | % Y = NEGLOGLOGIT(X) computes the negative log of the logistic 8 | % (sigmoid) function, which is also the integral of the sigmoid 9 | % function. 10 | % Returns: 11 | % Y - the negative log of the logistic. 12 | % Arguments: 13 | % X - input locations. 14 | % 15 | % 16 | % See also 17 | % SIGMOID 18 | 19 | 20 | % Copyright (c) 2006 Neil D. Lawrence 21 | % negLogLogit.m CVS version 1.1 22 | % negLogLogit.m SVN version 22 23 | % last update 2007-11-03T14:25:20.000000Z 24 | 25 | y = log(1+exp(x)); -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/NDLUTIL-161/ngaussian.m: -------------------------------------------------------------------------------- 1 | function y = ngaussian(x) 2 | 3 | % NGAUSSIAN Compute a Gaussian with mean 0 and variance 1. 4 | % 5 | % Description: 6 | % 7 | % Y = NGAUSSIAN(X) computes a the likelihood of a normalised Gaussian 8 | % distribution, i.e. with mean 0 and variance 1. 9 | % Returns: 10 | % Y - probability of the input values under the Gaussian. 11 | % Arguments: 12 | % X - input value(s) for which to compute the distribution. 13 | % 14 | % 15 | % See also 16 | % CUMGAUSSIAN, GAUSSOVERDIFFCUMGAUSSIAN 17 | 18 | 19 | % Copyright (c) 2004 Neil D. Lawrence 20 | % ngaussian.m CVS version 1.2 21 | % ngaussian.m SVN version 22 22 | % last update 2007-11-03T14:25:20.000000Z 23 | 24 | x2 = x.*x; 25 | y = exp(-.5*x2); 26 | y = y/sqrt(2*pi); 27 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/NDLUTIL-161/numsf2str.m: -------------------------------------------------------------------------------- 1 | function str = numsf2str(num, sf); 2 | 3 | % NUMSF2STR Convert number to a string with a number of significant digits. 4 | % 5 | % Description: 6 | % 7 | % STR = NUMSF2STR(NUM, SF) converts a number to a string with a given 8 | % number of significant digits. 9 | % Returns: 10 | % STR - the string containing the number with the given number of 11 | % significant digits. 12 | % Arguments: 13 | % NUM - the number to convert. 14 | % SF - the number of significant figures to show in the string. 15 | % 16 | % 17 | % See also 18 | % NUM2STR, FPRINTF 19 | 20 | 21 | % Copyright (c) 2005 Neil D. Lawrence 22 | % numsf2str.m CVS version 1.2 23 | % numsf2str.m SVN version 22 24 | % last update 2007-11-03T14:25:20.000000Z 25 | 26 | val = chop(num, sf); 27 | str = num2str(val, sf); 28 | tail = []; 29 | ePos = find(str == 'e'); 30 | if ~isempty(ePos) 31 | tail = str(ePos:end); 32 | str = str(1:ePos-1); 33 | end 34 | ind = 1; 35 | while str(ind) == '0' | str(ind) == '.' 36 | ind = ind+1; 37 | end 38 | count = 0; 39 | while(ind <= length(str)) 40 | if str(ind) ~= '.' 41 | count = count + 1; 42 | end 43 | ind = ind +1; 44 | end 45 | while count < sf 46 | str = [str '0']; 47 | count = count + 1; 48 | end 49 | str = [str tail]; -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/NDLUTIL-161/preparePlot.m: -------------------------------------------------------------------------------- 1 | function preparePlot(limitVal, ax) 2 | 3 | % PREPAREPLOT Helper function for tidying up the plot before printing. 4 | % 5 | % Description: 6 | % 7 | % PREPAREPLOT(LIMITVAL, AX) is a helper function for tidying up a plot 8 | % before printing. 9 | % Arguments: 10 | % LIMITVAL - the limits to be applied to the axes. 11 | % AX - the axes to apply the plot preparation to. 12 | % 13 | % 14 | % See also 15 | % ZEROAXES 16 | 17 | 18 | % Copyright (c) 2005 Neil D. Lawrence 19 | % preparePlot.m CVS version 1.3 20 | % preparePlot.m SVN version 22 21 | % last update 2008-01-22T18:56:47.000000Z 22 | 23 | axis equal 24 | 25 | if nargin < 2 26 | ax = gca; 27 | end 28 | set(ax, 'xlim', limitVal); 29 | set(ax, 'ylim', limitVal); 30 | xlim = get(ax, 'xlim'); 31 | ylim = get(ax, 'ylim'); 32 | 33 | xlim(1) = floor(xlim(1)); 34 | xlim(2) = ceil(xlim(2)); 35 | ylim(1) = floor(ylim(1)); 36 | ylim(2) = ceil(ylim(2)); 37 | 38 | set(ax, 'xlim', xlim); 39 | set(ax, 'ylim', ylim); 40 | 41 | dirs(1) = max([xlim(1) ylim(1)]); 42 | dirs(2) = min([xlim(2) ylim(2)]); 43 | 44 | line(dirs, dirs); 45 | line(dirs, dirs+1); 46 | line(dirs, dirs-1); 47 | 48 | zeroaxes(ax, 0.02, 18, 'times') 49 | 50 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/NDLUTIL-161/readBinaryDoubles.m: -------------------------------------------------------------------------------- 1 | function vec = readBinaryDoubles(fileName, format) 2 | 3 | % READBINARYDOUBLES Read information from a binary file in as doubles. 4 | % 5 | % Description: 6 | % 7 | % VEC = READBINARYDOUBLES(FILENAME, FORMAT) reads in information from 8 | % a binary file as a vector of doubles. 9 | % Returns: 10 | % VEC - vector of values in the file. 11 | % Arguments: 12 | % FILENAME - the name of the file. 13 | % FORMAT - the file format for 'fopen', defaults to 'ieee-le'. 14 | % 15 | % 16 | % See also 17 | % FOPEN, FREAD, FCLOSE 18 | 19 | 20 | % Copyright (c) 2009 Neil D. Lawrence 21 | % readBinaryDoubles.m SVN version 336 22 | % last update 2009-04-22T21:32:23.000000Z 23 | 24 | if nargin < 2 25 | format = 'ieee-le'; 26 | end 27 | fid = fopen(fileName, 'r', format); 28 | vec = fread(fid, inf, 'double')'; 29 | fclose(fid); 30 | end -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/NDLUTIL-161/readBoolFromFID.m: -------------------------------------------------------------------------------- 1 | function val = readBoolFromFID(FID, string) 2 | 3 | % READBOOLFROMFID Read a boolean from an FID. 4 | % 5 | % Description: 6 | % 7 | % VAL = READBOOLFROMFID(FID, NAME) reads a boolean from a stream. 8 | % Returns: 9 | % VAL - value of variable in file. 10 | % Arguments: 11 | % FID - stream to read from. 12 | % NAME - name of boolean. 13 | % 14 | % 15 | % See also 16 | % WRITEBOOLTOFID, READINTFROMFID, READDOUBLEFROMFID 17 | 18 | 19 | % Copyright (c) 2008 Neil D. Lawrence 20 | % readBoolFromFID.m SVN version 23 21 | % last update 2008-07-11T15:18:36.000000Z 22 | 23 | 24 | val = str2num(readStringFromFID(FID, string)); 25 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/NDLUTIL-161/readDoubleFromFID.m: -------------------------------------------------------------------------------- 1 | function val = readDoubleFromFID(FID, string) 2 | 3 | % READDOUBLEFROMFID Read a double from an FID. 4 | % 5 | % Description: 6 | % 7 | % VAL = READDOUBLEFROMFID(FID, NAME) reads a double from a stream. 8 | % Returns: 9 | % VAL - value of variable in file. 10 | % Arguments: 11 | % FID - stream to read from. 12 | % NAME - name of double. 13 | % 14 | % 15 | % See also 16 | % WRITEDOUBLETOFID, READINTFROMFID, READBOOLFROMFID, READSTRINGFROMFID 17 | 18 | 19 | % Copyright (c) 2008 Neil D. Lawrence 20 | % readDoubleFromFID.m SVN version 23 21 | % last update 2008-07-11T15:18:23.000000Z 22 | 23 | val = str2num(readStringFromFID(FID, string)); 24 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/NDLUTIL-161/readIntFromFID.m: -------------------------------------------------------------------------------- 1 | function val = readIntFromFID(FID, string) 2 | 3 | % READINTFROMFID Read an integer from an FID. 4 | % 5 | % Description: 6 | % 7 | % VAL = READINTFROMFID(FID, NAME) reads an integer from a stream. 8 | % Returns: 9 | % VAL - value of variable in file. 10 | % Arguments: 11 | % FID - stream to read from. 12 | % NAME - name of integer. 13 | % readBoolFromFID, readStringFromFID 14 | % 15 | % 16 | % See also 17 | % WRITEINTTOFID, READDOUBLEFROMFID, READINTFROMFID, 18 | 19 | 20 | % Copyright (c) 2008 Neil D. Lawrence 21 | % readIntFromFID.m SVN version 23 22 | % last update 2008-07-11T15:19:53.000000Z 23 | 24 | 25 | val = str2num(readStringFromFID(FID, string)); 26 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/NDLUTIL-161/readStringFromFID.m: -------------------------------------------------------------------------------- 1 | function val = readStringFromFID(FID, string) 2 | 3 | % READSTRINGFROMFID Read an boolean from an FID. 4 | % 5 | % Description: 6 | % 7 | % VAL = READSTRINGFROMFID(FID, NAME) reads a string from a stream. 8 | % Returns: 9 | % VAL - value of variable in file. 10 | % Arguments: 11 | % FID - stream to read from. 12 | % NAME - name of string. 13 | % 14 | % 15 | % See also 16 | % WRITESTRINGTOFID, READINTFROMFID, READBOOLFROMFID, READDOUBLEFROMFID 17 | 18 | 19 | % Copyright (c) 2008 Neil D. Lawrence 20 | % readStringFromFID.m SVN version 23 21 | % last update 2009-01-14T18:16:32.000000Z 22 | 23 | lineStr = getline(FID); 24 | tokens = tokenise(lineStr, '='); 25 | if(length(tokens)~=2 | ~strcmp(tokens{1}, string)) 26 | error('Incorrect file format.') 27 | end 28 | val = tokens{2}; 29 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/NDLUTIL-161/readVersionFromFID.m: -------------------------------------------------------------------------------- 1 | function val = readVersionFromFID(FID) 2 | 3 | % READVERSIONFROMFID Read version number from an FID. 4 | % 5 | % Description: 6 | % 7 | % VAL = READVERSIONFROMFID(FID) reads version number from a stream. 8 | % Returns: 9 | % VAL - value of variable in file. 10 | % Arguments: 11 | % FID - stream to read from. 12 | % 13 | % 14 | % See also 15 | % WRITEVERSIONTOFID, READDOUBLEFROMFID, READSTRINGFROMFID 16 | 17 | 18 | % Copyright (c) 2008 Neil D. Lawrence 19 | % readVersionFromFID.m SVN version 23 20 | % last update 2008-07-11T15:18:53.000000Z 21 | 22 | val = str2num(readStringFromFID(FID, 'version')); 23 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/NDLUTIL-161/rocCurve.m: -------------------------------------------------------------------------------- 1 | function [area, rocPointX, rocPointY] = rocCurve(outputs, labels) 2 | 3 | % ROCCURVE Draw ROC curve and return labels. 4 | % 5 | % Description: 6 | % 7 | % [AREA, ROCPOINTX, ROCPOINTY] = ROCCURVE(OUTPUTS, LABELS) draws an 8 | % ROC curve and returns the area under the ROC curve as well as the 9 | % points plotted. 10 | % Returns: 11 | % AREA - teh area under the ROC curve. 12 | % ROCPOINTX - the x points of the ROC curve. 13 | % ROCPOINTY - the y points of the ROC curve. 14 | % Arguments: 15 | % OUTPUTS - the outputs from the model (e.g. probabilities of 16 | % labels). 17 | % LABELS - the true labels associated with the outputs. 18 | % 19 | % 20 | % See also 21 | % TRAPZ 22 | 23 | 24 | % Copyright (c) 2004 Neil D. Lawrence 25 | % rocCurve.m CVS version 1.3 26 | % rocCurve.m SVN version 22 27 | % last update 2007-11-03T14:26:18.000000Z 28 | 29 | 30 | [sOutputs, index] = sort(outputs); 31 | sLabels = labels(index); 32 | 33 | for i = length(sOutputs):-1:1; 34 | % False positives 35 | rocPointX(length(sOutputs)-i+1) = sum(sLabels(i:end)==-1)/sum(labels==-1); 36 | rocPointY(length(sOutputs)-i+1) = sum(sLabels(i:end)==1)/sum(labels==1); 37 | end 38 | 39 | if nargin < 3 40 | plot(rocPointX, rocPointY); 41 | end 42 | area = trapz(rocPointX, rocPointY); -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/NDLUTIL-161/sigmoid.m: -------------------------------------------------------------------------------- 1 | function y = sigmoid(x) 2 | 3 | % SIGMOID The sigmoid function 4 | % 5 | % Description: 6 | % y = sigmoid(x) 7 | %% sigmoid.m CVS version 1.1 8 | % sigmoid.m SVN version 22 9 | % last update 2007-11-03T14:25:20.000000Z 10 | 11 | y = ones(size(x))./(1+exp(-x)); -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/NDLUTIL-161/sparseDiag.m: -------------------------------------------------------------------------------- 1 | function D = sparseDiag(d) 2 | 3 | % SPARSEDIAG Create a diagonal matrix that is sparse from a vector. 4 | % 5 | % Description: 6 | % 7 | % D = SPARSEDIAG(D) creates a diagonal matrix that is sparse from a 8 | % vector. 9 | % Returns: 10 | % D - the sparse diagonal matrix containing the vector as its 11 | % diagonal. 12 | % Arguments: 13 | % D - the diagonal vector from which the sparse diagonal matrix is 14 | % formed. 15 | % 16 | % 17 | % See also 18 | % DIAG, SPDIAGS 19 | 20 | 21 | % Copyright (c) 2005 Neil D. Lawrence 22 | % sparseDiag.m CVS version 1.4 23 | % sparseDiag.m SVN version 22 24 | % last update 2007-11-03T14:25:20.000000Z 25 | 26 | if length(size(d)) ~=2 27 | error('Input must be a vector.'); 28 | end 29 | if size(d, 1) ~= 1 & size(d, 2) ~=1 30 | error('Input must be a vector.'); 31 | end 32 | 33 | D = spdiags(d, 0, length(d), length(d)); 34 | % % Can be made more efficient. 35 | % n = length(d); 36 | % D = spalloc(n, n, n); 37 | % for i = 1:n 38 | % D(i, i) = d(i); 39 | % end 40 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/NDLUTIL-161/stack.m: -------------------------------------------------------------------------------- 1 | function x = stack(X) 2 | 3 | % STACK Return column stacked vector of given matrix. 4 | % 5 | % Description: 6 | % 7 | % X = STACK(X) returns a column stacked vector of a given matrix. This 8 | % is useful if you wish to stack a column vector from a matrix 9 | % returned by another function (i.e. you can't apply the colon 10 | % operator directly). 11 | % Returns: 12 | % X - stacked column vector from the matrix. 13 | % Arguments: 14 | % X - the matrix to be stacked. 15 | % 16 | % 17 | % See also 18 | % COLON 19 | 20 | 21 | % Copyright (c) 2004 Neil D. Lawrence 22 | % stack.m CVS version 1.2 23 | % stack.m SVN version 22 24 | % last update 2007-11-03T14:25:20.000000Z 25 | 26 | 27 | x = X(:); -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/NDLUTIL-161/stringSigFigs.m: -------------------------------------------------------------------------------- 1 | function str = stringSigFigs(num, sf); 2 | 3 | % STRINGSIGFIGS Convert number to a string with a number of significant digits. 4 | % 5 | % Description: 6 | % 7 | % STR = STRINGSIGFIGS(NUMBER, SF) converts a given number to a string, 8 | % but provides a given number of significant figures. 9 | % Returns: 10 | % STR - the string with the number to the given number of 11 | % significant figures. 12 | % Arguments: 13 | % NUMBER - the number that requires conversion. 14 | % SF - the number of significant figures required in the conversion. 15 | % 16 | % 17 | % See also 18 | % NUM2STR 19 | 20 | 21 | % Copyright (c) 2005, 2006 Neil D. Lawrence 22 | % stringSigFigs.m CVS version 1.2 23 | % stringSigFigs.m SVN version 22 24 | % last update 2007-11-03T14:26:18.000000Z 25 | 26 | val = chop(num, sf); 27 | str = num2str(val); 28 | ind = 1; 29 | while str(ind) == '0' | str(ind) == '.' 30 | ind = ind+1; 31 | end 32 | count = 0; 33 | while(ind <= length(str)) 34 | if str(ind) ~= '.' 35 | count = count + 1; 36 | end 37 | ind = ind +1; 38 | end 39 | while count < 3 40 | str = [str '0']; 41 | count = count + 1; 42 | end 43 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/NDLUTIL-161/stringSplit.m: -------------------------------------------------------------------------------- 1 | function parts = stringSplit(string, separator) 2 | 3 | % STRINGSPLIT Return separate parts of a string. 4 | % 5 | % Description: 6 | % 7 | % PARTS = STRINGSPLIT(STRING, SEPARATOR) return separate parts of a 8 | % string split by a given separator. 9 | % Returns: 10 | % PARTS - cell array of the string split into parts. 11 | % Arguments: 12 | % STRING - the string to be split into parts. 13 | % SEPARATOR - the character used to split the string (default, ','). 14 | % 15 | % 16 | % See also 17 | % TOKENISE 18 | 19 | 20 | % Copyright (c) 2005 Neil D. Lawrence 21 | % stringSplit.m CVS version 1.3 22 | % stringSplit.m SVN version 22 23 | % last update 2007-11-03T14:25:20.000000Z 24 | 25 | if nargin < 2 26 | separator = ','; 27 | end 28 | 29 | parts = tokenise(string, separator); -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/NDLUTIL-161/tokenise.m: -------------------------------------------------------------------------------- 1 | function tokens = tokenise(string, delim) 2 | 3 | % TOKENISE Split a string into separate tokens. 4 | % 5 | % Description: 6 | % 7 | % TOKENS = TOKENISE(STRING, DELIM) takes a string and splits it into 8 | % separate tokens. 9 | % Returns: 10 | % TOKENS - a cell array of tokens split from the string. 11 | % Arguments: 12 | % STRING - the string to be split into parts. 13 | % DELIM - the delimiter to use in splitting the string (default is ' 14 | % '). 15 | % 16 | % 17 | % See also 18 | % % SEEALSO STRINGSPLIT 19 | 20 | 21 | % Copyright (c) 2005 Neil D. Lawrence 22 | % tokenise.m CVS version 1.2 23 | % tokenise.m SVN version 22 24 | % last update 2007-11-03T14:25:20.000000Z 25 | 26 | if nargin < 2 27 | delim = ' '; 28 | end 29 | tokpos = find(string==delim); 30 | len=length(tokpos); 31 | 32 | if len==0 33 | tokens{1} = string; 34 | elseif len==1 35 | tokens{1} = string(1:tokpos(1)-1); 36 | tokens{2} = string(tokpos(1)+1:end); 37 | elseif len>1 38 | tokens{1} = string(1:tokpos(1)-1); 39 | for(i=2:len) 40 | tokens{i} = string(tokpos(i-1)+1:tokpos(i)-1); 41 | end 42 | tokens{len+1} = string(tokpos(len)+1:end); 43 | end -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/NDLUTIL-161/traceProduct.m: -------------------------------------------------------------------------------- 1 | function t = traceProduct(A, B) 2 | 3 | % TRACEPRODUCT Returns the trace of the product of two matrices. 4 | % 5 | % Description: 6 | % 7 | % T = TRACEPRODUCT(A, B) returns the trace of the product of two 8 | % matrices, tr(A*B). 9 | % Returns: 10 | % T - the trace of the product. 11 | % Arguments: 12 | % A - the first matrix in the product. 13 | % B - the second matrix in the product. 14 | % 15 | % 16 | % See also 17 | % TRACE 18 | 19 | 20 | % Copyright (c) 2004 Neil D. Lawrence 21 | % traceProduct.m CVS version 1.2 22 | % traceProduct.m SVN version 22 23 | % last update 2007-11-03T14:26:10.000000Z 24 | 25 | t = sum(sum(A.*B')); -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/NDLUTIL-161/treeFindChildren.m: -------------------------------------------------------------------------------- 1 | function tree = treeFindChildren(tree) 2 | 3 | % TREEFINDCHILDREN Given a tree that lists only parents, add children. 4 | % 5 | % Description: 6 | % 7 | % TREE = TREEFINDCHILDREN(TREE) takes a tree structure which lists the 8 | % children of each node and computes the parents for each node and 9 | % places them in. 10 | % Returns: 11 | % TREE - a tree that lists children and parents. 12 | % Arguments: 13 | % TREE - the tree that lists only children. 14 | % 15 | % 16 | % See also 17 | % TREEFINDPARENTS 18 | 19 | 20 | % Copyright (c) 2005, 2006 Neil D. Lawrence 21 | % treeFindChildren.m CVS version 1.1 22 | % treeFindChildren.m SVN version 22 23 | % last update 2007-11-03T14:25:19.000000Z 24 | 25 | for i = 1:length(tree) 26 | for j = 1:length(tree(i).parent) 27 | if tree(i).parent(j) 28 | tree(tree(i).parent(j)).children ... 29 | = [tree(tree(i).parent(j)).children i]; 30 | end 31 | end 32 | end 33 | 34 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/NDLUTIL-161/treeFindLeaves.m: -------------------------------------------------------------------------------- 1 | function ind = treeFindLeaves(tree) 2 | 3 | % TREEFINDLEAVES Return indices of all leaf nodes in a tree structure. 4 | % 5 | % Description: 6 | % 7 | % IND = TREEFINDLEAVES(TREE) returns indices of all leaf nodes in an 8 | % tree array. 9 | % Returns: 10 | % IND - indices of leaf nodes. 11 | % Arguments: 12 | % TREE - tree for which leaf nodes are being sought. 13 | % 14 | % 15 | % See also 16 | % TREEFINDPARENTS, TREEFINDCHILDREN 17 | 18 | 19 | % Copyright (c) 2007 Neil D. Lawrence 20 | % treeFindLeaves.m CVS version 1.1 21 | % treeFindLeaves.m SVN version 22 22 | % last update 2007-11-03T14:26:09.000000Z 23 | 24 | ind = []; 25 | for i = 1:length(tree) 26 | if isempty(tree(i).children) 27 | ind = [ind i]; 28 | end 29 | end -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/NDLUTIL-161/treeFindParents.m: -------------------------------------------------------------------------------- 1 | function tree = treeFindParents(tree) 2 | 3 | % TREEFINDPARENTS Given a tree that lists only children, add parents. 4 | % 5 | % Description: 6 | % 7 | % TREE = TREEFINDPARENTS(TREE) takes a tree structure which lists the 8 | % parents of each node and computes the children for each node and 9 | % places them in. 10 | % Returns: 11 | % TREE - a tree that lists parents and children. 12 | % Arguments: 13 | % TREE - the tree that lists only parents. 14 | % 15 | % 16 | % See also 17 | % TREEFINDCHILDREN 18 | 19 | 20 | % Copyright (c) 2005, 2006 Neil D. Lawrence 21 | % treeFindParents.m CVS version 1.1 22 | % treeFindParents.m SVN version 22 23 | % last update 2007-11-03T14:26:09.000000Z 24 | 25 | for i = 1:length(tree) 26 | for j = 1:length(tree(i).children) 27 | if tree(i).children(j) 28 | tree(tree(i).children(j)).parent ... 29 | = [tree(tree(i).children(j)).parent i]; 30 | end 31 | end 32 | end 33 | 34 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/NDLUTIL-161/treeFindRoots.m: -------------------------------------------------------------------------------- 1 | function ind = treeFindRoots(tree) 2 | 3 | % TREEFINDROOTS Return indices of all root nodes in a tree structure. 4 | % 5 | % Description: 6 | % 7 | % IND = TREEFINDROOTS(TREE) returns indices of all root nodes in an 8 | % tree array. 9 | % Returns: 10 | % IND - indices of root nodes. 11 | % Arguments: 12 | % TREE - tree for which root nodes are being sought. 13 | % 14 | % 15 | % See also 16 | % TREEFINDPARENTS, TREEFINDCHILDREN, TREEFINDLEAVES 17 | 18 | 19 | % Copyright (c) 2007 Neil D. Lawrence 20 | % treeFindRoots.m CVS version 1.2 21 | % treeFindRoots.m SVN version 22 22 | % last update 2007-11-03T14:25:19.000000Z 23 | 24 | ind = []; 25 | for i = 1:length(tree) 26 | if isempty(tree(i).parent) 27 | ind = [ind i]; 28 | end 29 | end -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/NDLUTIL-161/treeSwapNode.m: -------------------------------------------------------------------------------- 1 | function tree = treeSwapNode(tree, i, j); 2 | 3 | % TREESWAPNODE Swap two nodes in the tree structure array. 4 | % 5 | % Description: 6 | % 7 | % TREE = TREESWAPNODE(TREE, I, J) swaps the location of two nodes in a 8 | % tree structure array. 9 | % Returns: 10 | % TREE - the tree structure with the two node locations swapped. 11 | % Arguments: 12 | % TREE - the tree for which two nodes are to be swapped. 13 | % I - the index of the first node to be swapped. 14 | % J - the index of the second node to be swapped. 15 | % 16 | % 17 | % See also 18 | % TREEFINDPARENTS, TREEFINDCHILDREN 19 | 20 | 21 | % Copyright (c) 2005, 2006 Neil D. Lawrence 22 | % treeSwapNode.m CVS version 1.1 23 | % treeSwapNode.m SVN version 22 24 | % last update 2007-11-03T14:25:19.000000Z 25 | 26 | storeNodeI = tree(i); 27 | storeNodeJ = tree(j); 28 | tree(j) = storeNodeI; 29 | tree(i) = storeNodeJ; 30 | for k = 1:length(tree) 31 | tree(k).children(find(tree(k).children==i)) = -1; 32 | tree(k).children(find(tree(k).children==j)) = i; 33 | tree(k).children(find(tree(k).children==-1)) = j; 34 | tree(k).parent(find(tree(k).parent==i)) = -1; 35 | tree(k).parent(find(tree(k).parent==j)) = i; 36 | tree(k).parent(find(tree(k).parent==-1)) = j; 37 | end 38 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/NDLUTIL-161/writeBoolToFID.m: -------------------------------------------------------------------------------- 1 | function writeBoolToFID(FID, name, val) 2 | 3 | % WRITEBOOLTOFID Writes a boolean to an FID. 4 | % 5 | % Description: 6 | % 7 | % WRITEBOOLTOFID(FID, NAME, VAL) writes a boolean to a stream. 8 | % Arguments: 9 | % FID - stream to write to. 10 | % NAME - name of boolean. 11 | % VAL - value of variable to place in file. 12 | % 13 | % 14 | % See also 15 | % READBOOLFROMFID, WRITESTRINGTOFID, WRITEBOOLTOFID, WRITEINTTOFID 16 | 17 | 18 | % Copyright (c) 2008 Neil D. Lawrence 19 | % writeBoolToFID.m SVN version 23 20 | % last update 2008-07-11T15:19:35.000000Z 21 | 22 | if val 23 | writeStringToFID(FID, name, '1'); 24 | else 25 | writeStringToFID(FID, name, '0'); 26 | end 27 | 28 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/NDLUTIL-161/writeDoubleToFID.m: -------------------------------------------------------------------------------- 1 | function writeDoubleToFID(FID, name, val) 2 | 3 | % WRITEDOUBLETOFID Writes a double to an FID. 4 | % 5 | % Description: 6 | % 7 | % WRITEDOUBLETOFID(FID, NAME, VAL) writes a double to a stream. 8 | % Arguments: 9 | % FID - stream to write to. 10 | % NAME - name of double. 11 | % VAL - value of variable to place in file. 12 | % 13 | % 14 | % See also 15 | % READDOUBLEFROMFID, WRITESTRINGTOFID, WRITEBOOLTOFID, WRITEINTTOFID 16 | 17 | 18 | % Copyright (c) 2008 Neil D. Lawrence 19 | % writeDoubleToFID.m SVN version 23 20 | % last update 2008-07-11T15:19:26.000000Z 21 | 22 | writeStringToFID(FID, name, num2str(val)); 23 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/NDLUTIL-161/writeIntToFID.m: -------------------------------------------------------------------------------- 1 | function writeIntToFID(FID, name, val) 2 | 3 | % WRITEINTTOFID Writes an integer to an FID. 4 | % 5 | % Description: 6 | % 7 | % WRITEINTTOFID(FID, NAME, VAL) writes an integer to a stream. 8 | % Arguments: 9 | % FID - stream to write to. 10 | % NAME - name of int. 11 | % VAL - value of variable to place in file. 12 | % 13 | % 14 | % See also 15 | % READINTFROMFID, WRITESTRINGTOFID, WRITEBOOLTOFID, WRITEDOUBLETOFID 16 | 17 | 18 | % Copyright (c) 2008 Neil D. Lawrence 19 | % writeIntToFID.m SVN version 23 20 | % last update 2008-07-11T15:18:59.000000Z 21 | 22 | writeStringToFID(FID, name, num2str(val)); 23 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/NDLUTIL-161/writeStringToFID.m: -------------------------------------------------------------------------------- 1 | function writeStringToFID(FID, name, val) 2 | 3 | % WRITESTRINGTOFID Writes a string to an FID. 4 | % 5 | % Description: 6 | % 7 | % WRITESTRINGTOFID(FID, NAME, VAL) writes an string from a stream. 8 | % Arguments: 9 | % FID - stream to write from. 10 | % NAME - name of string. 11 | % VAL - value of variable to place in file. 12 | % 13 | % 14 | % See also 15 | % READSTRINGFROMFID, WRITEINTTOFID, WRITEBOOLTOFID, WRITEDOUBLETOFID 16 | 17 | 18 | % Copyright (c) 2008 Neil D. Lawrence 19 | % writeStringToFID.m SVN version 23 20 | % last update 2008-07-11T15:18:17.000000Z 21 | 22 | fprintf(FID, [name '=' val '\n']); 23 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/NDLUTIL-161/writeVersionToFID.m: -------------------------------------------------------------------------------- 1 | function writeVersionToFID(FID, val) 2 | 3 | % WRITEVERSIONTOFID Writes a version to an FID. 4 | % 5 | % Description: 6 | % 7 | % WRITEVERSIONTOFID(FID, VAL) writes a version from a stream. 8 | % Arguments: 9 | % FID - stream to write to. 10 | % VAL - value of version to place in file. 11 | % 12 | % 13 | % See also 14 | % READVERSIONFROMFID, WRITESTRINGTOFID 15 | 16 | 17 | % Copyright (c) 2008 Neil D. Lawrence 18 | % writeVersionToFID.m SVN version 23 19 | % last update 2008-07-11T15:19:19.000000Z 20 | 21 | writeStringToFID(FID, 'version', num2str(val)); 22 | 23 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/NDLUTIL-161/xlogy.m: -------------------------------------------------------------------------------- 1 | function z = xlogy(x, y) 2 | 3 | % XLOGY z = x*log(y) returns zero if x=y=0 4 | % 5 | % Description: 6 | % 7 | % Z = XLOGY(X, Y) computes the function x*log(y) but taking account 8 | % for the fact that the answer is zero if x=y=0. 9 | % Returns: 10 | % Z - returns z where z = x*log(y). 11 | % Arguments: 12 | % X - the x argument in x*log(y). 13 | % Y - the y argument in x*log(y). 14 | % 15 | % Y = XLOGY(X) computes the function x*log(x), taking account for the 16 | % fact that the answer is zero if x=0. 17 | % Returns: 18 | % Y - returns y where y = x*log(x). 19 | % Arguments: 20 | % X - the argument in x*log(x). 21 | 22 | 23 | % Copyright (c) 2001, 2006 Neil D. Lawrence 24 | % xlogy.m CVS version 1.2 25 | % xlogy.m SVN version 22 26 | % last update 2007-11-03T14:26:09.000000Z 27 | 28 | % If there is only one input argument x is assumed to equal y. 29 | if nargin == 1 30 | y=x; 31 | end 32 | if any(any(x==0)) 33 | if ~issparse(x) 34 | z = zeros(size(x)); 35 | else 36 | z = spalloc(size(x, 1), size(x, 2), sum(sum(x~=0))); 37 | end 38 | indx = find(x); 39 | z(indx)= x(indx).*log(y(indx)); 40 | else 41 | z= x.*log(y); 42 | end -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/acclaimNumberOfFrames.m: -------------------------------------------------------------------------------- 1 | function nFrames = acclaimNumberOfFrames(fileName) 2 | 3 | % ACCLAIMNUMBEROFFRAMES Extract the number of frames. 4 | % FORMAT 5 | % DESC counts the total number of frames from an acclaim motion capture 6 | % file. 7 | % ARG fileName : the file name to load in. 8 | % RETURN nFrames : the total number of frames in the file. 9 | % 10 | % COPYRIGHT : Alfredo A. Kalaitzis, 2012 11 | % 12 | % SEEALSO : 13 | 14 | % MOCAP 15 | 16 | fid = fopen(fileName, 'rt'); 17 | 18 | % Assumes the number of lines in each frame is fixed. 19 | a = cell(textscan(fid, '%s')); 20 | a = a{1}; 21 | nFrames = str2double(a{end-91}); % 91 strings from eof to last frame # 22 | 23 | fclose(fid); 24 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/acclaimPlayFile.m: -------------------------------------------------------------------------------- 1 | function acclaimPlayFile(fileNameAsf, fileNameAmc, frameLength) 2 | 3 | % ACCLAIMPLAYFILE Play motion capture data from a asf and amc file. 4 | % FORMAT 5 | % DESC plays motion capture data by reading in a asf and amc files from disk. 6 | % ARG fileNameAsf : the name of the ASF file to read in. 7 | % ARG fileNameAmc : the name of the AMC file to read in. 8 | % ARG frameLength : the length of the frames. 9 | % 10 | % COPYRIGHT : Neil D. Lawrence, 2006 11 | % 12 | % SEEALSO : acclaimPlayFile, bvhReadFile, skelPlayData 13 | 14 | % MOCAP 15 | 16 | skel = acclaimReadSkel(fileNameAsf); 17 | [channels, skel] = acclaimLoadChannels(fileNameAmc, skel); 18 | skelPlayData(skel, channels, frameLength); 19 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/additionalfiles.txt: -------------------------------------------------------------------------------- 1 | # These are files that should be packaged for gplvm C++ software 2 | dir: examples 3 | ~/datasets/mocap/Swagger.bvh 4 | dir: html 5 | ~/mlprojects/mocap/html/index.html 6 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/ankurAngle2XYZ.m: -------------------------------------------------------------------------------- 1 | function X = ankurAngle2XYZ(X) 2 | 3 | if(size(X,2)~=54) 4 | error('Wrong Dimensionality of Data'); 5 | end 6 | 7 | matrix_to_bvh(X','tmp.bvh'); 8 | X = bvh_to_3dmatrix('tmp.bvh'); 9 | 10 | % clean up 11 | system('rm tmp.bvh'); 12 | 13 | return; -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/bvhConnectionMatrix.m: -------------------------------------------------------------------------------- 1 | function connection = bvhConnectionMatrix(skel); 2 | 3 | % BVHCONNECTIONMATRIX Compute the connection matrix for the structure. 4 | % FORMAT 5 | % DESC computes the connection matrix for the structure. Returns a matrix 6 | % which has zeros at all entries except those that are connected in the 7 | % skeleton. 8 | % ARG skel : the skeleton for which the connectivity is required. 9 | % RETURN connection : connectivity matrix. 10 | % 11 | % COPYRIGHT : Neil D. Lawrence, 2005, 2006 12 | % 13 | % SEEALSO : skelConnectionMatrix 14 | 15 | % MOCAP 16 | 17 | connection = skelConnectionMatrix(skel); 18 | 19 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/bvhModify.m: -------------------------------------------------------------------------------- 1 | function bvhModify(handle, channels, skel, padding) 2 | 3 | % BVHMODIFY Helper code for visualisation of bvh data. 4 | % FORMAT 5 | % DESC updates a bvh representation in a 3-D plot. 6 | % ARG handle : a vector of handles to the structure to be updated. 7 | % ARG channels : the channels to update the skeleton with. 8 | % ARG skel : the skeleton structure. 9 | % 10 | % SEEALSO : skelModify, bvhVisualise 11 | % 12 | % COPYRIGHT : Neil D. Lawrence, 2005, 2006 13 | 14 | % MOCAP 15 | 16 | 17 | if nargin<4 18 | padding = 0; 19 | end 20 | 21 | skelModify(handle, channels, skel, padding); 22 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/bvhPlayData.m: -------------------------------------------------------------------------------- 1 | function bvhPlayData(skel, channels, frameLength) 2 | 3 | % BVHPLAYDATA Play bvh motion capture data. 4 | % FORMAT 5 | % DESC plays channels from the bvh motion capture format. 6 | % ARG skel : the skeleton for the motion. 7 | % ARG channels : the channels for the motion. 8 | % ARG frameLength : the framelength for the motion. 9 | % 10 | % COPYRIGHT : Neil D. Lawrence, 2005, 2006 11 | % 12 | % SEEALSO : skelPlayData 13 | 14 | % MOCAP 15 | 16 | skelPlayData(skel, channels, frameLength); 17 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/bvhPlayFile.m: -------------------------------------------------------------------------------- 1 | function bvhPlayFile(fileName) 2 | 3 | % BVHPLAYFILE Play motion capture data from a bvh file. 4 | % FORMAT 5 | % DESC plays motion capture data by reading in a bvh file from disk. 6 | % ARG fileName : the name of the file to read in, in bvh format. 7 | % 8 | % COPYRIGHT : Neil D. Lawrence, 2005 9 | % 10 | % SEEALSO : acclaimPlayFile, bvhReadFile, skelPlayData 11 | 12 | % MOCAP 13 | 14 | [skel, channels, frameLength] = bvhReadFile(fileName); 15 | skelPlayData(skel, channels, frameLength); 16 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/bvhVisualise.m: -------------------------------------------------------------------------------- 1 | function handle = bvhVisualise(channels, skel, padding) 2 | 3 | % BVHVISUALISE For updating a bvh representation of 3-D data. 4 | % FORMAT 5 | % DESC draws a bvh representation in a 3-D plot. 6 | % ARG channels : the channels to update the skeleton with. 7 | % ARG skel : the skeleton structure. 8 | % RETURN handle : a vector of handles to the plotted structure. 9 | % 10 | % SEEALSO : bvhModify, skelVisualise 11 | % 12 | % COPYRIGHT : Neil D. Lawrence, 2005, 2006 13 | 14 | % MOCAP 15 | 16 | if nargin < 3 17 | padding = 0; 18 | end 19 | handle = skelVisualise(channels, skel, padding); 20 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/clutterDir/bvhLoadData.m: -------------------------------------------------------------------------------- 1 | function [bvhStruct, channels, frameLength, velocityIndices] = bvhLoadData(dataSet, velocityIndices) 2 | 3 | % BVHLOADDATA Load a motion capture data set. 4 | 5 | if nargin < 2 6 | % By default consider x and y motion as velocity 7 | velocityIndices = [1 3 6]; 8 | end 9 | dataDir = mocapDataDir; 10 | switch dataSet 11 | otherwise 12 | % assume the data set is a bvh filename. 13 | fileName = [mocapDataDir dataSet '.bvh']; 14 | 15 | if exist(fileName) == 2 16 | [bvhStruct, channels, frameLength] = bvhReadFile(fileName); 17 | % Convert specified channels into velocities 18 | for i = 2:size(channels, 1) 19 | for j = velocityIndices 20 | channels(i-1, j) = channels(i, j) - channels(i-1, j); 21 | end 22 | end 23 | else 24 | error([fileName ' does not exist.']) 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/clutterDir/bvhLoadResult.m: -------------------------------------------------------------------------------- 1 | function [model, bvhStruct, frameLength] = bvhLoadResult(dataSet, number) 2 | 3 | % BVHLOADRESULT Load a previously saved result. 4 | 5 | [bvhStruct, channels, frameLength] = bvhLoadData(dataSet); 6 | 7 | dataSet(1) = upper(dataSet(1)); 8 | load(['dem' dataSet num2str(number)]) 9 | model = ivmReconstruct(kern, noise, ivmInfo, X, channels); 10 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/clutterDir/bvhModel.m: -------------------------------------------------------------------------------- 1 | function bvhModel(dataSet, experimentNo) 2 | 3 | % BVHMODEL Model Demonstration of modelling of BVH files. 4 | 5 | rand('seed', 1e5) 6 | randn('seed', 1e5) 7 | colordef white 8 | 9 | [bvhStruct, Y, frameLength, velocityIndices] = bvhLoadData(dataSet); 10 | 11 | numActive = min([50 size(Y, 1)]); 12 | % Fit the GP latent variable model 13 | switch experimentNo 14 | case 1 15 | kernelType = {'rbf', 'bias', 'white'}; 16 | case 2 17 | kernelType = {'mlp', 'bias', 'white'}; 18 | end 19 | options = bvhOptions; 20 | 21 | model = gplvmFit(Y, 2, options, kernelType, 'gaussian', ... 22 | 'entropy', numActive) 23 | 24 | % Save the results. 25 | X = model.X; 26 | [kern, noise, ivmInfo] = ivmDeconstruct(model); 27 | capName = dataSet; 28 | capName(1) = upper(capName(1)); 29 | save(['dem' capName num2str(experimentNo) '.mat'], 'X', 'kern', ... 30 | 'noise', 'ivmInfo'); 31 | 32 | %bvhResultsDynamic(dataSet, experimentNo, 'bvh', bvhStruct, velocityIndices) -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/clutterDir/bvhOptions.m: -------------------------------------------------------------------------------- 1 | function options = bvhOptions 2 | 3 | % BVHOPTIONS The default options for modelling bvh data. 4 | 5 | options = gplvmOptions; 6 | options.gplvmKern = 1; 7 | options.initX = 'sppca'; 8 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/clutterDir/bvhResults.m: -------------------------------------------------------------------------------- 1 | function bvhResults(dataSet, experimentNo) 2 | 3 | % BVHRESULTS Model Demonstration of modelling of BVH files. 4 | 5 | [bvhStruct, Y, frameLength, velocityIndices] = bvhLoadData(dataSet); 6 | bvhResultsDynamic(dataSet, experimentNo, 'bvh', bvhStruct, velocityIndices) 7 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/clutterDir/bvhResultsDynamic.m: -------------------------------------------------------------------------------- 1 | function bvhResultsDynamic(dataSet, number, dataType, bvhStruct, velocityIndices) 2 | 3 | % BVHRESULTSDYNAMIC Load a results file and visualise them. 4 | 5 | [model, bvhStruct, frameLength] = bvhLoadResult(dataSet, number); 6 | 7 | if size(model.X, 2) ~=2 8 | error('Visualisation only works for 2-D latent spaces.') 9 | end 10 | mocapVisualise(model, ones(size(model.X, 1), 1), ... 11 | str2func([dataType 'Visualise']), ... 12 | str2func([dataType 'Modify']), ... 13 | bvhStruct, velocityIndices); 14 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/clutterDir/demEa.m: -------------------------------------------------------------------------------- 1 | % DEMEA Show the saved results of demEa1. 2 | 3 | load demEa1 4 | labelInfo(1).text = 'Neutral'; 5 | labelInfo(1).indices = [1:20]'; 6 | labelInfo(2).text = 'Happy'; 7 | labelInfo(2).indices = [21:27 96:105]'; 8 | labelInfo(3).text = 'Sad'; 9 | labelInfo(3).indices = [30:38]'; 10 | labelInfo(4).text = 'Fear'; 11 | labelInfo(4).indices = [40:47]'; 12 | labelInfo(5).text = 'Suprise'; 13 | labelInfo(5).indices = [49:58]'; 14 | labelInfo(6).text = 'Anger'; 15 | labelInfo(6).indices = [60:68]'; 16 | labelInfo(7).text = 'Disgust'; 17 | labelInfo(7).indices = [70:78]'; 18 | labelInfo(8).text = 'Maniac'; 19 | labelInfo(8).indices = [80:95]'; 20 | labelInfo(9).text = 'Transition'; 21 | labelInfo(9).indices = [28:29 39 48 59 69 79]'; 22 | 23 | numData = size(Y, 1); 24 | % Visualise the results 25 | mocapFaceVisualise(X, Y, invK, theta, [], meanData, 1:numData, ... 26 | labelInfo, 'face2DVisualise', 'face2DModify', patches); 27 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/clutterDir/demMocapReconstruct.m: -------------------------------------------------------------------------------- 1 | function demMocapReconstruct(fileName) 2 | 3 | % MOCAPPLAYFACEFILE Play a face file of motion capture data. 4 | 5 | % Load patches 6 | 7 | % connections = mocapFaceConnections('../data/manuel/connections.txt'); 8 | % connections(:, 73:end) = []; 9 | % connections(73:end, :) = []; 10 | patches = mocapFacePatches('../data/manuel/patches.txt'); 11 | for i = 1:4 12 | patches(i).colour = zeros(size(patches(i).colour)); 13 | end 14 | indToDel = []; 15 | for i = 1:length(patches) 16 | if any(patches(i).index > 72) 17 | indToDel = [indToDel i]; 18 | end 19 | end 20 | load ../data/2_2.mat 21 | lastMarker = 72*3+1; 22 | points{1} = vals(:, 2:3:lastMarker); 23 | points{2} = vals(:, 3:3:lastMarker); 24 | points{3} = vals(:, 4:3:lastMarker); 25 | for i = 1:3 26 | vals = points{i}(:, 3) + points{i}(:, 50) + points{i}(:, 60); 27 | vals = vals/3; 28 | for j = 1:size(points{i}, 2); 29 | points{i}(:, j) = points{i}(:, j) - vals; 30 | end 31 | end 32 | patches(indToDel) = []; 33 | Y = [points{1} points{3} points{2}]*4; 34 | 35 | pause 36 | fprintf('Press any key.\n'); 37 | mocapPlayFace(Y); 38 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/clutterDir/face2DModify.m: -------------------------------------------------------------------------------- 1 | function face2DModify(handle, vals, patches) 2 | 3 | % FACE2DMODIFY Helper code for visualisation of a face. 4 | 5 | global PATCHINFO 6 | numMark = size(vals, 2)/3; 7 | valsx = vals(1, 1:numMark); 8 | valsy = vals(1, numMark+1:2*numMark); 9 | valsz = vals(1, 2*numMark+1:3*numMark); 10 | PATCHINFO.points = [valsx' valsy' valsz']; 11 | 12 | set(handle(1), 'Xdata', valsx, 'Ydata', valsz); 13 | for i = 1:length(patches) 14 | X = zeros(1, length(patches(i).index)); 15 | % Y = zeros(1, length(patches(i).index)); 16 | Z = zeros(1, length(patches(i).index)); 17 | for j = 1:length(X) 18 | X(j) = valsx(patches(i).index(j)); 19 | % Y(j) = valsy(patches(i).index(j)); 20 | Z(j) = valsz(patches(i).index(j)); 21 | end 22 | 23 | set(handle(i+1), 'Xdata', X, ... 24 | 'Ydata', Z); 25 | end 26 | drawnow -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/clutterDir/faceModify.m: -------------------------------------------------------------------------------- 1 | function faceModify(handle, values, connect) 2 | 3 | % FACEMODIFY Helper code for visualisation of a face. 4 | 5 | vals = reshape(values, size(values, 2)/3, 3); 6 | 7 | indices = find(connect); 8 | [I, J] = ind2sub(size(connect), indices); 9 | set(handle(1), 'Xdata', vals(:, 1), 'Ydata', vals(:, 3));%, 'Zdata', ... 10 | % vals(:, 3)); 11 | 12 | 13 | for i = 1:length(indices) 14 | set(handle(i+1), 'Xdata', [vals(I(i), 1) vals(J(i), 1)], ... 15 | 'Ydata', [vals(I(i), 3) vals(J(i), 3)]);%, ... 16 | % 'Zdata', [vals(I(i), 3) vals(J(i), 3)]); 17 | end 18 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/clutterDir/facePatchModify.m: -------------------------------------------------------------------------------- 1 | function facePatchModify(handle, vals, patches) 2 | 3 | % FACEPATCHMODIFY Helper code for visualisation of a face. 4 | 5 | numMark = size(vals, 2)/3; 6 | valsx = vals(1, 1:numMark); 7 | valsy = vals(1, numMark+1:2*numMark); 8 | valsz = vals(1, 2*numMark+1:3*numMark); 9 | PATCHINFO.points = [valsx' valsy' valsz']; 10 | 11 | set(handle(1), 'Xdata', valsx, 'Ydata', valsy, 'Zdata', ... 12 | valsz); 13 | %set(handle(1), 'visible', 'on'); 14 | for i = 1:length(patches) 15 | X = zeros(1, length(patches(i).index)); 16 | Y = zeros(1, length(patches(i).index)); 17 | Z = zeros(1, length(patches(i).index)); 18 | for j = 1:length(X) 19 | X(j) = valsx(patches(i).index(j)); 20 | Y(j) = valsy(patches(i).index(j)); 21 | Z(j) = valsz(patches(i).index(j)); 22 | end 23 | 24 | set(handle(i+1), 'Xdata', X, ... 25 | 'Ydata', Y, ... 26 | 'Zdata', Z); 27 | end 28 | drawnow -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/clutterDir/faceVisualise.m: -------------------------------------------------------------------------------- 1 | function handle = faceVisualise(vals, connect) 2 | 3 | % FACEVISUALISE For updateing a face representation of 3-D data. 4 | 5 | numMark = size(vals, 2)/3; 6 | valsx = vals(1, 1:numMark); 7 | valsy = vals(1, numMark+1:2*numMark); 8 | valsz = vals(1, 2*numMark+1:3*numMark); 9 | 10 | indices = find(connect); 11 | [I, J] = ind2sub(size(connect), indices); 12 | %handle(1) = plot3(valsx, valsy, valsz, '.'); 13 | handle(1) = plot(valsx, valsz, '.'); 14 | set(handle(1), 'markersize', 12); 15 | set(handle(1), 'visible', 'off') 16 | hold on 17 | grid on 18 | for i = 1:length(indices) 19 | handle(i+1) = line([valsx(I(i)) valsx(J(i))], ... 20 | [valsz(I(i)) valsz(J(i))]); ... 21 | % [valsz(I(i)) valsz(J(i))]); 22 | set(handle(i+1), 'linewidth', 2); 23 | % set(handle(i+1), 'visible', 'off') 24 | end 25 | axis equal 26 | %set(gca, 'zlim', [-2 2]) 27 | set(gca, 'ylim', [-4 4]) 28 | set(gca, 'xlim', [-2 2]) 29 | xlabel('x') 30 | ylabel('z') 31 | zlabel('y') 32 | %set(gca, 'cameraposition', [-1.3954 -91.5992 46.0000]) 33 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/clutterDir/manifoldOutputs.m: -------------------------------------------------------------------------------- 1 | function [meanOut, varOut] = manifoldOutputs(X2, X, Y, theta, invK) 2 | 3 | % MANIFOLDOUTPUTS Evaluate the manifold output for datapoints X. 4 | 5 | global LINEAR 6 | 7 | dataDim = size(Y, 2); 8 | numData = size(Y, 1); 9 | numDataTest = size(X2, 1); 10 | 11 | alpha = zeros(numData, dataDim); 12 | 13 | kbold = kernel(X2, X, theta)'; 14 | 15 | A = Y'*invK; 16 | meanOut = A*kbold; 17 | meanOut = meanOut'; 18 | varOut = zeros(numDataTest, 1); 19 | for i = 1:numDataTest 20 | varOut(i) = theta(2) +1/theta(end) - kbold(:, i)'*invK*kbold(:, i); 21 | end 22 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/clutterDir/mocapConnections.m: -------------------------------------------------------------------------------- 1 | function connect = mocapConnections(fileName, pointNames); 2 | 3 | % MOCAPCONNECTIONS Give a connection matrix for the motion capture data. 4 | 5 | fid = fopen(fileName); 6 | i = 1; 7 | rem = fgets(fid); 8 | while(rem ~= -1) 9 | [token, rem] = strtok(rem, ','); 10 | connections{i, 1} = fliplr(deblank(fliplr(deblank(token)))); 11 | [token, rem] = strtok(rem, ','); 12 | connections{i, 2} = fliplr(deblank(fliplr(deblank(token)))); 13 | i = i + 1; 14 | rem = fgets(fid); 15 | end 16 | 17 | connect = zeros(length(pointNames)); 18 | fclose(fid); 19 | for i = 1:size(connections, 1); 20 | for j = 1:length(pointNames) 21 | if strcmp(pointNames{j}, connections{i, 1}) | ... 22 | strcmp(pointNames{j}, connections{i, 2}) 23 | for k = 1:length(pointNames) 24 | if k == j 25 | break 26 | end 27 | if strcmp(pointNames{k}, connections{i, 1}) | ... 28 | strcmp(pointNames{k}, connections{i, 2}) 29 | connect(j, k) = 1; 30 | end 31 | end 32 | end 33 | end 34 | end 35 | connect = sparse(connect); -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/clutterDir/mocapDataDir.m: -------------------------------------------------------------------------------- 1 | function directory = mocapDataDir 2 | 3 | % MOCAPDATADIR Return the directory where the data is stored. 4 | 5 | dirSep = filesep; 6 | directory = ['..' dirSep 'data' dirSep]; -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/clutterDir/mocapFaceConnections.m: -------------------------------------------------------------------------------- 1 | function connect = mocapFaceConnections(fileName); 2 | 3 | % MOCAPFACECONNECTIONS Give a connection matrix for the motion capture data. 4 | 5 | fid = fopen(fileName); 6 | i = 1; 7 | rem = fgets(fid); 8 | while(rem ~= -1) 9 | [token, rem] = strtok(rem, ','); 10 | row = str2num(fliplr(deblank(fliplr(deblank(token)))))+1; 11 | [token, rem] = strtok(rem, ','); 12 | col = str2num(fliplr(deblank(fliplr(deblank(token)))))+1; 13 | i = i + 1; 14 | connect(row, col) = 1; 15 | rem = fgets(fid); 16 | end 17 | connect = connect + connect'; 18 | connect(find(connect)) = 1; 19 | connect = tril(connect); 20 | connect = sparse(connect); -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/clutterDir/mocapFacePatches.m: -------------------------------------------------------------------------------- 1 | function patches = mocapFacePatches(fileName); 2 | 3 | % MOCAPFACEPATCHES Give a connection matrix for the motion capture data. 4 | 5 | fid = fopen(fileName); 6 | i = 1; 7 | rem = fgets(fid); 8 | while(rem ~= -1) 9 | patches(i) = struct('index', [], 'colour', []); 10 | patches(i).index = sscanf(rem, '%d')+1; 11 | i = i+1; 12 | rem = fgets(fid); 13 | end 14 | colour = ones(1, 1, 3); 15 | for i = 1:length(patches) 16 | patches(i).colour = colour; 17 | end -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/clutterDir/mocapLoadData.m: -------------------------------------------------------------------------------- 1 | function mocapData = mocapLoadData(dataSet, velocity) 2 | 3 | % MOCAPLOADDATA Load a motion capture data set. 4 | 5 | dataDir = mocapDataDir; 6 | if nargin < 2 7 | velocity = 1; 8 | end 9 | switch dataSet 10 | otherwise 11 | % assume the data set is a bvh filename. 12 | fileName = [mocapDataDir dataSet '.bvh']; 13 | 14 | if exist(fileName) == 7 15 | [bvhStruct, channels, frameLength] = bvhReadFile(fileName); 16 | if velocity 17 | % Convert root's channels into velocities 18 | rootIndices = 1; 19 | for i = 2:size(channels, 1) 20 | for j = rootIndices 21 | for k = bvhStruct(j).posInd 22 | channels(i-1, k) = channels(i, k) - channels(i-1, k); 23 | end 24 | for k = bvhStruct(j).rotInd 25 | channels(i-1, k) = channels(i, k) - channels(i-1, k); 26 | end 27 | end 28 | end 29 | end 30 | end 31 | end 32 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/clutterDir/mocapLoadResult.m: -------------------------------------------------------------------------------- 1 | function [model, connect] = mocapLoadResult(dataSet, number) 2 | 3 | % MOCAPLOADRESULT Load a previously saved result. 4 | 5 | [Y, connect] = mocapLoadData(dataSet); 6 | 7 | dataSet(1) = upper(dataSet(1)); 8 | load(['dem' dataSet num2str(number)]) 9 | model = ivmReconstruct(kern, noise, ivmInfo, X, Y); 10 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/clutterDir/mocapManuelRead.m: -------------------------------------------------------------------------------- 1 | function [columnNames, data] = mocapManuelRead(fileName) 2 | 3 | % MOCAPMANUELREAD Read in data which has column titles in the first line and separated values in each other line. 4 | 5 | if nargin < 2 6 | separator = ','; 7 | end 8 | 9 | 10 | 11 | fid = fopen(fileName); 12 | numMarkers = str2num(fgetl(fid)); 13 | numLines = str2num(fgetl(fid)); 14 | framesPerSecond = str2num(fgetl(fid)); 15 | 16 | lin = fgetl(fid); 17 | columnNames = stringSplit(lin, ';'); 18 | numCol = length(columnNames); 19 | i = 0; 20 | data = zeros(numLines, (numCol - 1)*3+1); 21 | delim = sprintf('\t'); 22 | while 1 23 | i = i+1; 24 | lin=fgetl(fid); 25 | if ~ischar(lin), break, end 26 | split = stringSplit(deblank(lin), delim); 27 | % if length(split) ~= numMarkers*3 28 | % error(['Error at line ' num2str(i) ' of file ' fileName ': wrong ' ... 29 | % 'number of columns']) 30 | % end 31 | for j = 2:length(split); 32 | data(i, j) = str2num(split{j}); 33 | end 34 | end 35 | fclose(fid); -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/clutterDir/mocapParseText.m: -------------------------------------------------------------------------------- 1 | function [points, pointNames, times] = mocapParseText(fileName); 2 | 3 | % MOCAPPARSETEXT Parse a motion capture text file. 4 | 5 | fid = fopen(fileName); 6 | readLine = fgets(fid); 7 | 8 | [token, rem] = strtok(readLine); 9 | [token, rem] = strtok(rem); % skipping the 'field' field 10 | [token, rem] = strtok(rem); % skipping the 'time' field 11 | 12 | i = 1; 13 | while (~isempty(token)) 14 | pointNames{i}= token(1:end-2); 15 | i = i+1; 16 | [token, rem] = strtok(rem); 17 | [token, rem] = strtok(rem); 18 | [token, rem] = strtok(rem); 19 | end 20 | 21 | numPoints = length(pointNames); 22 | S = fscanf(fid, '%f '); 23 | numData = length(S)/(numPoints*3+2); 24 | S = reshape(S, numPoints*3+2, numData)'; 25 | field = S(:, 1); 26 | times = S(:, 2); 27 | S(find(S==-9999.99)) = NaN; 28 | points{1} = S(:, 3:3:end); 29 | points{2} = S(:, 4:3:end); 30 | points{3} = S(:, 5:3:end); 31 | 32 | fclose(fid); -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/clutterDir/mocapPath.m: -------------------------------------------------------------------------------- 1 | % MOCAPATH The toolboxes for the mocap toolbox. 2 | 3 | 4 | importTool('ivm', 0.31) 5 | importTool('kern', 0.13) 6 | importTool('noise', 0.12) 7 | importTool('prior', 0.12) 8 | importTool('optimi', 0.12) 9 | importTool('ndlutil', 0.12) 10 | importTool('rochol', 0.12) 11 | importTool('gplvm') -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/clutterDir/mocapPlayData.m: -------------------------------------------------------------------------------- 1 | function mocapPlayData(fileName) 2 | 3 | % MOCAPPLAYDATA 4 | 5 | [Y, connections] = mocapLoadData(fileName); 6 | 7 | pauseVal = 0.01; 8 | handle = stickVisualise(Y(1, :), connections); 9 | pause 10 | disp('Press a key') 11 | for j = 1:20 12 | for i = 1:size(Y, 1) 13 | pause(pauseVal); 14 | stickModify(handle, Y(i, :), connections); 15 | end 16 | end -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/clutterDir/mocapPlayFace.m: -------------------------------------------------------------------------------- 1 | function mocapPlayFace(Y, patches, model) 2 | 3 | % MOCAPPLAYDATA 4 | 5 | % Load patches 6 | % Compute any missing values 7 | 8 | playY = Y; 9 | if nargin > 2 10 | x = randn(2, 1); 11 | for i = 1:size(playY, 1) 12 | if any(isnan(playY(i, :))) 13 | x = scg('pointNegLogLikelihood', ... 14 | x, options, 'pointNegGrad', ... 15 | yval, model.X, ... 16 | model.A, ... 17 | model.theta, ... 18 | model.invSigma); 19 | playY(i, :) = manifoldOutputs(x, model.X, model.Y, ... 20 | model.theta, model.invSigma); 21 | notMissing = find(~isnan(Y(i, :))); 22 | playY(i, notMissing) = Y(i, notMissing); 23 | end 24 | end 25 | end 26 | 27 | pauseVal = 0.0001; 28 | handle = facePatchVisualise(playY(1, :), patches); 29 | for i = 1:size(playY, 1) 30 | facePatchModify(handle, playY(i, :), patches); 31 | drawnow 32 | end 33 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/clutterDir/mocapPlayFaceFile.m: -------------------------------------------------------------------------------- 1 | % MOCAPPLAYFACEFILE Play a face file of motion capture data. 2 | 3 | % Load patches 4 | 5 | % connections = mocapFaceConnections('../data/manuel/connections.txt'); 6 | % connections(:, 73:end) = []; 7 | % connections(73:end, :) = []; 8 | patches = mocapFacePatches('../data/manuel/patches.txt'); 9 | for i = 1:4 10 | patches(i).colour = zeros(size(patches(i).colour)); 11 | end 12 | indToDel = []; 13 | for i = 1:length(patches) 14 | if any(patches(i).index > 72) 15 | indToDel = [indToDel i]; 16 | end 17 | end 18 | load ../data/2_2.mat 19 | lastMarker = 72*3+1; 20 | points{1} = vals(:, 2:3:lastMarker); 21 | points{2} = vals(:, 3:3:lastMarker); 22 | points{3} = vals(:, 4:3:lastMarker); 23 | for i = 1:3 24 | vals = points{i}(:, 3) + points{i}(:, 50) + points{i}(:, 60); 25 | vals = vals/3; 26 | for j = 1:size(points{i}, 2); 27 | points{i}(:, j) = points{i}(:, j) - vals; 28 | end 29 | end 30 | patches(indToDel) = []; 31 | Y = [points{1} points{3} points{2}]*4; 32 | 33 | pause 34 | fprintf('Press any key.\n'); 35 | mocapPlayFace(Y(1:5:end, :), patches); 36 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/clutterDir/mocapResultsCpp.m: -------------------------------------------------------------------------------- 1 | function mocapResultsCpp(dataSet, number, dataType, varargin) 2 | 3 | % MOCAPRESULTSDYNAMIC Load a results file and visualise them. 4 | 5 | [model, connect] = mocapLoadResult(dataSet, number); 6 | 7 | % Visualise the results 8 | switch size(model.X, 2) 9 | case 1 10 | gplvmVisualise1D(model, [dataType 'Visualise'], [dataType 'Modify'], ... 11 | connect, varargin{:}); 12 | 13 | case 2 14 | gplvmVisualise(model, ones(size(model.X, 1)), [dataType 'Visualise'], [dataType 'Modify'], ... 15 | connect, varargin{:}); 16 | 17 | otherwise 18 | error('No visualisation code for data of this latent dimension.'); 19 | end -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/clutterDir/mocapResultsDynamic.m: -------------------------------------------------------------------------------- 1 | function mocapResultsDynamic(dataSet, number, dataType, varargin) 2 | 3 | % MOCAPRESULTSDYNAMIC Load a results file and visualise them. 4 | 5 | [model, connect] = mocapLoadResult(dataSet, number); 6 | 7 | % Visualise the results 8 | switch size(model.X, 2) 9 | case 1 10 | gplvmVisualise1D(model, [dataType 'Visualise'], [dataType 'Modify'], ... 11 | connect, varargin{:}); 12 | 13 | case 2 14 | gplvmVisualise(model, ones(size(model.X, 1)), [dataType 'Visualise'], [dataType 'Modify'], ... 15 | connect, varargin{:}); 16 | 17 | otherwise 18 | error('No visualisation code for data of this latent dimension.'); 19 | end -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/clutterDir/mocapVers.m: -------------------------------------------------------------------------------- 1 | function [vers, depend] = mocapVers 2 | 3 | % MOCAPPATH Brings dependent toolboxes into the path. 4 | 5 | vers = 0.001; 6 | if nargout > 2 7 | depend(1).name = 'gplvm'; 8 | depend(1).vers = 2.02; 9 | depend(1).required = 0; 10 | end 11 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/clutterDir/pointNegLogLikelihood.m: -------------------------------------------------------------------------------- 1 | function e = pointNegLogLikelihood(x, y, X, A, theta, invK, m, C) 2 | 3 | % POINTNEGLOGLIKELIHOOD Wrapper function for calling noise likelihoods. 4 | 5 | L = modelLogLikelihood(x, y, X, A, theta, invK); 6 | if nargin < 7 7 | m = [0 0]; 8 | C = [1 0; 0 1]; 9 | end 10 | L = L - .5*(x-m)*pdinv(C)*(x-m)'; 11 | e = -L; 12 | 13 | function logLike = modelLogLikelihood(x, y, X, A, theta, invK); 14 | 15 | presentInd = find(~isnan(y)); 16 | Atemp = A(presentInd, :); 17 | 18 | kbold = kernel(x, X, theta)'; 19 | meanOut = Atemp*kbold; 20 | meanOut = meanOut'; 21 | varOut = theta(2) +1/theta(end) - kbold'*invK*kbold; 22 | ycent = (y(presentInd) - meanOut); 23 | logLike = -0.5*length(presentInd)*log(varOut) - ycent*ycent'/(2*varOut); 24 | 25 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/clutterDir/runB.m: -------------------------------------------------------------------------------- 1 | bvhModel('b', 1); 2 | bvhModel('b', 2); -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/clutterDir/runEric.m: -------------------------------------------------------------------------------- 1 | bvhModel('eric1', 1); 2 | bvhModel('eric1', 2); 3 | bvhModel('ericr1', 1); 4 | bvhModel('ericr1', 2); 5 | bvhModel('ericrun', 1); 6 | bvhModel('ericrun', 2); 7 | bvhModel('ericdog', 1); 8 | bvhModel('ericdog', 2); -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/clutterDir/thetaConstrain.m: -------------------------------------------------------------------------------- 1 | function theta = thetaConstrain(theta) 2 | 3 | % THETACONSTRAIN Prevent kernel parameters from getting too big or small. 4 | 5 | minTheta = 1e-6; 6 | maxTheta = 1/minTheta; 7 | 8 | if any(theta < minTheta) 9 | theta(find(thetamaxTheta) 11 | theta(find(theta>maxTheta)) = maxTheta; 12 | end 13 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/clutterDir/vectorModify.m: -------------------------------------------------------------------------------- 1 | function vectorModify(handle, values, names, connect) 2 | 3 | % VECTORMODIFY Helper code for visualisation of vectorial data. 4 | 5 | vals = reshape(values, size(values, 2)/3, 3); 6 | 7 | indices = find(connect); 8 | [I, J] = ind2sub(size(connect), indices); 9 | set(handle(1), 'Xdata', vals(:, 1), 'Ydata', vals(:, 2), 'Zdata', ... 10 | vals(:, 3)); 11 | 12 | 13 | for i = 1:length(indices) 14 | set(handle(i+1), 'Xdata', [vals(I(i), 1) vals(J(i), 1)], ... 15 | 'Ydata', [vals(I(i), 2) vals(J(i), 2)], ... 16 | 'Zdata', [vals(I(i), 3) vals(J(i), 3)]); 17 | end 18 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/clutterDir/vectorVisualise.m: -------------------------------------------------------------------------------- 1 | function handle = vectorVisualise(vals, names, connect) 2 | 3 | % VECTORVISUALISE Helper code for plotting a vector during 2-D visualisation.Plot the oil data 4 | 5 | vals = reshape(vals, size(vals, 2)/3, 3); 6 | 7 | indices = find(connect); 8 | [I, J] = ind2sub(size(connect), indices); 9 | handle(1) = plot3(vals(:, 1), vals(:, 2), vals(:, 3), 'ro'); 10 | hold on 11 | for i = 1:length(indices) 12 | handle(i+1) = line([vals(I(i), 1) vals(J(i), 1)], ... 13 | [vals(I(i), 2) vals(J(i), 2)], ... 14 | [vals(I(i), 3) vals(J(i), 3)]); 15 | end 16 | %for i = 1:size(vals, 1) 17 | % handle = [handle text(vals(i, 1), vals(i, 2), vals(i, 3), names{i})]; 18 | %end 19 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/convertxyz2Vect.m: -------------------------------------------------------------------------------- 1 | function vect = convertxyz2Vect(xyz) 2 | 3 | % CONVERTXYZ2VECT convert an xyz matrix into a vector. 4 | % 5 | % Description: 6 | % 7 | % channelsFinal = gradientDescent(skel, initialChannels, finalChannels, 8 | % error,step) 9 | % 10 | % Returns: 11 | % VECT - a line vector 12 | % Arguments: 13 | % XYZ - the xyz matrix to be transformed 14 | 15 | for i=1:size(xyz,1) 16 | for j=1:size(xyz,2) 17 | vect((i-1)*3 + j) = xyz(i,j); 18 | end 19 | end -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/diagnostics.dat: -------------------------------------------------------------------------------- 1 | Files not tagged as in toolbox: 2 | 3 | Files not commented: 4 | 5 | Files not in CVS or SVN: 6 | 7 | Dependent toolbox problems 8 | File Comments Removed 9 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/mocapToolboxes.m: -------------------------------------------------------------------------------- 1 | % MOCAPTOOLBOXES Toolboxes required by the MOCAP toolbox. 2 | importLatest('ndlutil') -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/orn/stickman/AnimateSM.m: -------------------------------------------------------------------------------- 1 | 2 | noCoordinates = length(points(1,:)); 3 | noFrames = length(points(:,1)); 4 | noPoints = noCoordinates / 3; 5 | 6 | points_x = zeros(noFrames, noPoints); 7 | points_y = zeros(noFrames, noPoints); 8 | points_z = zeros(noFrames, noPoints); 9 | 10 | line = zeros(1, noCoordinates); 11 | 12 | frameNo = 1; 13 | 14 | while( frameNo <= noFrames ) 15 | line = points(frameNo,:); 16 | 17 | points_x(frameNo,:) = line(1:noPoints); 18 | points_y(frameNo,:) = line(noPoints+1:2*noPoints); 19 | points_z(frameNo,:) = line(2*noPoints+1:3*noPoints); 20 | 21 | frameNo = frameNo + 1; 22 | end 23 | 24 | % Animate 25 | frame_x = zeros(1, noPoints); 26 | frame_y = zeros(1, noPoints); 27 | frame_z = zeros(1, noPoints); 28 | 29 | t = timer('TimerFcn','StickManPlot(frame_x,frame_z,frame_y,connection)', 'StartDelay', 0.01); 30 | 31 | frameNo = 1; 32 | 33 | while( frameNo <= noFrames ) 34 | frame_x = points_x(frameNo, :); 35 | frame_y = points_y(frameNo, :); 36 | frame_z = points_z(frameNo, :); 37 | 38 | start(t); 39 | frameNo = frameNo + 1; 40 | wait(t); 41 | end 42 | 43 | delete(t); -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/orn/stickman/GPLVM_walking.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/computer-animation-perception-group/DeepDance/28be6b7ad6232b86e80524ba28d673154b643bcf/m2m_evaluation/matlab-file/mocap/orn/stickman/GPLVM_walking.mat -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/orn/stickman/StickManPlot.m: -------------------------------------------------------------------------------- 1 | function StickManPlot(frame_x, frame_z, frame_y, connection) 2 | 3 | plot3(frame_x, frame_z, frame_y, 'o', 'LineWidth', 2); 4 | 5 | noJoints = length(connection(1,:)); 6 | twoPoints = zeros(2, 3); 7 | 8 | hold on; 9 | 10 | for i = 1:noJoints; 11 | for j = 1:noJoints; 12 | if connection(i,j) == 1 13 | twoPoints(1,1) = frame_x(1,i); 14 | twoPoints(2,1) = frame_x(1,j); 15 | twoPoints(1,2) = frame_z(1,i); 16 | twoPoints(2,2) = frame_z(1,j); 17 | twoPoints(1,3) = frame_y(1,i); 18 | twoPoints(2,3) = frame_y(1,j); 19 | plot3(twoPoints(:,1), twoPoints(:,2), twoPoints(:,3), 'LineWidth', 2); 20 | end 21 | end 22 | end 23 | 24 | hold off; 25 | 26 | set(gca, 'XLim', [-100 100]); 27 | set(gca, 'YLim', [-100 100]); 28 | set(gca, 'ZLim', [-100 100]); 29 | campos([20 80 60]); 30 | camtarget([0 0 0]); 31 | set(gca, 'DataAspectRatio', [1 1 1]); 32 | grid on; 33 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/orn/stickman/plotJointConnections.m: -------------------------------------------------------------------------------- 1 | function plotJointConnections(frame_x, frame_y, frame_z, connection) 2 | 3 | noJoints = length(connection(1,:)); 4 | twoPoints = zeros(2, 3); 5 | somethingPlotted = 0; 6 | 7 | for i = 1:noJoints; 8 | for j = 1:noJoints; 9 | if connection(i,j) == 1 10 | twoPoints(1,1) = frame_x(1,i); 11 | twoPoints(2,1) = frame_x(1,j); 12 | twoPoints(1,2) = frame_z(1,i); 13 | twoPoints(2,2) = frame_z(1,j); 14 | twoPoints(1,3) = frame_y(1,i); 15 | twoPoints(2,3) = frame_y(1,j); 16 | plot3(twoPoints(:,1), twoPoints(:,2), twoPoints(:,3), '-o', 'LineWidth', 2); 17 | 18 | if somethingPlotted == 0 19 | hold on; 20 | somethingPlotted = 1; 21 | end 22 | end 23 | end 24 | end 25 | 26 | hold off; 27 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/orn/stickman/stickmanGplvmModify.m: -------------------------------------------------------------------------------- 1 | function stickmanGplvmModify(handle, vals, connection) 2 | 3 | numPoints = size(vals, 2) / 3; 4 | 5 | frame_x = vals(1:numPoints); 6 | frame_y = vals(numPoints+1:2*numPoints); 7 | frame_z = vals(2*numPoints+1:3*numPoints); 8 | 9 | figure(2) 10 | 11 | plotJointConnections(frame_x, frame_y, frame_z, connection); 12 | % feval(handle, frame_x, frame_y, frame_z, connection); 13 | 14 | set(gca, 'DataAspectRatio', [1 1 1]); 15 | grid on; 16 | 17 | figure(1) -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/orn/stickman/stickmanGplvmVisualise.m: -------------------------------------------------------------------------------- 1 | function handle = stickmanGplvmVisualise(vals, connection) 2 | 3 | numPoints = size(vals, 2) / 3; 4 | 5 | frame_x = vals(1:numPoints); 6 | frame_y = vals(numPoints+1:2*numPoints); 7 | frame_z = vals(2*numPoints+1:3*numPoints); 8 | 9 | plotJointConnections(frame_x, frame_y, frame_z, connection); 10 | set(gca, 'DataAspectRatio', [1 1 1]); 11 | grid on; 12 | 13 | % handle = @plotJointConnections; 14 | 15 | handle = plot3(frame_x, frame_y, frame_z, 'o'); 16 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/orn/stickman/stickmanResample.m: -------------------------------------------------------------------------------- 1 | function [resampledPoints] = stickmanResample(points, sampleSize) 2 | 3 | indices = randperm(size(points, 1)); 4 | resampledPoints = zeros(sampleSize, size(points, 2)); 5 | 6 | for i = 1:sampleSize 7 | resampledPoints(i, :) = points(indices(i), :); 8 | end -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/romain/compareGradient.m: -------------------------------------------------------------------------------- 1 | %test Gradient 2 | 3 | skel = acclaimReadSkel('07.asf'); 4 | [channels, skel] = acclaimLoadChannels('07_01.amc', skel); 5 | 6 | gradient = computeGradient(skel,channels(1,:)); 7 | 8 | epsilon = 0.0000001; 9 | [lin siz] = size(gradient); 10 | 11 | result = zeros(lin,siz); 12 | 13 | vect = zeros(lin,siz); 14 | 15 | for k=1:siz 16 | 17 | channels_epsilonPlus = channels(1,:); 18 | channels_epsilonPlus(1,k) = channels_epsilonPlus(1,k) + epsilon ; 19 | channels_epsilonMoins = channels(1,:); 20 | channels_epsilonMoins(1,k) = channels_epsilonMoins(1,k) - epsilon ; 21 | 22 | 23 | 24 | xyz = skel2xyz(skel, channels_epsilonPlus); 25 | xyz2 = skel2xyz(skel, channels_epsilonMoins); 26 | 27 | toCompare = (xyz - xyz2)/(2*epsilon); 28 | 29 | vect(:,k) = convertxyz2Vect(toCompare)'; 30 | 31 | 32 | %This is the matrix where the values are the comparison between the real 33 | %gradient and the variation rate (all the values should be close to 1 34 | result(:,k) = vect(:,k) ./ gradient(:,k); 35 | 36 | end 37 | 38 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/romain/convertxyz2Vect.m: -------------------------------------------------------------------------------- 1 | function vect = convertxyz2Vect(xyz) 2 | 3 | % CONVERTXYZ2VECT convert an xyz matrix into a vector. 4 | % 5 | % Description: 6 | % 7 | % channelsFinal = gradientDescent(skel, initialChannels, finalChannels, 8 | % error,step) 9 | % 10 | % Returns: 11 | % VECT - a line vector 12 | % Arguments: 13 | % XYZ - the xyz matrix to be transformed 14 | 15 | for i=1:size(xyz,1) 16 | for j=1:size(xyz,2) 17 | vect((i-1)*3 + j) = xyz(i,j); 18 | end 19 | end -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/romain/demoGradientDescent.m: -------------------------------------------------------------------------------- 1 | % DEMOGRADIENTDESCENT compute a gradient descent for an initial position 2 | % and an end position of a human body 3 | 4 | 5 | %you can modify the error value to make the channels get closer to the 6 | %wanted channels 7 | error = 10; 8 | step = 0.01; 9 | 10 | 11 | skel = acclaimReadSkel('07.asf'); 12 | [channels, skel] = acclaimLoadChannels('07_01.amc', skel); 13 | 14 | channels(1,[1 2 3]) = [ 0 0 0 ]; 15 | channels(200,[1 2 3])= [ 0 0 0 ]; 16 | test = zeros(1,62); 17 | 18 | %channelsFinal = gradientDescent(skel, channels(1,:), channels(200,:),error,step); 19 | channelsFinal = gradientDescent(skel, channels(1,:), test,error,step); 20 | 21 | 22 | figure(1) 23 | subplot(2,2,1) 24 | skelVisualise(channels(1,:), skel, -1); 25 | title('initial position') 26 | subplot(2,2,2) 27 | %skelVisualise(channels(200,:), skel, -1); 28 | skelVisualise(test, skel, -1); 29 | title('final position') 30 | subplot(2,2,3) 31 | skelVisualise(channels(1,:), skel, -1); 32 | %skelVisualise(channels(200,:), skel, -1); 33 | skelVisualise(test, skel, -1); 34 | title('initial and final position') 35 | 36 | 37 | figure(2) 38 | skelPlayData(skel,channelsFinal,1/60); 39 | %skelVisualise(channels(200,:), skel, -1); 40 | skelVisualise(test, skel, -1); -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/skel2xyz.m: -------------------------------------------------------------------------------- 1 | function xyz = skel2xyz(skel, channels) 2 | 3 | % SKEL2XYZ Compute XYZ values given skeleton structure and channels. 4 | % FORMAT 5 | % DESC Computes X, Y, Z coordinates given a BVH or acclaim skeleton 6 | % structure and an associated set of channels. 7 | % ARG skel : a skeleton for the bvh file. 8 | % ARG channels : the channels for the bvh file. 9 | % RETURN xyz : the point cloud positions for the skeleton. 10 | % 11 | % COPYRIGHT : Neil D. Lawrence, 2006 12 | % 13 | % SEEALSO : acclaim2xyz, bvh2xyz 14 | 15 | % MOCAP 16 | 17 | fname = str2func([skel.type '2xyz']); 18 | xyz = fname(skel, channels); 19 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/skelConnectionMatrix.m: -------------------------------------------------------------------------------- 1 | function connection = skelConnectionMatrix(skel); 2 | 3 | % SKELCONNECTIONMATRIX Compute the connection matrix for the structure. 4 | % FORMAT 5 | % DESC computes the connection matrix for the structure. Returns a matrix 6 | % which has zeros at all entries except those that are connected in the 7 | % skeleton. 8 | % ARG skel : the skeleton for which the connectivity is required. 9 | % RETURN connection : connectivity matrix. 10 | % 11 | % COPYRIGHT : Neil D. Lawrence, 2006 12 | % 13 | % SEEALSO : skelVisualise, skelModify 14 | 15 | % MOCAP 16 | 17 | connection = zeros(length(skel.tree)); 18 | for i = 1:length(skel.tree); 19 | for j = 1:length(skel.tree(i).children) 20 | connection(i, skel.tree(i).children(j)) = 1; 21 | end 22 | end 23 | 24 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/skelReverseLookup.m: -------------------------------------------------------------------------------- 1 | function index = skelReverseLookup(skel, jointName) 2 | 3 | % SKELREVERSELOOKUP Return the number associated with the joint name. 4 | % FORMAT 5 | % DESC returns the number associated with a particular joint name in a 6 | % given skeleton. 7 | % ARG skel : the skeleton to look up. 8 | % ARG jointName : the joint name to look up. 9 | % RETURN index : the index of the joint name in the skeleton. 10 | % 11 | % COPYRIGHT : Neil D. Lawrence, 2006 12 | % 13 | 14 | % MOCAP 15 | 16 | for i=1:length(skel.tree) 17 | if strcmp(skel.tree(i).name, jointName) 18 | index = i; 19 | return 20 | end 21 | end 22 | 23 | error('Reverse look up of name failed.') 24 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/skelVisualise.m: -------------------------------------------------------------------------------- 1 | function handle = skelVisualise(channels, skel, padding) 2 | 3 | % SKELVISUALISE For drawing a skel representation of 3-D data. 4 | % FORMAT 5 | % DESC draws a skeleton representation in a 3-D plot. 6 | % ARG channels : the channels to update the skeleton with. 7 | % ARG skel : the skeleton structure. 8 | % RETURN handle : a vector of handles to the plotted structure. 9 | % 10 | % SEEALSO : skelModify 11 | % 12 | % COPYRIGHT : Neil D. Lawrence, 2005, 2006 13 | 14 | % MOCAP 15 | 16 | if nargin<3 17 | padding = 0; 18 | end 19 | channels = [channels zeros(1, padding)]; 20 | vals = skel2xyz(skel, channels); 21 | connect = skelConnectionMatrix(skel); 22 | 23 | indices = find(connect); 24 | [I, J] = ind2sub(size(connect), indices); 25 | handle(1) = plot3(vals(:, 1), vals(:, 3), vals(:, 2), '.'); 26 | axis ij % make sure the left is on the left. 27 | set(handle(1), 'markersize', 20); 28 | %/~ 29 | %set(handle(1), 'visible', 'off') 30 | %~/ 31 | hold on 32 | grid on 33 | for i = 1:length(indices) 34 | handle(i+1) = line([vals(I(i), 1) vals(J(i), 1)], ... 35 | [vals(I(i), 3) vals(J(i), 3)], ... 36 | [vals(I(i), 2) vals(J(i), 2)]); 37 | set(handle(i+1), 'linewidth', 2); 38 | end 39 | axis equal 40 | xlabel('x') 41 | ylabel('z') 42 | zlabel('y') 43 | axis on 44 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/smoothAngleChannels.m: -------------------------------------------------------------------------------- 1 | function channels = smoothAngleChannels(channels, skel); 2 | 3 | % SMOOTHANGLECHANNELS Try and remove artificial discontinuities associated with angles. 4 | 5 | % MOCAP 6 | 7 | for i=1:length(skel.tree) 8 | for j=1:length(skel.tree(i).rotInd) 9 | col = skel.tree(i).rotInd(j); 10 | if col 11 | for k=2:size(channels, 1) 12 | diff=channels(k, col)-channels(k-1, col); 13 | if abs(diff+360)0) 34 | alpha(i) = -alpha(i); 35 | end 36 | 37 | if(display) 38 | waitbar(i/size(Z,1)); 39 | end 40 | 41 | end 42 | if(display) 43 | close(handle_waitbar); 44 | end 45 | 46 | return 47 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/xyzhumanevaJoint2pos.m: -------------------------------------------------------------------------------- 1 | function pos = xyzhumanevaJoint2pos(joint) 2 | 3 | % XYZHUMANEVAJOINT2POS 4 | % 5 | % COPYRIGHT : Carl Henrik Ek and Neil Lawrence, 2008 6 | 7 | % MOCAP 8 | 9 | 10 | pos = zeros(1,prod(size(joint))); 11 | 12 | pos(1:3:end) = joint(:,1); 13 | pos(2:3:end) = joint(:,2); 14 | pos(3:3:end) = joint(:,3); 15 | 16 | return 17 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/xyzhumanevaModify.m: -------------------------------------------------------------------------------- 1 | function handle = xyzhumanevaModify(handle,pos) 2 | 3 | % XYZHUMANEVAMODIFY 4 | % 5 | % COPYRIGHT : Carl Henrik Ek and Neil Lawrence, 2008 6 | 7 | % MOCAP 8 | 9 | 10 | joint = xyzhumaneva2joint(pos); 11 | 12 | if(iscell(handle)) 13 | for(i = 1:1:length(handle)) 14 | xyzhumanevaDraw(joint,handle{i}); 15 | end 16 | else 17 | xyzhumanevaDraw(joint,handle); 18 | end 19 | 20 | return 21 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/xyzhumanevaModify2.m: -------------------------------------------------------------------------------- 1 | function handle = xyzhumanevaModify2(handle,pos) 2 | 3 | % XYZHUMANEVAMODIFY2 4 | % 5 | % COPYRIGHT : Carl Henrik Ek and Neil Lawrence, 2008 6 | 7 | % MOCAP 8 | 9 | 10 | joint = xyzhumaneva2joint(pos); 11 | xyzhumanevaDraw(joint,handle{1}); 12 | xyzhumanevaDraw(joint,handle{2}); 13 | 14 | return 15 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/xyzhumanevaRemovePart.m: -------------------------------------------------------------------------------- 1 | function out = xyzhumanevaRemovePart(Z,type,limb_type) 2 | 3 | % XYZHUMANEVAREMOVEPART 4 | % 5 | % COPYRIGHT : Carl Henrik Ek and Neil Lawrence, 2008 6 | 7 | % MOCAP 8 | 9 | 10 | if(nargin<3) 11 | limb_type = 'head'; 12 | end 13 | 14 | switch type 15 | case 'jon' 16 | limb{1} = [1 2;2 3;3 4;4 5]; % left leg 17 | limb{2} = [1 6;6 7;7 8;8 9]; % right leg 18 | limb{3} = [19 10;10 11;11 12;12 13]; % left arm 19 | limb{4} = [19 14;14 15;15 16;16 17]; % right arm 20 | limb{5} = [1 19;19 18]; % head 21 | case 'raquel' 22 | limb{1} = [1 2;2 3;3 4;4 5]; % left leg 23 | limb{2} = [1 6;6 7;7 8;8 9]; % right leg 24 | limb{3} = [19 10;10 11;11 12;12 13]; % left arm 25 | limb{4} = [19 14;14 15;15 16;16 17]; % right arm 26 | limb{5} = [1 19;19 18]; % head 27 | otherwise 28 | error('Unkown parametrization'); 29 | end 30 | 31 | 32 | switch limb_type 33 | case 'head' 34 | limb_index = 19; 35 | end 36 | 37 | for(i = 1:1:size(Z,1)) 38 | pos = xyzhumaneva2joint(Z(i,:)); 39 | pos = pos(setdiff(1:1:size(pos,1),limb_index),:); 40 | out(i,:) = xyzhumanevaJoint2pos(pos); 41 | end 42 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/xyzhumanevaVisualise.m: -------------------------------------------------------------------------------- 1 | function handle = xyzhumanevaVisualise(pos,fid) 2 | 3 | % XYZHUMANEVAVISUALISE 4 | % 5 | % COPYRIGHT : Carl Henrik Ek and Neil Lawrence, 2008 6 | 7 | % MOCAP 8 | 9 | 10 | if(nargin<2) 11 | fid = 2; 12 | end 13 | 14 | figure(fid); 15 | 16 | % determine parametrization 17 | if(max(max(abs(pos)))<100) 18 | type = 'jon'; 19 | else 20 | type = 'raquel'; 21 | end 22 | 23 | switch type 24 | case 'raquel' 25 | if(size(pos(1,:),2)==54); 26 | type = 'raquelS3'; 27 | end 28 | end 29 | 30 | 31 | joint = xyzhumaneva2joint(pos); 32 | handle = xyzhumanevaDraw(joint,[],type);axis equal;view([1 0 0]); 33 | switch type 34 | case 'raquel' 35 | set(gca,'XLim',[-300 300],'YLim',[-300 300],'ZLim',[-800 800]); 36 | case 'jon' 37 | % Jon Parametrization 38 | set(gca,'XLim',[-0.35 0.35],'YLim',[-0.35 0.35],'ZLim',[-1 0.3]); 39 | end 40 | 41 | 42 | return 43 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/xyzhumanevaVisualise2.m: -------------------------------------------------------------------------------- 1 | function handle = xyzhumanevaVisualise2(pos,fid) 2 | 3 | % XYZHUMANEVAVISUALISE2 4 | % 5 | % COPYRIGHT : Carl Henrik Ek and Neil Lawrence, 2008 6 | 7 | % MOCAP 8 | 9 | 10 | if(nargin<2) 11 | fid = 2; 12 | end 13 | 14 | figure(fid); 15 | 16 | % determine parametrization 17 | if(max(max(abs(pos)))<100) 18 | type = 'jon'; 19 | else 20 | type = 'raquel'; 21 | end 22 | 23 | joint = xyzhumaneva2joint(pos); 24 | handle{1} = xyzhumanevaDraw(joint);axis equal;view([1 0 0]); 25 | switch type 26 | case 'raquel' 27 | set(gca,'XLim',[-300 300],'YLim',[-300 300],'ZLim',[-800 800]); 28 | case 'jon' 29 | set(gca,'XLim',[-0.35 0.35],'YLim',[-0.35 0.35],'ZLim',[-1 0.3]); 30 | end 31 | 32 | figure(fid+2); 33 | handle{2} = xyzhumanevaDraw(joint);axis equal;view([1 1 1]); 34 | switch type 35 | case 'raquel' 36 | set(gca,'XLim',[-300 300],'YLim',[-300 300],'ZLim',[-800 800]); 37 | case 'jon' 38 | set(gca,'XLim',[-0.35 0.35],'YLim',[-0.35 0.35],'ZLim',[-1 0.3]); 39 | end 40 | 41 | return 42 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/xyzhumanevaVisualise3d.m: -------------------------------------------------------------------------------- 1 | function handle = xyzhumanevaVisualise3d(pos,fid) 2 | 3 | % XYZHUMANEVAVISUALISE3D 4 | % 5 | % COPYRIGHT : Carl Henrik Ek and Neil Lawrence, 2008 6 | 7 | % MOCAP 8 | 9 | 10 | if(nargin<2) 11 | fid = 2; 12 | end 13 | 14 | figure(fid); 15 | 16 | % determine parametrization 17 | if(max(max(abs(pos)))<100) 18 | type = 'jon'; 19 | else 20 | type = 'raquel'; 21 | end 22 | 23 | joint = xyzhumaneva2joint(pos); 24 | figure(fid); 25 | handle = xyzhumanevaDraw(joint);axis equal;view([1 1 1]); 26 | switch type 27 | case 'raquel' 28 | set(gca,'XLim',[-300 300],'YLim',[-300 300],'ZLim',[-800 800]); 29 | case 'jon' 30 | set(gca,'XLim',[-0.35 0.35],'YLim',[-0.35 0.35],'ZLim',[-1 0.3]); 31 | end 32 | 33 | return 34 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/xyzpoppeAnim.m: -------------------------------------------------------------------------------- 1 | function xyzpoppeAnim(X, fps) 2 | 3 | % XYZPOPPEANIM Animate point cloud of stick man from Poppe dataset. 4 | % FORMAT 5 | % DESC animates a matrix of x,y,z point clound positions representing the 6 | % motion of the figure used to generate the silhouttes for Poppe 7 | % Silhouette data 8 | % ARG y : the data to animate. 9 | % ARG fps : the number of frames per second to animate (defaults to 24). 10 | % 11 | % SEEALSO : xyzpoppeVisualise, xyzpoppeModify 12 | % 13 | % COPYRIGHT : Carl Henrik Ek and Neil Lawrence, 2008 14 | 15 | % MOCAP 16 | 17 | if(nargin<3) 18 | fps = 24; 19 | if(nargin<2) 20 | fid = 1; 21 | if(nargin<1) 22 | error('Too few arguments'); 23 | end 24 | end 25 | end 26 | 27 | for(i = 1:1:size(X,1)) 28 | if(i==1) 29 | handle = xyzpoppeVisualise(X(i,:),1); 30 | else 31 | xyzpoppeModify(handle,X(i,:)); 32 | end 33 | pause(1/fps); 34 | end 35 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/xyzpoppeModify.m: -------------------------------------------------------------------------------- 1 | function handle = xyzpoppeModify(handle,pos) 2 | 3 | % XYZPOPPEMODIFY 4 | % 5 | % COPYRIGHT : Carl Henrik Ek and Neil Lawrence, 2008 6 | 7 | % MOCAP 8 | 9 | 10 | joint = xyzpoppe2joint(pos); 11 | 12 | if(iscell(handle)) 13 | for(i = 1:1:length(handle)) 14 | xyzpoppeDraw(joint,handle{i}); 15 | end 16 | else 17 | xyzpoppeDraw(joint,handle); 18 | end 19 | 20 | return 21 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/mocap/xyzpoppeVisualise.m: -------------------------------------------------------------------------------- 1 | function handle = xyzpoppeVisualise(pos,fid) 2 | 3 | % XYZPOPPEVISUALISE Draw the Poppe figure return the graphics handle. 4 | % FORMAT 5 | % DESC draws the stick figure from the Poppe silhouette 6 | % data. 7 | % ARG pos : the positions of the joints. 8 | % ARG v : the view point for the figure (defaults to standard 3D view). 9 | % RETURN handle : the graphics handle of the drawn object. 10 | % 11 | % SEEALSO : xyzpoppeDraw, xyzpoppeModify 12 | % 13 | % COPYRIGHT : Carl Henrik Ek and Neil Lawrence, 2008 14 | 15 | % MOCAP 16 | 17 | if(nargin<2); 18 | fid = 1; 19 | end 20 | 21 | % Convert positions for plotting. 22 | joint = xyzpoppe2joint(pos); 23 | handle = xyzpoppeDraw(joint); 24 | axis equal 25 | view(3); 26 | 27 | xlabel('x'); 28 | ylabel('z'); 29 | zlabel('y'); 30 | axis on 31 | 32 | return; 33 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/plot_loss.m: -------------------------------------------------------------------------------- 1 | base_dir = 'F:\CAPG\mm_lzj\code\motion_generation\log\capg-50\'; 2 | time_dir = '2018-01-09-18-58-29\'; 3 | train_loss_path = [base_dir, time_dir, 'save\train_loss.txt']; 4 | validate_loss_path = [base_dir, time_dir, 'save\validate_loss.txt']; 5 | test_loss_path = [base_dir, time_dir, 'save\test_loss.txt']; 6 | 7 | train_loss = read_json(train_loss_path); 8 | val_loss = read_json(validate_loss_path); 9 | test_loss = read_json(test_loss_path); 10 | train_x = 1 : length(train_loss); 11 | val_x = 1 : length(train_loss); 12 | test_x = 1: 1: length(train_loss); 13 | test_loss = test_loss(test_x); 14 | 15 | plot(train_x, train_loss, '-r', val_x, val_loss, '-g', test_x, test_loss, '-b'); 16 | xlabel('Epoch'); 17 | ylabel('Loss'); 18 | legend('train-loss','validate-loss', 'forecast-loss'); 19 | ylim([0, 0.5]); 20 | 21 | %% 22 | plot( test_x, test_loss, '-b'); 23 | xlabel('Epoch'); 24 | ylabel('Loss'); 25 | legend('forecast-loss'); -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/plot_mot_fig.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/computer-animation-perception-group/DeepDance/28be6b7ad6232b86e80524ba28d673154b643bcf/m2m_evaluation/matlab-file/plot_mot_fig.m -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/quat2bvh.m: -------------------------------------------------------------------------------- 1 | % normalize motion using max-min normlization 2 | function res_bvh = quat2bvh(norm_data, is_unnorm) 3 | 4 | blen = size(norm_data, 1); 5 | if is_unnorm == true 6 | info_path = 'F:/CAPG/mm_lzj/code/motion_feature/stft/info.csv'; 7 | 8 | info = dlmread(info_path); 9 | max_fea = info(1, :); 10 | min_fea = info(2, :); 11 | max_fea = repmat(max_fea, blen, 1); 12 | min_fea = repmat(min_fea, blen, 1); 13 | max_min = (max_fea - min_fea); 14 | max_min(max_min == 0) = 1e-9; 15 | unnorm_data = (norm_data + 0.9)/1.8 .* max_min + min_fea; 16 | else 17 | unnorm_data = norm_data; 18 | end 19 | 20 | res_bvh = zeros(blen, 60); 21 | for r = 1 : blen 22 | bvh_line = unnorm_data(r, :); 23 | res_bvh(r, 1:3) = bvh_line(1:3); 24 | col = 4; 25 | for j = 4 : 4 : 79 26 | q = bvh_line(j:j+3); 27 | [zr, xr, yr] = quat2angle(q, 'ZXY'); 28 | zr = rad2deg(zr); 29 | xr = rad2deg(xr); 30 | yr = rad2deg(yr); 31 | res_bvh(r, col: col+2) = [zr, xr, yr]; 32 | col = col + 3; 33 | end 34 | end 35 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/read_json.m: -------------------------------------------------------------------------------- 1 | function json_data = read_json(json_path) 2 | fid = fopen(json_path); 3 | raw = fread(fid,inf); 4 | json_str = char(raw'); 5 | fclose(fid); 6 | json_data = jsondecode(json_str); 7 | json_data = struct2cell(json_data); 8 | json_data = cell2mat(json_data); 9 | end -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/revertCoordinateSpace.m: -------------------------------------------------------------------------------- 1 | %{ 2 | Takes eucliden map input which is centered w.r.t. the starting point and 3 | convert it to w.r.t. world co-ordinate space 4 | %} 5 | 6 | function [channels_reconstruct,R_prev,T_prev] = revertCoordinateSpace(channels_self,R0,T0) 7 | % addpaths; 8 | channels_reconstruct = channels_self; 9 | R_prev = R0; 10 | T_prev = T0; 11 | rootRotInd = 4:6; 12 | for ii = 1:size(channels_self,1) 13 | R_diff = expmap2rotmat(channels_self(ii,rootRotInd)); 14 | R = R_diff*R_prev; 15 | channels_reconstruct(ii,rootRotInd) = rotmat2expmap(R); 16 | T = T_prev + ((R_prev^-1)*(channels_self(ii,1:3))')'; 17 | % T = T_prev + ((R_diff^-1)*(channels_self(ii,1:3))')'; 18 | channels_reconstruct(ii,1:3) = T; 19 | T_prev = T; 20 | R_prev = R; 21 | end; 22 | end -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/see_forecast.m: -------------------------------------------------------------------------------- 1 | net_data_dir = 'F:\CAPG\mm_lzj\code\motion_generation\log\capg-50\'; 2 | time_str = '2018-01-11-19-37-18\'; 3 | fore_len = 0; 4 | frame_rate = 1/30; 5 | epoch_str = '199\'; 6 | file_name = '549.csv'; 7 | res_dir = 'C:\Users\JohnsonLai\Desktop\01_15\srnn\'; 8 | res_path = [res_dir, time_str(1:end-1), '_', file_name]; 9 | % 100 300 301 10 | src_path = [net_data_dir, time_str, 'forecast\' ,epoch_str, file_name]; 11 | src_path = 'F:\CAPG\mm_lzj\code\music2motion\log\2018-03-03-09-33-40\train\train_predictions_40.csv'; 12 | load('cmu_retarget_skel.mat'); 13 | exp_chls = dlmread(src_path); 14 | exp_chls = exp_chls(1:500, :); 15 | % if fore_len > 0 16 | % exp_chls = exp_chls(end-fore_len:end, :); 17 | % end 18 | exp2bvh(skel, exp_chls, frame_rate); -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/vec2quat.m: -------------------------------------------------------------------------------- 1 | function q = vec2quat(u, v) 2 | % from u to v 3 | % reference: 4 | % 1. https://stackoverflow.com/questions/1171849/... 5 | % finding-quaternion-representing-the-rotation-from-one-vector-to-another 6 | % 2. http://lolengine.net/blog/2014/02/24/quaternion-from-two-vectors-final 7 | 8 | k_cos = dot(u, v); 9 | k = sqrt(norm(u)^2 * norm(v)^2) ; 10 | if k_cos / k < -0.99 11 | xyz = 0; 12 | if abs(u(1)) > abs(u(3)) 13 | w = [-u(2), u(1), 0]; 14 | else 15 | w = [0, -u(3), u(2)]; 16 | end 17 | elseif k_cos / k > 0.99 18 | xyz = 1; 19 | w = [0, 0, 0]; 20 | else 21 | xyz = k_cos + k; 22 | w = cross(u, v); 23 | end 24 | q = [xyz, w]; 25 | q = quatnormalize(q); -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/xyz2bvh.m: -------------------------------------------------------------------------------- 1 | % function xyz2bvh(skel, channels) 2 | % Incorrect 3 | clear; 4 | load('cmu_exp_skel.mat'); 5 | src_path = 'F:/CAPG/mm_lzj/code/retarget_bvh/cmu/retarget/120hz/xyz/01_02.csv'; 6 | des_path = 'F:/CAPG/mm_lzj/code/retarget_bvh/cmu/test_res/xyz2bvh/test_1.bvh'; 7 | 8 | if ~exist(fileparts(des_path), 'dir') 9 | mkdir(fileparts(des_path)); 10 | end 11 | 12 | xyz_mat = dlmread(src_path); 13 | skel = exp_skel; 14 | % for i = 1 : length(skel.tree) 15 | % skel.tree(i).channels = {'Xposition', 'Yposition', 'Zposition'}; 16 | % skel.tree(i).rotInd = []; 17 | % skel.tree(i).posInd = [(i-1)*3+1, (i-1)*3+2, (i-1)*3+3]; 18 | % end 19 | %% 20 | bvh_data = zeros(size(xyz_mat, 1), 60); 21 | fprintf('Converting to euler...\n'); 22 | for i = 1: size(xyz_mat, 1) 23 | bvh_data(i, :) = xyz2euler(skel, xyz_mat(i, :)); 24 | end 25 | fprintf('Converting success, Writing...\n'); 26 | %% 27 | bvhWriteFile(des_path, skel, bvh_data, 1/120); 28 | fprintf('Writing success, Playing...\n'); 29 | %% 30 | bvh_buffer = bvh_data; 31 | % bvh_buffer = bvh_data(1293, :); 32 | % bvh_buffer(:, 4:12) = [0, 0, 180, 0, 0, 0, 30.3822854545896,38.0166559114061,9.68409549846094]; 33 | bvhPlayData(skel, bvh_buffer, 1/120); 34 | 35 | 36 | -------------------------------------------------------------------------------- /m2m_evaluation/matlab-file/xyzModify.m: -------------------------------------------------------------------------------- 1 | function xyzModify(handle, channels, skel, padding) 2 | 3 | % SKELMODIFY Update visualisation of skeleton data. 4 | % FORMAT 5 | % DESC updates a skeleton representation in a 3-D plot. 6 | % ARG handle : a vector of handles to the structure to be updated. 7 | % ARG channels : the channels to update the skeleton with. 8 | % ARG skel : the skeleton structure. 9 | % 10 | % SEEALSO : skelVisualise 11 | % 12 | % COPYRIGHT : Neil D. Lawrence, 2005, 2006 13 | 14 | % MOCAP 15 | 16 | if nargin<4 17 | padding = 0; 18 | end 19 | channels = [channels zeros(1, padding)]; 20 | vals = reshape(channels, 3, []); 21 | vals = vals'; 22 | connect = skelConnectionMatrix(skel); 23 | 24 | indices = find(connect); 25 | [I, J] = ind2sub(size(connect), indices); 26 | 27 | 28 | set(handle(1), 'Xdata', vals(:, 1), 'Ydata', vals(:, 3), 'Zdata', ... 29 | vals(:, 2)); 30 | %/~ 31 | %set(handle(1), 'visible', 'on') 32 | %~/ 33 | 34 | for i = 1:length(indices) 35 | set(handle(i+1), 'Xdata', [vals(I(i), 1) vals(J(i), 1)], ... 36 | 'Ydata', [vals(I(i), 3) vals(J(i), 3)], ... 37 | 'Zdata', [vals(I(i), 2) vals(J(i), 2)]); 38 | end 39 | -------------------------------------------------------------------------------- /model/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/computer-animation-perception-group/DeepDance/28be6b7ad6232b86e80524ba28d673154b643bcf/model/__init__.py -------------------------------------------------------------------------------- /requirement.txt: -------------------------------------------------------------------------------- 1 | tensorflow_gpu==1.8.0 2 | numpy==1.16.4 3 | pandas==0.24.2 4 | librosa==0.6.3 -------------------------------------------------------------------------------- /sample_list.json: -------------------------------------------------------------------------------- 1 | [ 2 | "samples/gudianwu.csv", 3 | "samples/sample_music1.csv" 4 | ] -------------------------------------------------------------------------------- /statistic_features/ignore_dimensions.csv: -------------------------------------------------------------------------------- 1 | 18 2 | 19 3 | 20 4 | 33 5 | 34 6 | 35 7 | 48 8 | 49 9 | 50 10 | 60 11 | 61 12 | 62 13 | 72 14 | 73 15 | 74 16 | -------------------------------------------------------------------------------- /statistic_features/mot_data_max.csv: -------------------------------------------------------------------------------- 1 | 0.49003384 2 | 0.098606 3 | 0.5105147 4 | 0.7082812 5 | 0.3797951 6 | 0.3735329 7 | 0.5361564 8 | 0.3669903 9 | 0.5205384 10 | 0.9627585 11 | 1.1147746 12 | 0.8903766 13 | 1.6116425 14 | 0.8536882 15 | 1.2071377 16 | 1.4713241 17 | 1.915839 18 | 1.6405686 19 | -0.0 20 | -0.0 21 | -0.0 22 | 0.4353984 23 | 2.0582273 24 | 1.4724363 25 | 2.7342868 26 | 2.7655294 27 | 3.0987978 28 | 2.7937808 29 | 3.126264 30 | 3.100581 31 | 2.5031836 32 | 3.120717 33 | 3.1335528 34 | -0.0 35 | -0.0 36 | -0.0 37 | 1.1255434 38 | 1.0392774 39 | 1.0063897 40 | 2.636101 41 | 3.0564299 42 | 3.0887487 43 | 3.1122031 44 | 3.1330144 45 | 3.1372056 46 | 1.9927775 47 | 3.1415558 48 | 3.070907 49 | -0.0 50 | -0.0 51 | -0.0 52 | 2.2537298 53 | 2.0102317 54 | 0.9201749 55 | 1.0137045 56 | 1.548014 57 | 2.9543607 58 | 2.1379645 59 | 2.7491229 60 | 2.0891223 61 | -0.0 62 | -0.0 63 | -0.0 64 | 2.1997406 65 | 3.1380532 66 | 2.3282866 67 | 2.442728 68 | 1.5378275 69 | 2.8874273 70 | 2.4346633 71 | 3.129 72 | 2.099245 73 | -0.0 74 | -0.0 75 | -0.0 76 | -------------------------------------------------------------------------------- /statistic_features/mot_data_mean.csv: -------------------------------------------------------------------------------- 1 | -0.00019843427 2 | -0.00013048419 3 | 0.0011662428 4 | -4.5912402e-05 5 | -0.0013248713 6 | -0.00015187473 7 | 0.024744548 8 | 0.002511129 9 | 0.015936438 10 | 0.106019415 11 | 0.027981704 12 | 0.003948365 13 | -0.1675113 14 | 0.06533457 15 | 0.039919894 16 | -0.1327631 17 | 0.10187928 18 | 0.05336368 19 | 0.0 20 | 0.0 21 | 0.0 22 | -0.16868012 23 | -0.08236213 24 | -0.1322091 25 | 0.1644107 26 | 0.033706944 27 | -0.5554038 28 | 0.9140234 29 | 0.013111535 30 | 0.64201725 31 | -0.020184662 32 | -0.015545757 33 | 0.009812002 34 | 0.0 35 | 0.0 36 | 0.0 37 | -0.12561543 38 | 0.04439954 39 | 0.087746195 40 | 0.15391262 41 | -0.20833896 42 | 0.5380564 43 | 0.84107375 44 | -0.106223725 45 | -0.26381412 46 | 0.10373221 47 | -0.06339156 48 | 0.06879778 49 | 0.0 50 | 0.0 51 | 0.0 52 | 0.21720347 53 | 0.04184109 54 | -0.13977702 55 | -0.44814417 56 | 0.0019641167 57 | 0.17119564 58 | 0.4194583 59 | -0.30855438 60 | 0.31146747 61 | 0.0 62 | 0.0 63 | 0.0 64 | 0.2161398 65 | 0.22562782 66 | 0.101612054 67 | -0.36991054 68 | 0.055063076 69 | -0.07649407 70 | 0.43603146 71 | 0.0021689732 72 | -0.17088667 73 | 0.0 74 | 0.0 75 | 0.0 76 | -------------------------------------------------------------------------------- /statistic_features/mot_data_min.csv: -------------------------------------------------------------------------------- 1 | -0.49790215 2 | -0.11617858 3 | -0.518385 4 | -0.4016256 5 | -0.4256568 6 | -0.7971931 7 | -1.106191 8 | -0.4816924 9 | -0.5904078 10 | -0.8939407 11 | -0.6750529 12 | -0.9989755 13 | -1.7043656 14 | -0.7738294 15 | -1.3155042 16 | -1.4527339 17 | -1.9050816 18 | -0.9611766 19 | -0.0 20 | -0.0 21 | -0.0 22 | -1.0294149 23 | -1.1762207 24 | -1.5447459 25 | -2.441296 26 | -2.489949 27 | -3.1022375 28 | -1.9554178 29 | -3.138305 30 | -3.0356612 31 | -2.254636 32 | -3.1247313 33 | -2.759926 34 | -0.0 35 | -0.0 36 | -0.0 37 | -2.2651894 38 | -0.989962 39 | -1.7701393 40 | -2.0043523 41 | -3.1054523 42 | -3.077362 43 | -3.070969 44 | -3.133468 45 | -3.0920098 46 | -3.1075847 47 | -3.141469 48 | -3.079672 49 | -0.0 50 | -0.0 51 | -0.0 52 | -0.8158536 53 | -1.4576343 54 | -1.7983347 55 | -2.6973033 56 | -2.1038816 57 | -1.5274743 58 | -2.2426808 59 | -2.7885432 60 | -2.2376103 61 | -0.0 62 | -0.0 63 | -0.0 64 | -1.4032366 65 | -3.1408737 66 | -2.3184674 67 | -2.7152765 68 | -1.3325422 69 | -2.0616944 70 | -1.4791074 71 | -3.133696 72 | -2.1837816 73 | -0.0 74 | -0.0 75 | -0.0 76 | -------------------------------------------------------------------------------- /statistic_features/mot_data_std.csv: -------------------------------------------------------------------------------- 1 | 0.011072728 2 | 0.008143786 3 | 0.009629969 4 | 0.011966494 5 | 0.03735334 6 | 0.013871224 7 | 0.13337106 8 | 0.040832724 9 | 0.06354646 10 | 0.16584064 11 | 0.11863567 12 | 0.09564784 13 | 0.22551112 14 | 0.17577526 15 | 0.12335801 16 | 0.29525626 17 | 0.4305215 18 | 0.23567313 19 | 0.0 20 | 0.0 21 | 0.0 22 | 0.12112879 23 | 0.10775214 24 | 0.28145844 25 | 0.46240196 26 | 0.4008449 27 | 0.59965926 28 | 0.5485715 29 | 0.51184434 30 | 0.81511486 31 | 0.3713573 32 | 0.61450833 33 | 0.46985462 34 | 0.0 35 | 0.0 36 | 0.0 37 | 0.1269012 38 | 0.18645102 39 | 0.32808048 40 | 0.48168546 41 | 0.46491048 42 | 0.60764414 43 | 0.5195682 44 | 0.52934074 45 | 0.56231546 46 | 0.3228932 47 | 0.5162893 48 | 0.4810829 49 | 0.0 50 | 0.0 51 | 0.0 52 | 0.30695584 53 | 0.52647144 54 | 0.2091251 55 | 0.36992282 56 | 0.24864317 57 | 0.29788077 58 | 0.40613884 59 | 0.6284811 60 | 0.30772942 61 | 0.0 62 | 0.0 63 | 0.0 64 | 0.31208783 65 | 0.6913236 66 | 0.2548297 67 | 0.4296718 68 | 0.23768088 69 | 0.394291 70 | 0.46940404 71 | 0.8614376 72 | 0.49306425 73 | 0.0 74 | 0.0 75 | 0.0 76 | -------------------------------------------------------------------------------- /statistic_features/new_idx.csv: -------------------------------------------------------------------------------- 1 | 0 2 | 1 3 | 2 4 | 3 5 | 4 6 | 5 7 | 6 8 | 7 9 | 8 10 | 9 11 | 10 12 | 11 13 | 12 14 | 13 15 | 14 16 | 15 17 | 16 18 | 17 19 | -1 20 | -1 21 | -1 22 | 18 23 | 19 24 | 20 25 | 21 26 | 22 27 | 23 28 | 24 29 | 25 30 | 26 31 | 27 32 | 28 33 | 29 34 | -1 35 | -1 36 | -1 37 | 30 38 | 31 39 | 32 40 | 33 41 | 34 42 | 35 43 | 36 44 | 37 45 | 38 46 | 39 47 | 40 48 | 41 49 | -1 50 | -1 51 | -1 52 | 42 53 | 43 54 | 44 55 | 45 56 | 46 57 | 47 58 | 48 59 | 49 60 | 50 61 | -1 62 | -1 63 | -1 64 | 51 65 | 52 66 | 53 67 | 54 68 | 55 69 | 56 70 | 57 71 | 58 72 | 59 73 | -1 74 | -1 75 | -1 76 | -------------------------------------------------------------------------------- /utils/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/computer-animation-perception-group/DeepDance/28be6b7ad6232b86e80524ba28d673154b643bcf/utils/__init__.py --------------------------------------------------------------------------------