Skip to content

Instantly share code, notes, and snippets.

@irealva
Last active May 11, 2023 06:29
Show Gist options
  • Save irealva/6d6b7cacda0bba2f41117142105cc6dd to your computer and use it in GitHub Desktop.
Save irealva/6d6b7cacda0bba2f41117142105cc6dd to your computer and use it in GitHub Desktop.
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);
}
@BioGeek
Copy link

BioGeek commented Mar 21, 2019

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

@irealva
Copy link
Author

irealva commented Oct 13, 2020

thanks for that! fixed it

@ZhangZoffy
Copy link

We used each person’s bounding box coordinates to crop and scale each image (and corresponding keypoint coordinates) to a consistent size.
how tom crop and scale? why height == weight?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment