Skip to content

Instantly share code, notes, and snippets.

View irealva's full-sized avatar

Irene Alvarado irealva

View GitHub Profile
@irealva
irealva / moveMirrorVPTree.js
Last active May 11, 2023 06:26
Gist for Move Mirror blog post: vp tree
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);
@irealva
irealva / moveMirrorWeightedDistance.js
Created July 18, 2018 22:23
Gist for Move Mirror blog post: weighted distance
// 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);
@irealva
irealva / moveMirrorCosineDistance.js
Last active May 11, 2023 06:29
Gist for Move Mirror blog post: cosine distance
// 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);
@irealva
irealva / addTwitterFollowingToList.js
Created December 16, 2017 21:12
Add all the Twitter users you are following to a Twitter list.
/*
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.