Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function compareIcons( icon1, icon2, callback ) {
try {
fs.statSync( icon1 );
} catch ( error ) {
// File doesn't exists. This is a new icon. So yes, it's different.
return callback( false );
}
png.decode( icon1, function( pixels1 ) {
png.decode( icon2, function( pixels2 ) {
if ( pixels1.length != pixels2.length )
return callback( false );
for ( var i = pixels1.length ; i-- ; ) {
if ( pixels1[ i ] !== pixels2[ i ] )
return callback( false );
}
return callback( true );
} );
} );
}
setUp: function(done) {
PNG.decode('test/assets/faces.png', function(pixels) {
image = pixels;
done();
});
},
PNG.decode('test/assets/box1.png', function(pixels1) {
image1Gray = tracking.Image.grayscale(pixels1, imageWidth, imageHeight);
corners1 = tracking.Fast.findCorners(image1Gray, imageWidth, imageHeight);
descriptors1 = tracking.Brief.getDescriptors(image1Gray, imageWidth, corners1);
PNG.decode('test/assets/box2.png', function(pixels2) {
image2Gray = tracking.Image.grayscale(pixels2, imageWidth, imageHeight);
corners2 = tracking.Fast.findCorners(image2Gray, imageWidth, imageHeight);
descriptors2 = tracking.Brief.getDescriptors(image2Gray, imageWidth, corners1);
done();
});
});
range(0, n).forEach(function (i) {
png.decode(fixtures('frame' + i + '.png'), function (pixels) {
frames[i] = pixels;
next();
});
});
setUp: function(done) {
PNG.decode('test/assets/box1.png', function(pixels1) {
image1Gray = tracking.Image.grayscale(pixels1, imageWidth, imageHeight);
corners1 = tracking.Fast.findCorners(image1Gray, imageWidth, imageHeight);
descriptors1 = tracking.Brief.getDescriptors(image1Gray, imageWidth, corners1);
PNG.decode('test/assets/box2.png', function(pixels2) {
image2Gray = tracking.Image.grayscale(pixels2, imageWidth, imageHeight);
corners2 = tracking.Fast.findCorners(image2Gray, imageWidth, imageHeight);
descriptors2 = tracking.Brief.getDescriptors(image2Gray, imageWidth, corners1);
done();
});
});
},
setUp: function(done) {
PNG.decode('test/assets/psmove.png', function(pixels) {
image = pixels;
done();
});
},
setUp: function(done) {
PNG.decode('test/assets/box1.png', function(pixels) {
image = pixels;
imageGray = tracking.Image.grayscale(image, imageWidth, imageHeight);
done();
});
},
.map(file => new Promise(resolve => png.decode(file, pixels => resolve(pixels))))
)
png.decode( icon1, function( pixels1 ) {
png.decode( icon2, function( pixels2 ) {
if ( pixels1.length != pixels2.length )
return callback( false );
for ( var i = pixels1.length ; i-- ; ) {
if ( pixels1[ i ] !== pixels2[ i ] )
return callback( false );
}
return callback( true );
} );
} );
}
constructor(data, label) {
this.label = label;
this.image = new PNG(data);
this.width = this.image.width;
this.height = this.image.height;
this.imgData = this.image.imgData;
this.obj = null;
}