Instantly share code, notes, and snippets.

• Sort options
Last active Apr 8, 2019
Gist for Move Mirror blog post: vp tree
View moveMirrorVPTree.js
 const similarity = require('compute-cosine-similarity'); const VPTreeFactory = require('vptree'); const poseData = [ […], […], […], …] // an array with all the images’ pose data let vptree ; // where we’ll store a reference to our vptree // Function from the previous section covering cosine distance function cosineDistanceMatching(poseVector1, poseVector2) { let cosineSimilarity = similarity(poseVector1, poseVector2); let distance = 2 * (1 - cosineSimilarity);
Created Jul 18, 2018
Gist for Move Mirror blog post: weighted distance
View moveMirrorWeightedDistance.js
 // poseVector1 and poseVector2 are 52-float vectors composed of: // Values 0-33: are x,y coordinates for 17 body parts in alphabetical order // Values 34-51: are confidence values for each of the 17 body parts in alphabetical order // Value 51: A sum of all the confidence values // Again the lower the number, the closer the distance function weightedDistanceMatching(poseVector1, poseVector2) { let vector1PoseXY = poseVector1.slice(0, 34); let vector1Confidences = poseVector1.slice(34, 51); let vector1ConfidenceSum = poseVector1.slice(51, 52);
Created Jul 18, 2018
Gist for Move Mirror blog post: cosine distance
View moveMirrorCosineDistance.js
 // Great npm package for computing cosine similarity const similarity = require('compute-cosine-similarity'); // Cosine similarity as a distance function. The lower the number, the closer // the match // poseVector1 and poseVector2 are a L2 normalized 34-float vectors (17 keypoints each // with an x and y. 17 * 2 = 32) function cosineDistanceMatching(poseVector1, poseVector2) { let cosineSimilarity = similarity(poseVector1, poseVector2); let distance = 2 * (1 - cosineSimilarity); return Math.sqrt(distance);
Created Dec 16, 2017