Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

OpenCV 3.3.0 predict mismatches with all

We called predict in Java class like this.

int[] label = new int[1];
double[] d = new double[1];
predict(mGrey.getNativeObjAddr(), label, confidence);
Log.v(TAG, "Prediction completed, label[0]: " + label[0] + ", d[0]: " + d[0]);

And in JNI predict method defined like this.

JNIEXPORT void JNICALL Java_com_opencv.test_FaceRecognizer_predict
        (JNIEnv *env, jobject thisObj, jlong image1, jintArray label, jdoubleArray confidence) {
    Mat &mGr = *(Mat *) image1;
    jint *labelBody = (*env).GetIntArrayElements(label, 0);
    jdouble *confidenceBody = (*env).GetDoubleArrayElements(confidence, 0);
    int &myLabel = labelBody[0];
    double &myConfidence = confidenceBody[0];
    LOGD("Prediction started in JNI");
    model->predict(mGr, myLabel, myConfidence);
    LOGD("Prediction ended in JNI");
    (*env).ReleaseIntArrayElements(label, labelBody, 0);
    (*env).ReleaseDoubleArrayElements(confidence, confidenceBody, 0);
}

Here model is declared like this,

Ptr<LBPHFaceRecognizer> model;

And this model has been accessible by all methods in this JNI class.

And initiated like this.

model = LBPHFaceRecognizer::create();

I got logcat output as

Prediction completed, label[0]: 1, d[0]: 38.56067116659108

Don't know how it returns 38 % confidence level for some other person. Is there anything wrong in my code?

Previously I trained opencv with 10 images of one person, those images are 250X250 sizes.

This predict method predicts all members with same level of confidence. Don't know how?

Any help will be highly appreciated.

OpenCV 3.3.0 predict mismatches with all

We called predict in Java class like this.

int[] label = new int[1];
double[] d = new double[1];
label[0] = -1;
d[0] = 0.0;
predict(mGrey.getNativeObjAddr(), label, confidence);
Log.v(TAG, "Prediction completed, label[0]: " + label[0] + ", d[0]: " + d[0]);

And in JNI predict method defined like this.

JNIEXPORT void JNICALL Java_com_opencv.test_FaceRecognizer_predict
        (JNIEnv *env, jobject thisObj, jlong image1, jintArray label, jdoubleArray confidence) {
    Mat &mGr = *(Mat *) image1;
    jint *labelBody = (*env).GetIntArrayElements(label, 0);
    jdouble *confidenceBody = (*env).GetDoubleArrayElements(confidence, 0);
    int &myLabel = labelBody[0];
    double &myConfidence = confidenceBody[0];
    LOGD("Prediction started in JNI");
    model->predict(mGr, myLabel, myConfidence);
    LOGD("Prediction ended in JNI");
    (*env).ReleaseIntArrayElements(label, labelBody, 0);
    (*env).ReleaseDoubleArrayElements(confidence, confidenceBody, 0);
}

Here model is declared like this,

Ptr<LBPHFaceRecognizer> model;

And this model has been accessible by all methods in this JNI class.

And initiated like this.

model = LBPHFaceRecognizer::create();

I got logcat output as

Prediction completed, label[0]: 1, d[0]: 38.56067116659108

Don't know how it returns 38 % confidence level for some other person. Is there anything wrong in my code?

Previously I trained opencv with 10 images of one person, those images are 250X250 sizes.

This predict method predicts all members with same level of confidence. Don't know how?

Any help will be highly appreciated.

OpenCV 3.3.0 predict mismatches with all

We called predict in Java class like this.

int[] label = new int[1];
double[] d = new double[1];
label[0] = -1;
d[0] = 0.0;
predict(mGrey.getNativeObjAddr(), label, confidence);
Log.v(TAG, "Prediction completed, label[0]: " + label[0] + ", d[0]: " + d[0]);

And in JNI predict method defined like this.

JNIEXPORT void JNICALL Java_com_opencv.test_FaceRecognizer_predict
        (JNIEnv *env, jobject thisObj, jlong image1, jintArray label, jdoubleArray confidence) {
    Mat &mGr = *(Mat *) image1;
    jint *labelBody = (*env).GetIntArrayElements(label, 0);
    jdouble *confidenceBody = (*env).GetDoubleArrayElements(confidence, 0);
    int &myLabel = labelBody[0];
    double &myConfidence = confidenceBody[0];
    LOGD("Prediction started in JNI");
    model->predict(mGr, myLabel, myConfidence);
    LOGD("Prediction ended in JNI");
    (*env).ReleaseIntArrayElements(label, labelBody, 0);
    (*env).ReleaseDoubleArrayElements(confidence, confidenceBody, 0);
}

Here model is declared like this,

Ptr<LBPHFaceRecognizer> model;

And this model has been accessible by all methods in this JNI class.

And initiated like this.

model = LBPHFaceRecognizer::create();

I got logcat output as

Prediction completed, label[0]: 1, d[0]: 38.56067116659108

Don't know how it returns 38 % confidence level for some other person. Is there anything wrong in my code?

Previously I trained opencv with 10 images of one person, those images are 250X250 sizes.

This predict method predicts all members with same level of confidence. Don't know how?

Any help will be highly appreciated.