Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ItemTracked.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ exports.ItemTracked = function(properties, frameNb, unMatchedFramesTolerance, fa
}

itemTracked.toMOT = function(frameIndex) {
return `${frameIndex},${this.idDisplay},${this.x},${this.y},${this.w},${this.h},${this.confidence / 100},-1,-1,-1`;
return `${frameIndex},${this.idDisplay},${this.x - this.w / 2},${this.y - this.h / 2},${this.w},${this.h},${this.confidence / 100},-1,-1,-1`;
}

itemTracked.toJSONGenericInfo = function() {
Expand Down
11 changes: 7 additions & 4 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,14 @@ fs.readFile(`${pathRawDetectionsInput}`, function (err, f) {
var detectionOfThisFrameArray = line.split(",");
var detectionFrameIndex = parseInt(detectionOfThisFrameArray[0], 10);
if (!Number.isNaN(detectionFrameIndex)) {
var w = parseFloat(detectionOfThisFrameArray[4]);
var h = parseFloat(detectionOfThisFrameArray[5]);

var detection = {
x: parseFloat(detectionOfThisFrameArray[2]),
y: parseFloat(detectionOfThisFrameArray[3]),
w: parseFloat(detectionOfThisFrameArray[4]),
h: parseFloat(detectionOfThisFrameArray[5]),
x: parseFloat(detectionOfThisFrameArray[2]) + w / 2,
y: parseFloat(detectionOfThisFrameArray[3]) + h / 2,
Comment on lines +142 to +143

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we subtract the width and height instead of adding it? Or am I misunderstanding the coordinate system?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be correct that way. The format of the MOT17 input file is
<frame>, <id>, <bb_left>, <bb_top>, <bb_width>, <bb_height>, <conf>, <x>, <y>, <z>
so we're going from top left corner to center point, which means adding half of width and height.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, you're right! 👍

w,
h,
confidence: parseFloat(detectionOfThisFrameArray[6]) * 100,
name: ""
}
Expand Down
18 changes: 9 additions & 9 deletions utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ exports.isDetectionTooLarge = (detections, largestAllowed) => {
}

const isInsideArea = (area, point) => {
const xMin = area.x
const xMax = area.x + area.w;
const yMin = area.y
const yMax = area.y + area.h;
const xMin = area.x - area.w / 2;
const xMax = area.x + area.w / 2;
const yMin = area.y - area.h / 2;
const yMax = area.y + area.h / 2;

if(point.x >= xMin &&
point.x <= xMax &&
point.y >= yMin &&
Expand All @@ -35,10 +35,10 @@ exports.ignoreObjectsNotToDetect = (detections, objectsToDetect) => {

const getRectangleEdges = (item) => {
return {
x0: item.x,
y0: item.y,
x1: item.x + item.w,
y1: item.y + item.h
x0: item.x - item.w / 2,
y0: item.y - item.h / 2,
x1: item.x + item.w / 2,
y1: item.y + item.h / 2,
}
}

Expand Down