Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 7 additions & 19 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -177,15 +177,15 @@
*/


var best_match = 101
var best_match = -1
var best_shape = ""
var best_index = -1

var second_match = 101
var second_match = -1
var second_shape = ""
var second_index = -1

var matchPerc = 101
var matchPerc = -1


if(algorithm == "hausdorff"){
Expand All @@ -201,10 +201,6 @@
var secMom1 = Sketchy.secondMoment('hiddenDude1');


} else if(algorithm == "shape_context"){
best_match = -1;
matchPerc = -1;
second_match = -1;
}

for (i=0; i<ALL_LETTERS_KEYS.length; i++){
Expand All @@ -218,7 +214,7 @@
//console.log(best_match + ", " + second_match + ", " + matchPerc)
//console.log(" best: "+ best_match + ", second: " + second_match + ", match: " + matchPerc)
//keep track of the best match
if (matchPerc < best_match){
if (matchPerc > best_match){
//console.log("before best: "+ best_match + ", second: " + second_match + ", match: " + matchPerc)
second_match = best_match
second_shape = best_shape
Expand All @@ -229,7 +225,7 @@
best_index = i
//console.log("after best: "+ best_match + ", second: " + second_match + ", match: " + matchPerc)
//continue
} else if (matchPerc < second_match){
} else if (matchPerc > second_match){
//console.log("-before best: "+ best_match + ", second: " + second_match + ", match: " + matchPerc)
second_match = matchPerc
second_shape = ALL_LETTERS[i]
Expand Down Expand Up @@ -272,20 +268,12 @@
}
}//end for loop

//handle the face that this alg returns ##%, not .##%
if(algorithm == "shape_context"){
best_match = best_match;
second_match = second_match;
}


//output result
console.log("Best match: " + ALL_LETTERS_KEYS[best_index] + ", " + best_match);
console.log("Next match: " + ALL_LETTERS_KEYS[second_index]+ ", " + second_match);

//best match
percent = (Math.floor(best_match * 10000)/100)
percent = percent.toString().substring(0,5)
percent = (best_match * 100).toFixed(2)
percentStr = percent + "%"


Expand Down Expand Up @@ -1083,4 +1071,4 @@ <h3>Welcome to Sketchy.js.</h3>
</footer>
</div>
</body>
</html>
</html>