Skip to content

Commit

Permalink
[Feature] Add args (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucksp authored Sep 13, 2024
2 parents ab69881 + 8146d6e commit fba7523
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ node_modules/
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*


.DS_Store
21 changes: 17 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,18 @@ export interface RecognizedObject {
missedCount: number;
}

/**
* FrameRecognition arguments:
* @param height: the height of the device
* @param width: the width of the device
* @param recognitionCount: optional, minimum number of items you want before being considered as a top object
* @param score: optional, minimum threshold of box score to keep track of
*/
interface Props {
height: number;
width: number;
recognitionCount?: number;
score?: number;
}

/**
Expand All @@ -30,25 +39,29 @@ export class FrameRecognition {
recognizedObjectsCount: number;
height: number;
width: number;
recognitionCount: number;
scoreThreshold: number;

constructor({ height, width }: Props) {
constructor({ height, width, recognitionCount = 20, score = 0.25 }: Props) {
this.height = height;
this.width = width;
this.trackingObjects = {};
this.recognizedObjectsCount = 0;
this.recognitionCount = recognitionCount;
this.scoreThreshold = score;
}

/**
* getConfidentObject are the most confident about.
* It finds the object with the highest score & count.
* @returns RecognizedObject
* @todo llow more than 1 output item
* @todo allow more than 1 output item
*/
getConfidentObject() {
let topObject: RecognizedObject | null = null;

for (const recognized of Object.values(this.trackingObjects)) {
if (recognized.recognitionCount < 10) {
if (recognized.recognitionCount < 20) {
continue;
}

Expand Down Expand Up @@ -85,7 +98,7 @@ export class FrameRecognition {
const label = labels[i];
const score = scores[i];

if (score < 0.25) {
if (score < this.scoreThreshold) {
continue;
}

Expand Down

0 comments on commit fba7523

Please sign in to comment.