This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 = 34) | |
function cosineDistanceMatching(poseVector1, poseVector2) { | |
let cosineSimilarity = similarity(poseVector1, poseVector2); | |
let distance = 2 * (1 - cosineSimilarity); | |
return Math.sqrt(distance); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Author: Irene Alvarado | |
Description: Add all the Twitter users you are following to a Twitter list. | |
Useful if using services such as TweetDeck to search only through people you are following | |
To run: first install twit through node `npm install twit`, then run `node addTwitterFollowingToList.js` | |
Change your API keys and list configurations where the comments say TODO. | |
Note about API limits: Twitter sets limits for how many users you can add to a list within 12 hours. |