Skip to content

Commit 1d7efcd

Browse files
First working version (http://cl.ly/image/1r1t471h3N2T)
1 parent e46c8c4 commit 1d7efcd

1 file changed

Lines changed: 18 additions & 15 deletions

File tree

src/tracker/human/human.js

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
defaults: {
1010
blockSize: 20,
1111

12-
blockJump: 10,
12+
blockJump: 5,
1313

1414
blockScale: 1.25,
1515

@@ -25,7 +25,7 @@
2525
treeLen = tree.length,
2626
t,
2727

28-
inverseArea = 1/(blockSize*blockSize),
28+
inverseArea = 1.0/(blockSize*blockSize),
2929
scale = blockSize/defaults.blockSize,
3030

3131
stageSum = 0;
@@ -66,16 +66,19 @@
6666
}
6767

6868
for (r = 0; r < rectsLen; r++) {
69-
x1 = j + node[r*5];
70-
y1 = i + node[r*5 + 1];
69+
x1 = j + ~~(node[r*5]*scale);
70+
y1 = i + ~~(node[r*5 + 1]*scale);
7171
rectWidth = ~~(node[r*5 + 2]*scale);
7272
rectHeight = ~~(node[r*5 + 3]*scale);
7373
rectWeight = node[r*5 + 4];
7474

75-
w1 = x1*width + y1;
76-
w2 = x1*width + (y1 + rectWidth);
77-
w3 = (x1 + rectHeight)*width + y1;
78-
w4 = (x1 + rectHeight)*width + (y1 + rectWidth);
75+
x2 = x1 + rectWidth;
76+
y2 = y1 + rectHeight;
77+
78+
w1 = y1*width + x1;
79+
w2 = y1*width + x2;
80+
w3 = y2*width + x1;
81+
w4 = y2*width + x2;
7982

8083
rectsSum += (integralImage[w1] - integralImage[w2] - integralImage[w3] + integralImage[w4])*rectWeight;
8184
}
@@ -99,8 +102,8 @@
99102
canvas = video.canvas,
100103
height = canvas.get('height'),
101104
width = canvas.get('width'),
102-
integralImage = new Array(width*height),
103-
integralImageSquare = new Array(width*height),
105+
integralImage = new Uint32Array(width*height),
106+
integralImageSquare = new Uint32Array(width*height),
104107

105108
imageLen = 0,
106109
g,
@@ -144,7 +147,7 @@
144147
blockSize = defaults.blockSize,
145148
maxBlockSize = Math.min(width, height);
146149

147-
for (; blockSize <= maxBlockSize; blockSize = ~~(blockScale*blockSize)) {
150+
for (; blockSize <= maxBlockSize; blockSize = ~~(blockSize*blockScale)) {
148151
for (i = 0; i < (height - blockSize); i+=blockJump) {
149152
for (j = 0; j < (width - blockSize); j+=blockJump) {
150153
var pass = true;
@@ -160,6 +163,10 @@
160163
}
161164

162165
if (pass) {
166+
console.log('ROSTO');
167+
// canvas.setImageData(imageData);
168+
canvas.context.strokeStyle = "rgb(255,0,0)";
169+
canvas.context.strokeRect(j, i, blockSize, blockSize);
163170
}
164171
}
165172
}
@@ -168,8 +175,4 @@
168175

169176
};
170177

171-
// canvas.setImageData(imageData);
172-
// canvas.context.strokeStyle = "rgb(255,0,0)";
173-
// canvas.context.strokeRect(j, i, blockSize, blockSize);
174-
175178
}( window ));

0 commit comments

Comments
 (0)