Conversion between javacv and opencv to get mean and stdDev from a Mat
i can successfully access the value of mean and stdDev using opencv in eclipse. But i am fail to do so with javacv in Android. There are two main problems. First, no MatODouble is supported in javacv. Second, no "get" function can be called. Anyone here know how to translate these code for javacv.
Please give me a helping hand, i need you all indeed......
MatOfDouble mu = new MatOfDouble(); MatOfDouble sigma = new MatOfDouble(); Core.meanStdDev( detected_edges, mu, sigma); double m = mu.get(0,0); double d = sigma.get(0,0);
The following example may helps: ColorCalibrator.java
CvMat b = CvMat.create(referenceColors.length*3, 1); ... CvScalar mean = new CvScalar(), stddev = new CvScalar(); cvAvgSdv(b, mean, stddev, null);
After that mean and stddev can be used as a 4-element vector (i.e. stddev.val(0)).
Update #1 on how to create CvMat from BufferedImage:
// To get a BufferedImage from an IplImage, or vice versa, we can chain calls to // Java2DFrameConverter and OpenCVFrameConverter, one after the other. Java2DFrameConverter cvt1 = new Java2DFrameConverter(); OpenCVFrameConverter.ToIplImage cvt2 = new OpenCVFrameConverter.ToIplImage(); BufferedImage img = ImageIO.read(new File(imagePath)); IplImage image1 = cvt2.convert(cvt1.convert(img)); CvMat image2 = image1.asCvMat();