Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I want to see the similarity percentage between two images using Brief. #401

Open
nurulalamador opened this issue Jun 15, 2022 · 1 comment

Comments

@nurulalamador
Copy link

nurulalamador commented Jun 15, 2022

I want to see the similarity percentages between the two images using Brief. I can't understand too much by reading Documentation how can I do this. Can anyone help me with this, please?

    var width = 393;
    var height = 295;
    var canvas = document.getElementById('canvas');
    var context = canvas.getContext('2d');

    var image1 = document.getElementById('image1');
    var image2 = document.getElementById('image2');

    window.descriptorLength = 256;
    window.matchesShown = 30;
    window.blurRadius = 3;

    var doMatch = function() {
      tracking.Brief.N = window.descriptorLength;

      context.drawImage(image1, 0, 0, width, height);
      context.drawImage(image2, width, 0, width, height);
  
      var imageData1 = context.getImageData(0, 0, width, height);
      var imageData2 = context.getImageData(width, 0, width, height);
  
      var gray1 = tracking.Image.grayscale(tracking.Image.blur(imageData1.data, width, height, blurRadius), width, height);
      var gray2 = tracking.Image.grayscale(tracking.Image.blur(imageData2.data, width, height, blurRadius), width, height);
  
      var corners1 = tracking.Fast.findCorners(gray1, width, height);
      var corners2 = tracking.Fast.findCorners(gray2, width, height);
  
      var descriptors1 = tracking.Brief.getDescriptors(gray1, width, corners1);
      var descriptors2 = tracking.Brief.getDescriptors(gray2, width, corners2);
  
      var matches = tracking.Brief.reciprocalMatch(corners1, descriptors1, corners2, descriptors2);

      matches.sort(function(a, b) {
        return b.confidence - a.confidence;
      });
  
      var similarityPercentage = **What Shoud I Count Here?**;
      console.log(similarityPercentage)
    };

    doMatch();

https://trackingjs.com/examples/brief.html

@tj-creative
Copy link

tj-creative commented Jun 15, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants