quaggaJS: Limiting false positives
During excessive testing, I found that I get about 5 to 10 percent false positives. But I found out – and I do not think that this is documented - if you check the error of the decodedCodes, you will find that by rejection codes with a certain error margin will increase your hit rate 100 percent.
This is the code I use. I take the average error margin. If it is below 0.1 it is fair to assume we detected the code correct.
So far I had no false positives at all while still a very fast detection.
var countDecodedCodes=0, err=0;
$.each(result.codeResult.decodedCodes, function(id,error){
if (error.error!=undefined) {
countDecodedCodes++;
err+=parseFloat(error.error);
}
});
if (err/countDecodedCodes < 0.1) {
// correct code detected
} else {
// probably wrong code
}
Hope this helps!
About this issue
- Original URL
- State: open
- Created 7 years ago
- Reactions: 10
- Comments: 15
Based on @iFlash answer, I made it using median instead of averages.
During my tests (built-in webcam), I noticed that many times it reads correctly, but its averages were all above 0.1 because some of the errors has a much higher value like
0.3 ..0.4while others are0.05. .0.07, thus “pulling” the average up.Medians represents most of the dataset a bit better. That being said, I still get false positives occasionally. Hit rate of probably 7-8/10, but a faster match than averages.
Its good for me.
you can try this make an array and select the highest mode value
Hi,
I too am struggling with error rates. I have tried your code and unfortunately still get errors, the longer the code the more likely there will be an error.
For example scanning the attached code for me sometimes scans correctly, at other times returns garbage within the string such as “6e&n Connery”:
My own personal sanity check on the bar codes is to dictate a valid format of the returned string, e.g. reject any results that contain non-alphanumeric such as &, #, @, etc. This may work for you, but if you actually want to accept strings containing these characters this workaround is not a valid solution.
I’ve combined your solution with my own, which has reduced my error rate to zero in my use case:
Hope this helps!
@ericblade Base on @sam-lex answer, I get good results (near 100%) validating errors against two threshold : median et max values