Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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);

This comment has been minimized.

Copy link

@BioGeek BioGeek commented Mar 21, 2019

The 32 at the end of the second comment should be 34.


This comment has been minimized.

Copy link
Owner Author

@irealva irealva commented Oct 13, 2020

thanks for that! fixed it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.