Skip to content

Features: Reset idDisplay, configurable fast delete and custom distance function#19

Merged
tdurand merged 15 commits intoopendatacam:masterfrom
vsaw:master
Sep 8, 2020
Merged

Features: Reset idDisplay, configurable fast delete and custom distance function#19
tdurand merged 15 commits intoopendatacam:masterfrom
vsaw:master

Conversation

@vsaw
Copy link
Copy Markdown
Collaborator

@vsaw vsaw commented Aug 11, 2020

This pull request contains 3 improvements

1. Reset idDisplay

Resetting the tracker did not affect the item ID. Therefore multiple tests runs on the same file were difficult to evaluate as one had to offset the later runs to get the actual number of the items tracked.

This pull request fixes this. As it introduces a new reset function for ItemsTracked.

To prove it is working, jasmine tests with GitHub Actions are included. As GitHub does not run the checks in the opendatacam repository see the passing checks in my fork here: https://github.com/vsaw/node-moving-things-tracker/actions/runs/202256302

2. Configurable Fast Delete

This allows to configure if detections should be removed quickly in cases where they were detected and could not be matched afterwards.

Fast deletion can be enabled/disabled via:

Tracker.setParams({ fastDelete: false });

Again passing tests can be see here https://github.com/vsaw/node-moving-things-tracker/pull/2/checks

3. Custom Distance Function

In cases where one wants to try with a custom distance function it can now be passed to the Tracer as follows:

// See https://en.wikipedia.org/wiki/Taxicab_geometry
function l1metric(item1, item2) {
  // Get the x and y distance, in relation to the item size
  const xDist = Math.abs(item1.x - item2.x) / ((item1.w + item2.w) / 2);
  const yDist = Math.abs(item1.y - item2.y) / ((item1.h + item2.h) / 2);
  return xDist + yDist;
}

Tracker.setParams({ distanceFunc: l1metric });

As usual passing tests can be found here: https://github.com/vsaw/node-moving-things-tracker/actions/runs/203819989

vsaw and others added 9 commits August 10, 2020 10:57
Resetting the tracker now also resets the ID if tracked items.
This allows to configure if detections should be removed
quickly in cases where they were detected and could not
be matched afterwards.

Fast deletion can be enabled/disabled via

```
Tracker.setParams({ items: { fastDelete: false } });
```
Feat(Tracker): Configurable Fast Delete
Allows to change fast detele for each item individually (e.g.
based on confidence).
refactor(Tracker): FastDelete configurable per Item
Feat(Tracker): Allow for custom distance functions
@vsaw vsaw changed the title Reset idDisplay, configurable fast delete and custom distance function Features: Reset idDisplay, configurable fast delete and custom distance function Aug 11, 2020
vsaw and others added 4 commits August 11, 2020 12:02
chore(ItemTracked): Removes unused function
This is useful to set the distance limit when setting a custom distance
function.
Refactor(tracker): Allow setting distance limit
@tdurand
Copy link
Copy Markdown
Member

tdurand commented Sep 8, 2020

Hi,

Thanks for cleaning up and improving this messy code ;-) ..

Seems good to me, could release this as a new version of the node package and add it to OpenDataCam

curious if for your use case if you found some good improvements from tweaking the tracker ?

@vsaw
Copy link
Copy Markdown
Collaborator Author

vsaw commented Sep 8, 2020

Hi @tdurand

Thanks for cleaning up and improving this messy code ;-) ..

Thank you for putting up the hard work and writing it in the first place 🙂

Seems good to me, could release this as a new version of the node package and add it to OpenDataCam

I've bumped the version, but I'm unsure if I can push a new version to npmjs. Once we a new version up on npm I'd be happy to update the dependency in OpenDataCam itself.

curious if for your use case if you found some good improvements from tweaking the tracker ?

I guess my results are highly use case specific, but when tracking small objects (< 5% of relative size) the objects were often moving to fast for the tracker to have an overlap between two frames. Therefore

  1. I disabled the "fast delete" so we have a few more objects to match against.
  2. I created a custom distance function which tolerated small gaps between objects. I effectively "inflated" the objects a bit, to make their area bigger than what YOLO detected, before running them through the regular iouDistance function.

In my case this had a significant impact on the number of IDs the tracker produced.

chart

OpenDataCam itself did not have this dramatic increase of counted objects, but I was still able to track 12% more objects on average.

@tdurand
Copy link
Copy Markdown
Member

tdurand commented Sep 8, 2020

@vsaw nice, no I think I need to push it myself for the rights for npm... will do now.

Many thanks for the inputs.. makes sense if there are too small object.. and yes main problem is that everything tends to be use case specific so no real winner ;-)

Glad OpenDataCam was a good starting base for your project

@tdurand tdurand merged commit 474f50a into opendatacam:master Sep 8, 2020
@tdurand
Copy link
Copy Markdown
Member

tdurand commented Sep 8, 2020

I just published v8.0.0 on npm and added a release: https://github.com/opendatacam/node-moving-things-tracker/releases

Hopefully this will helps you avoid maintaining a fork on your end ..

@vsaw
Copy link
Copy Markdown
Collaborator Author

vsaw commented Sep 8, 2020

@vsaw nice, no I think I need to push it myself for the rights for npm... will do now.

Maybe a GitHub Action such as https://github.com/marketplace/actions/npm-publish could help to take the grunt work out of it :-)

Glad OpenDataCam was a good starting base for your project

Yes, thanks again for opening it up for others!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants