npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

object-tracking-measure

v1.7.0

Published

Implementation of object tracking measure in javascript (MOTA, IDF1 ...)

Downloads

33

Readme

Build Status

Object Tracking measure

This project aims to calculate metrics for tracking algorithm (especially MOTA, IDF1)

MOTA

See [1].

const otm = require('object-tracking-measure');

const groundTruths = [
	[
		[22, 33, 20, 20],// x, y, w, h
		[22, 33, 20, 20],
		[22, 33, 20, 20],
		[22, 33, 20, 20]
	],
	[
		[22, 33, 20, 20],// x, y, w, h
		null,
		[25, 35, 20, 20],
		[39, 41, 20, 20]
	]
];

const predictions = [
	[
		[23, 33, 22, 20],// x, y, w, h
		[21, 35, 20, 26],
		[23, 33, 22, 20],
		[21, 35, 20, 26]
	],
	[
		[23, 33, 20, 20],// x, y, w, h
		null,
		[23, 35, 22, 20],
		[39, 35, 20, 26]
	]
];

otm.mota({
	groundTruths,
	predictions
});

IDF1

See [2].

const otm = require('object-tracking-measure');

const groundTruths = [
	[
		[22, 33, 20, 20],// x, y, w, h
		[22, 33, 20, 20],
		[22, 33, 20, 20],
		[22, 33, 20, 20]
	],
	[
		[22, 33, 20, 20],// x, y, w, h
		null,
		[25, 35, 20, 20],
		[39, 41, 20, 20]
	]
];

const predictions = [
	[
		[23, 33, 22, 20],// x, y, w, h
		[21, 35, 20, 26],
		[23, 33, 22, 20],
		[21, 35, 20, 26]
	],
	[
		[23, 33, 20, 20],// x, y, w, h
		null,
		[23, 35, 22, 20],
		[39, 35, 20, 26]
	]
];

otm.idf1({
	groundTruths,
	predictions
});

Advanced usage

By default, object-tracking-measure uses

  • distance between boxes is (1 - Intersection Over Union) (using mean-average-precision library)
  • threshold is 1 (i.e. IOU = 0 - no overlap)

You can cutomize this, for example to track distance between {x,y} points like

const otm = require('object-tracking-measure');

const groundTruths = [
	[
		{x: 22, y: 34},
		{x: 22, y: 34},
		{x: 22, y: 34},
		{x: 22, y: 34}
	],
	[
		{x: 55, y: 68},// x, y, w, h
		null,
		{x: 55, y: 68},
		{x: 55, y: 68}
	]
];

const predictions = [
	[
		{x: 22, y: 34},// x, y, w, h
		{x: 22, y: 34},
		{x: 22, y: 34},
		{x: 22, y: 34}
	],
	[
		{x: 55, y: 68},// x, y, w, h
		null,
		{x: 55, y: 68},
		{x: 55, y: 68}
	]
];

otm.idf1({
	groundTruths,
	predictions,
	distFn: ((a,b) => Math.sqrt(((a.x - b.x) * (a.x - b.x)) + ((a.y - b.y) * (a.y - b.y)))), // Euclidian distance
	threshold: 2 // means that 2 meters far is too far
});

Inspect ID Metric

const measure = otm.idDetails({
	groundTruths,
	predictions
});

console.log(otm.idInspect(Object.assign({}, measure, {
	columns: process.stdout.columns - 20
})))

will print

--
GroundTruth[0]✓――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――✓
Prediction[0] ✓――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――✓
              |----------------------------|----------------------------|---------------------------
              0                            1                            2                           

--
GroundTruth[1]✓―――――――――――――――――――――――――――✓?―――――――――――――――――――――――――――?✓――――――――――――――――――――――――――✓
Prediction[1] ✓―――――――――――――――――――――――――――✓?―――――――――――――――――――――――――――?✓――――――――――――――――――――――――――✓
              |----------------------------|----------------------------|---------------------------

Inspect MOT Metric

const measure = otm.motDetails({
	groundTruths,
	predictions
});

console.log(otm.motInspect(Object.assign({}, measure, {
	columns: process.stdout.columns - 20
})))

will print

0[0]                1-1-1-1-1-1-1-1-1-1-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-
1[1]                0-0-0-0-0-0-0-0-0-0---------------------1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-

Other tools

getStats

const result = otm.getStats({
	track: [
		[22, 33, 20, 20], // X, y, w, h
		null,
		[25, 35, 20, 20],
		[39, 41, 20, 20],
		null
	]
});

/* 
{
	count: 3, // number of non-null point)
	iterationAge: 1, // number of null at the end
	fullDensity: 0.6, // non-null /total size of track
	gapDensity: 0.3333333333333333, // number of gaps / number of non-null
	density: 0.75, // non-null / size of the trimed track
	firstIndex: 0, // first index of the trimed track
	lastIndex: 3 // last index of the trimed track
}
*/
 

fastGetNullSegment

const result = otm.fastGetNullSegment({
	track: [
		[22, 33, 20, 20], // X, y, w, h
		null,
		null,
		null,
		[25, 35, 20, 20],
		[39, 41, 20, 20],
		null
	]
});

/* 
{
	first: 1,
	last: 5,
	type: 'null',
}
*/
 

References

[1] Keni Bernardin and Rainer Stiefelhagen (2008). Evaluating Multiple Object Tracking Performance: The CLEAR MOT Metrics

[2] Ergys Ristani1, Francesco Solera2, Roger S. Zou1, Rita Cucchiara2, and Carlo Tomasi1 (2016). Performance Measures and a Data Set for Multi-Target, Multi-Camera Tracking