Ask Your Question

Revision history [back]

How do I change predict method in class FaceRecognizer

I trying to custom predict method for my application, but doesn't work. How can I do this?

How do I change predict method in class FaceRecognizer

I trying to custom predict method for my application, but doesn't work. How can I do this?

I wanna change this part in facerec.cpp, where would be calculated Mahalanobis distance:

for(size_t sampleIdx = 0; sampleIdx < _projections.size(); sampleIdx++) {
        double dist = norm(_projections[sampleIdx], q, NORM_L2);
        if((dist < minDist) && (dist < _threshold)) {
            minDist = dist;
            minClass = _labels.at<int>((int)sampleIdx);
        }
    }

I change in contrib.hpp to:

 virtual int predict(InputArray src,int distance) const = 0;

where distance is the type identifier of the distance to be calculated (Euclidian, Mahalanobis, Cosine)