JavaCV FaceRecognizer预测不起作用

时间:2013-12-29 23:13:34

标签: opencv computer-vision javacv face-recognition

我正在使用opencv 2.4.6和javacv 0.6。我正在尝试制作面部识别器。 这是我的代码:

    FaceRecognizer ef = createEigenFaceRecognizer(1, 0.00000001);
    int facewidth = 92, faceheight = 112;
    private boolean stopRec = false;
    List<String> names = new ArrayList<String>();

    public void recognize(IplImage face) {
        int predicted;
        int [] tabPredicted = new int[2];
        double[] predConfTab = new double[2];
        IplImage resizedFace = IplImage.create(new CvSize(facewidth,  faceheight), IPL_DEPTH_8U, 1);
        cvResize(face, resizedFace);
        if (names.size() != 0)
        {
           ef.predict(resizedFace, tabPredicted, predConfTab);
           predicted = tabPredicted[0];
        }
        else
        {
               predicted = -1;
        }

        if(predicted == -1 ) 
        {
           //adding user like: 
           int i = names.size();
           names.add(name);
           System.out.println("Identified new person: " + names.get(i));
           MatVector mv = new MatVector(1);
           mv.put(0, resizedFace);
           int[] u = new int[] {i};
           ef.train(mv, u);
        }

我尝试了很多配置。我敢肯定我有灰度的有效脸部图像。问题是在ef.predict(resizedFace, tabPredicted, predConfTab);之后 tabPredicted[0]始终是最后添加的用户的索引,predConfTab[0]始终等于0,因此这意味着任何面孔都与最后添加的面孔完全匹配。

0 个答案:

没有答案