For those who don't know about what is Tracking.js, The tracking.js library brings different computer vision algorithms and techniques into the browser environment. Using modern HTML5 specifications, it enables you to do real-time color tracking, face detection, and much more. Learn more about it on https://trackingjs.com/
But my problem is I want to see the percentage similarity of the two images by using Tracking.js Feature Descriptor (Brief). I read the documentation but can't understand properly.
window.onload = function() {
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();