简体   繁体   English

读取 opencv_face.LBPHFaceRecognizer.getHistograms() 中的值

[英]Reading values in opencv_face.LBPHFaceRecognizer.getHistograms()

I am trying to work with the open_cv library in android.我正在尝试使用 android 中的 open_cv 库。 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.我的识别器活动中有一个opencv_face.LBPHFaceRecognizer object。 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.我无法在 mat object 中找到任何版本的 .get() 或 .at() 方法。

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.我能够通过将 opencv_core.Mat 转换为 opencv_core.CvMat object 来读取这些值。 I don't know for what reason this object is marked deprecated but this worked fine for me:我不知道为什么这个 object 被标记为已弃用,但这对我来说很好:

            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.此处的输入变量现在具有所有直方图的所需值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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