mirror of
https://github.com/koush/scrypted.git
synced 2026-06-20 08:30:30 +01:00
videonanalysis: notes on character casing todo.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
// visual similarity
|
||||
const similarCharacters = [
|
||||
['0', 'O', 'D'],
|
||||
['1', 'I'],
|
||||
@@ -32,6 +33,12 @@ function isSameCharacter(c1: string, c2: string) {
|
||||
}
|
||||
|
||||
export function levenshteinDistance(str1: string, str2: string): number {
|
||||
// todo: handle lower/uppercase similarity in similarCharacters above.
|
||||
// ie, b is visualy similar to 6, but does not really look like B.
|
||||
// others include e and C. v, u and Y. l, i, 1.
|
||||
str1 = str1.toUpperCase();
|
||||
str2 = str2.toUpperCase();
|
||||
|
||||
const len1 = str1.length;
|
||||
const len2 = str2.length;
|
||||
|
||||
|
||||
@@ -173,8 +173,7 @@ export class SmartMotionSensor extends ScryptedDeviceBase implements Settings, R
|
||||
if (this.storageSettings.values.requireDetectionThumbnail && !detected.detectionId)
|
||||
return false;
|
||||
|
||||
let { labels, labelDistance } = this.storageSettings.values;
|
||||
labels = labels?.map((l: string) => l.toUpperCase());
|
||||
const { labels, labelDistance } = this.storageSettings.values;
|
||||
|
||||
const match = detected.detections?.find(d => {
|
||||
if (this.storageSettings.values.requireScryptedNvrDetections && !d.boundingBox)
|
||||
@@ -208,15 +207,14 @@ export class SmartMotionSensor extends ScryptedDeviceBase implements Settings, R
|
||||
if (!d.label)
|
||||
return false;
|
||||
|
||||
const du = d.label.toUpperCase();
|
||||
for (const label of labels) {
|
||||
if (label === du)
|
||||
if (label === d.label)
|
||||
return true;
|
||||
if (!labelDistance)
|
||||
continue;
|
||||
if (levenshteinDistance(label, du) <= labelDistance)
|
||||
if (levenshteinDistance(label, d.label) <= labelDistance)
|
||||
return true;
|
||||
this.console.log('No label does not match.', label, du);
|
||||
this.console.log('No label does not match.', label, d.label);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user