tracking.js
tracking.js copied to clipboard
I want to see the similarity percentage between two images using Brief.
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
这是来自QQ邮箱的假期自动回复邮件。 您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。