简体   繁体   中英

Reading values in opencv_face.LBPHFaceRecognizer.getHistograms()

I am trying to work with the open_cv library in android. I have never worked on it before, so this may be a very basic question.

I have an opencv_face.LBPHFaceRecognizer object in my Recognizer Activity. My requirement is to read the histogram values for previously-stored faces.

            opencv_face.LBPHFaceRecognizer mFaceRecognizer = = createLBPHFaceRecognizer(2, 8, 8, 8, 95);
            File file = new File(RegisterActivity.getFilePath(mContext));
            mFaceRecognizer.load(file.getAbsolutePath());


            opencv_core.MatVector vector = mFaceRecognizer.getHistograms();
            for (int i = 0; i < vector.size(); i++) {
                opencv_core.Mat mat = vector.get(i);
                opencv_core.Size size = mat.size();
                for (int j = 0; j < size.height();j++)
                    for (int k = 0; k < size.width(); k++) {
                        // Here I want to ready the values (which would be same as the values in file am initializing mFaceRecognizer with) of these matrices but I am not able to find any appropriate method to do so.
                    }
            }

Please help me out with the required methods to do so, I have tried many resources and gone through documentation as well, but being a beginner I think I am missing something.

I am not able to find any version of.get() or.at() method in mat object.

Any help would be greatly appreciated. Thanks in advance.

I was able to read the values by converting opencv_core.Mat to opencv_core.CvMat object. I don't know for what reason this object is marked deprecated but this worked fine for me:

            double[][] input = new double[(int)vector.size()][vector.get(0).size().width()];
            for (int i = 0; i < vector.size(); i++) {
                opencv_core.Mat mat = vector.get(i);
                (new opencv_core.CvMat(mat)).get(input[i]);
            }

input variable here now had required values of all the histograms.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM