I'm trying to convert a Java class to a C# one using EmguCV. It's for a class in Unsupervised Learning. The teacher made a program using OpenCV and Java. I have to convert it to C#.
The goal is to implement a simple Face Recognition algorithm.
The method I'm stuck at:
Mat sample = train.get(0).getData(); mean = Mat.zeros(/*6400*/sample.rows(), /*1*/sample.cols(), /*CvType.CV_64FC1*/sample.type()); // Calculating it by hand train.forEach(person -> { Mat data = person.getData(); for (int i = 0; i < mean.rows(); i++) { double mv = mean.get(i, 0)[0]; // Gets the value of the cell in the first channel double pv = data.get(i, 0)[0]; // Gets the value of the cell in the first channel mv += pv; mean.put(i, 0, mv); // *********** I'm stuck here *********** } }); So far, my C# equivalent is:
var sample = trainSet[0].Data; mean = Mat.Zeros(sample.Rows, sample.Cols, sample.Depth, sample.NumberOfChannels); foreach (var person in trainSet) { var data = person.Data; for (int i = 0; i < mean.Rows; i++) { var meanValue = (double)mean.GetData().GetValue(i,0); var personValue = (double)data.GetData().GetValue(i, 0); meanValue += personValue; } } And I am not finding the put equivalent in C#. But, if I'm being honest, I'm not even sure the previous two lines in my C# equivalent are correct.
Can someone help me figure this one out?
https://stackoverflow.com/questions/65864907/emgucv-equivalent-to-java-mat-puti-0-mv January 24, 2021 at 06:03AM
没有评论:
发表评论