Skip to content

Commit 9259cd7

Browse files
mairatmaeduardolundgren
authored andcommitted
Fixing Brief test
1 parent 0cf535c commit 9259cd7

2 files changed

Lines changed: 36 additions & 7 deletions

File tree

build/tracking.js

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,7 @@
886886
}());
887887

888888
(function() {
889-
/*
889+
/**
890890
* ViolaJones utility.
891891
* @static
892892
* @constructor
@@ -990,6 +990,7 @@
990990
* @return {boolean} True whether the block at position i,j can be skipped,
991991
* false otherwise.
992992
* @static
993+
* @protected
993994
*/
994995
tracking.ViolaJones.isTriviallyExcluded = function(edgesDensity, integralImageSobel, i, j, width, blockWidth, blockHeight) {
995996
var wbA = i * width + j;
@@ -1211,6 +1212,7 @@
12111212
* @return {Int32Array} Returns an array where for each four sequence int
12121213
* values represent the descriptor binary string (128 bits) necessary
12131214
* to describe the corner, e.g. [0,0,0,0, 0,0,0,0, ...].
1215+
* @static
12141216
*/
12151217
tracking.Brief.getDescriptors = function(pixels, width, keypoints) {
12161218
// Optimizing divide by 32 operation using binary shift
@@ -1267,6 +1269,7 @@
12671269
* corner2, e.g. keypoints1=[x0,y0,x1,y1,...] and
12681270
* keypoints2=[x'0,y'0,x'1,y'1,...], if x0 matches x'1 and x1 matches x'0,
12691271
* the return array would be [3,0].
1272+
* @static
12701273
*/
12711274
tracking.Brief.match = function(keypoints1, descriptors1, keypoints2, descriptors2) {
12721275
var len1 = keypoints1.length >> 1;
@@ -1311,6 +1314,7 @@
13111314
* corner2, e.g. keypoints1=[x0,y0,x1,y1,...] and
13121315
* keypoints2=[x'0,y'0,x'1,y'1,...], if x0 matches x'1 and x1 matches x'0,
13131316
* the return array would be [3,0].
1317+
* @static
13141318
*/
13151319
tracking.Brief.reciprocalMatch = function(keypoints1, descriptors1, keypoints2, descriptors2) {
13161320
var matches = [];
@@ -1332,6 +1336,7 @@
13321336
* Gets the coordinates values of (x,y)-location pairs uniquely chosen
13331337
* during the initialization.
13341338
* @return {array} Array with the random offset values.
1339+
* @private
13351340
*/
13361341
tracking.Brief.getRandomOffsets_ = function(width) {
13371342
if (!this.randomWindowOffsets_) {
@@ -1361,7 +1366,7 @@
13611366
}());
13621367

13631368
(function() {
1364-
/*
1369+
/**
13651370
* FAST intends for "Features from Accelerated Segment Test". This method
13661371
* performs a point segment test corner detection. The segment test
13671372
* criterion operates by considering a circle of sixteen pixels around the
@@ -1411,6 +1416,7 @@
14111416
* darker than the corner candidate p. Default value is 40.
14121417
* @return {array} Array containing the coordinates of all found corners,
14131418
* e.g. [x0,y0,x1,y1,...], where P(x0,y0) represents a corner coordinate.
1419+
* @static
14141420
*/
14151421
tracking.Fast.findCorners = function(pixels, width, height, opt_threshold) {
14161422
var circleOffsets = this.getCircleOffsets_(width);
@@ -1456,11 +1462,21 @@
14561462
* @param {number} p The value of the candidate pixel p.
14571463
* @param {number} threshold
14581464
* @return {Boolean}
1465+
* @static
14591466
*/
14601467
tracking.Fast.isBrighter = function(circlePixel, p, threshold) {
14611468
return circlePixel - p > threshold;
14621469
};
14631470

1471+
/**
1472+
* Checks if the circle pixel is within the corner of the candidate pixel p
1473+
* by a threshold.
1474+
* @param {number} p The value of the candidate pixel p.
1475+
* @param {number} circlePixel The circle pixel value.
1476+
* @param {number} threshold
1477+
* @return {Boolean}
1478+
* @static
1479+
*/
14641480
tracking.Fast.isCorner = function(p, circlePixels, threshold) {
14651481
if (this.isTriviallyExcluded(circlePixels, p, threshold)) {
14661482
return false;
@@ -1503,6 +1519,7 @@
15031519
* @param {number} p The value of the candidate pixel p.
15041520
* @param {number} threshold
15051521
* @return {Boolean}
1522+
* @static
15061523
*/
15071524
tracking.Fast.isDarker = function(circlePixel, p, threshold) {
15081525
return p - circlePixel > threshold;
@@ -1518,6 +1535,8 @@
15181535
* @param {number} p The value of the candidate pixel p.
15191536
* @param {number} threshold
15201537
* @return {Boolean}
1538+
* @static
1539+
* @protected
15211540
*/
15221541
tracking.Fast.isTriviallyExcluded = function(circlePixels, p, threshold) {
15231542
var count = 0;
@@ -1566,6 +1585,7 @@
15661585
* @param {number} width The image width.
15671586
* @return {array} Array with the sixteen offset values of the circle
15681587
* surrounding pixel.
1588+
* @private
15691589
*/
15701590
tracking.Fast.getCircleOffsets_ = function(width) {
15711591
if (this.circles_[width]) {
@@ -1627,9 +1647,12 @@
16271647
* of 1's in the string.
16281648
*
16291649
* Example:
1650+
*
1651+
* <pre>
16301652
* Binary string Hamming weight
16311653
* 11101 4
16321654
* 11101010 5
1655+
* </pre>
16331656
*
16341657
* @param {number} i Number that holds the binary string to extract the hamming weight.
16351658
* @return {number} The hamming weight.
@@ -1654,9 +1677,11 @@
16541677
/**
16551678
* Tests if a rectangle intersects with another.
16561679
*
1680+
* <pre>
16571681
* x0y0 -------- x2y2 --------
16581682
* | | | |
16591683
* -------- x1y1 -------- x3y3
1684+
* </pre>
16601685
*
16611686
* @param {number} x0 Horizontal coordinate of P0.
16621687
* @param {number} y0 Vertical coordinate of P0.
@@ -2003,6 +2028,7 @@
20032028
* @param {number} width The image width.
20042029
* @return {array} Array with the eight offset values of the neighbours
20052030
* surrounding a pixel.
2031+
* @private
20062032
*/
20072033
tracking.ColorTracker.prototype.getNeighboursForWidth_ = function(width) {
20082034
if (tracking.ColorTracker.neighbours_[width]) {
@@ -2028,6 +2054,7 @@
20282054
/**
20292055
* Unites groups whose bounding box intersect with each other.
20302056
* @param {Array.<Object>} rects
2057+
* @private
20312058
*/
20322059
tracking.ColorTracker.prototype.mergeRectangles_ = function(rects) {
20332060
var intersects;
@@ -2118,6 +2145,7 @@
21182145
* @param {number} width The pixels canvas width.
21192146
* @param {number} height The pixels canvas height.
21202147
* @param {string} color The color to be found
2148+
* @private
21212149
*/
21222150
tracking.ColorTracker.prototype.trackColor_ = function(pixels, width, height, color) {
21232151
var colorFn = tracking.ColorTracker.knownColors_[color];

test/Brief.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ module.exports = {
1414
// TODO: Update this test to generate randomWindowOffsets_ and randomImageOffsets_ instead.
1515
testGetDescriptors: function(test) {
1616
var descriptors;
17+
var descriptorsPerKeypoint = tracking.Brief.N / 32;
1718
var grayScale = [
1819
0, 0, 1, 0, 0, 0,
1920
1, 9, 0, 9, 1, 0,
@@ -23,20 +24,20 @@ module.exports = {
2324
var width = 6;
2425

2526
// Write the offsets manually, as we can't verify results that are obtained randomly.
26-
tracking.Brief.randomOffsets_[width] = [];
27+
tracking.Brief.randomImageOffsets_[width] = [];
2728
for (var i = 0; i < tracking.Brief.N; i++) {
2829
var position = i % 4;
29-
tracking.Brief.randomOffsets_[width].push(repeat[position * 2], repeat[position * 2 + 1]);
30+
tracking.Brief.randomImageOffsets_[width].push(repeat[position * 2], repeat[position * 2 + 1]);
3031
}
3132

3233
descriptors = tracking.Brief.getDescriptors(grayScale, width, [1, 1, 3, 1]);
3334

34-
test.equal(8, descriptors.length, 'There should be 8 descriptor words');
35+
test.equal(2 * descriptorsPerKeypoint, descriptors.length, 'There should be 8 descriptor words');
3536

36-
for (var j = 0; j < 4; j++) {
37+
for (var j = 0; j < descriptorsPerKeypoint; j++) {
3738
test.equal(858993459, descriptors[j], 'Descriptor should be 858993459');
3839
}
39-
for (var k = 5; k < 8; k++) {
40+
for (var k = descriptorsPerKeypoint; k < 2 * descriptorsPerKeypoint; k++) {
4041
test.equal(-286331154, descriptors[k], 'Descriptor should be -286331154');
4142
}
4243

0 commit comments

Comments
 (0)