Opencv_contrib: Whether it is possible to add dlib.net recognition of faces and speed up

Created on 4 Nov 2017  ·  1Comment  ·  Source: opencv/opencv_contrib

its algorithm works much slower, but with one person the best result

question (invalid tracker)

Most helpful comment

most parts you'll need are already builtin with recent opencv3.4 !

you can use the same, pretrained deep-face network, using opencv's dnn module, like this:

    dnn::Net net;
    try {
        net = dnn::readNetFromTorch("openface.nn4.small2.v1.t7");
    } catch(Exception &e) {
        cerr << "Download it from:  ";
        cerr << "https://raw.githubusercontent.com/pyannote/pyannote-data/master/openface.nn4.small2.v1.t7" << endl;
    }

    // later:
    Mat inputBlob = dnn::blobFromImage(image, 1./255, Size(96,96), Scalar(), true, false);
    net.setInput(inputBlob);
    Mat feature = net.forward();

now you can compare images, using the 128 float feature Mat from the dnn output, using a simple:

  double distance = norm(feature_a, feature_b);

(or train your favourite ml or clustering)

>All comments

most parts you'll need are already builtin with recent opencv3.4 !

you can use the same, pretrained deep-face network, using opencv's dnn module, like this:

    dnn::Net net;
    try {
        net = dnn::readNetFromTorch("openface.nn4.small2.v1.t7");
    } catch(Exception &e) {
        cerr << "Download it from:  ";
        cerr << "https://raw.githubusercontent.com/pyannote/pyannote-data/master/openface.nn4.small2.v1.t7" << endl;
    }

    // later:
    Mat inputBlob = dnn::blobFromImage(image, 1./255, Size(96,96), Scalar(), true, false);
    net.setInput(inputBlob);
    Mat feature = net.forward();

now you can compare images, using the 128 float feature Mat from the dnn output, using a simple:

  double distance = norm(feature_a, feature_b);

(or train your favourite ml or clustering)

Was this page helpful?
0 / 5 - 0 ratings