opendatacam / node-moving-things-tracker

javascript implementation of "tracker by detections" for realtime multiple object tracking (MOT)
MIT License
105 stars 25 forks source link

WIP: added browserify bundle scripts to package.json #8

Closed b-g closed 4 years ago

b-g commented 6 years ago

@tdurand WIP. Having trouble with this ... could you have a look?

$ npm run bundle

> node-moving-things-tracker@0.4.2 bundle /Users/bene/Documents/node-moving-things-tracker
> browserify main.js -t babelify --standalone movingThingsTracker -o dist/moving-things-tracker.js

SyntaxError: /Users/bene/Documents/node-moving-things-tracker/main.js: 'return' outside of function (29:2)
  27 | if(!pathRawDetectionsInput) {
  28 |   console.error('Please specify the path to the raw detections file');
> 29 |   return;
     |   ^
  30 | }
  31 | 
  32 | // Compute the output file path
    at Parser.pp$5.raise (/Users/bene/Documents/node-moving-things-tracker/node_modules/babylon/lib/index.js:4454:13)
    at Parser.pp$1.parseReturnStatement (/Users/bene/Documents/node-moving-things-tracker/node_modules/babylon/lib/index.js:2066:10)
    at Parser.pp$1.parseStatement (/Users/bene/Documents/node-moving-things-tracker/node_modules/babylon/lib/index.js:1848:19)
    at Parser.pp$1.parseBlockBody (/Users/bene/Documents/node-moving-things-tracker/node_modules/babylon/lib/index.js:2268:21)
    at Parser.pp$1.parseBlock (/Users/bene/Documents/node-moving-things-tracker/node_modules/babylon/lib/index.js:2247:8)
    at Parser.pp$1.parseStatement (/Users/bene/Documents/node-moving-things-tracker/node_modules/babylon/lib/index.js:1868:19)
    at Parser.pp$1.parseIfStatement (/Users/bene/Documents/node-moving-things-tracker/node_modules/babylon/lib/index.js:2059:26)
    at Parser.pp$1.parseStatement (/Users/bene/Documents/node-moving-things-tracker/node_modules/babylon/lib/index.js:1846:19)
    at Parser.pp$1.parseBlockBody (/Users/bene/Documents/node-moving-things-tracker/node_modules/babylon/lib/index.js:2268:21)
    at Parser.pp$1.parseTopLevel (/Users/bene/Documents/node-moving-things-tracker/node_modules/babylon/lib/index.js:1778:8)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-moving-things-tracker@0.4.2 bundle: `browserify main.js -t babelify --standalone movingThingsTracker -o dist/moving-things-tracker.js`
npm ERR! Exit status 1
tdurand commented 6 years ago

The main.js contain the logic for parsing the command line and stuff, the core module is tracker.js

For some reason the main.js code fails to pass the browserify exporting, but as the code of the main.js isn't needed, I changed it to export the tracker.js only and it works

Then to use it you can import the script in dist/ and

movingThingsTracker.updateTrackedItemsWithNewFrame(detectionsOfThisFrame, frameNb);
// NB: We could simplify the API and auto increment frame by 1 when calling updateTrackedItemsWithNewFrame

const trackerDataForThisFrame = movingThingsTracker.getJSONOfTrackedItems();
tdurand commented 6 years ago

Seems the uglify script isn't properly working yet, I let you have a look

tdurand commented 4 years ago

close this as very old