Skip to content
/ image-tag Public

Processes passed image buffer (sorry, no streams at this point due to limiations of the underlaying operations), detects faces on the image, adds perceptual hash, and phashBinary (can be used for image similarity matching)

Notifications You must be signed in to change notification settings

AVVS/image-tag

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Image tag

Outputs perceptual hash and face objects that are present on the image; Requires phash, cimg, imagemagick and opencv to be installed. It must be noted that due to the limitation of phash, which only accepts file paths, we must have access to some folder, where we can write tmp files. By default module uses os.tmpdir() + '/image-tag-' + pkg.version directory to store files, and cleans them up after they had been processed. If you want to speed up processing and only pay the price of copying memory (which is, of course, still not ideal) - create ramdisk and use it

npm install image-tag -S

Installing

TODO: list libraries needed to install

Usage

Accepts image buffer and outputs tagged image:

var ImageTag = require('image-tag');
var imageTag = new ImageTag({
    tmpDir: '/path/to/ramdisk',
    faceProfiles: false, // you can pass paths to custom xml haar cascades, that will be used to detect faces. In fact you can detect smth other than a face here
    phash: true, // determines whether we need to calculate phash
    phashBinary: true, // should we calculat it?
    face: true, // determines whether we need to detect face
    size: true // do we need to report size? Add width, height to the response
});

// works only with png and jp(e)g images, so if you need to do this with other formats
// please convert your image beforehand
imageTag.detect(imageBuffer, function (err, data) {
    if (err) throw err;

    // data contains:
    {
        // only if hasFace eq true
        face: {
            x: Number,
            y: Number,
            width: Number,
            height: Number
        },
        width: Number,
        height: Number,
        hasFace: Boolean,
        phash: String, // 72-byte hex string
        phashBinary: [Number] // array of numbers, contains position of each 1 in the binary format of phash hex string
    }

});

About

Processes passed image buffer (sorry, no streams at this point due to limiations of the underlaying operations), detects faces on the image, adds perceptual hash, and phashBinary (can be used for image similarity matching)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published