Skip to content

Commit 4b71712

Browse files
committed
barebones readme
1 parent 80efb2d commit 4b71712

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# dlib-correlation-tracker-js
2+
3+
Track moving objects in videos in Javascript using [dlib's correlation tracker](http://dlib.net/python/index.html#dlib.correlation_tracker). These bindings compile the module using [emscripten](http://emscripten.org/), providing the raw interface as well as a utility class to simplify working with an [HTML `<video>` element](https://developer.mozilla.org/en-US/docs/Web/API/HTMLVideoElement).
4+
5+
## Usage
6+
7+
```bash
8+
$ npm install --save dlib-correlation-tracker-js
9+
```
10+
11+
To use the DOM interface, create a new `VideoCorrelationTracker` with an `HTMLVideoElement` and the position of the object to track. A new prediction can be generated based on the video's current frame at any time by referring to `tracker.prediction`. The tracker can be fine-tuned by updating it with a user-specified rect using `tracker.update(rect)`.
12+
13+
```js
14+
import { VideoCorrelationTracker } from 'dlib-correlation-tracker';
15+
16+
// begin by passing a video and a bounding box of what you want to track
17+
const tracker = new VideoCorrelationTracker(document.querySelector('video'), { x, y, width, height });
18+
19+
// update the tracker with a specified rect when the video updates
20+
tracker.update({ x, y, width, height });
21+
22+
// get the tracker's prediction for the current video frame
23+
const { x, y, width, height } = tracker.prediction;
24+
25+
// if the video dimensions change, memory must be manually re-allocated
26+
function onVideoDimensionsChange(video) {
27+
VideoCorrelationTracker.reserveMemory(video);
28+
}
29+
30+
// memory must also be manually freed when done!
31+
function onUnload() {
32+
VideoCorrelationTracker.freeMemory();
33+
}
34+
```

0 commit comments

Comments
 (0)