Java: Core.Pow: (-215:Assertion failed) depth == CV_32F || depth == CV_64F
Hello,
I use an astronomy software that is call firecapture and you can add you own plug-in to the software.
To help, to learn and because plugin has to be in java, I try to add the BRISQUE quality image evaluation. https://www.learnopencv.com/image-qua...
I am stuck at the begining with an error:
Exception in thread "main" CvException [org.opencv.core.CvException: cv::Exception: OpenCV(4.2.0) C:\build\master_winpack-bindings-win64-vc14-static\opencv\modules\core\src\mathfuncs.cpp:1242: error: (-215:Assertion failed) depth == CV_32F || depth == CV_64F in function 'cv::pow'
/* premier essai de open CV et java*/
package HelloCv;
import org.opencv.core.Core;
import org.opencv.core.CvType;
import org.opencv.core.Mat;
import org.opencv.core.Size;
import org.opencv.imgcodecs.Imgcodecs;
import org.opencv.imgproc.Imgproc;
/**importation des classes**/
public class HelloCv {
public static void main(String[] args){
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
String location = "resources/Poli.jpg";
System.out.print("Convert the image at " + location + " in gray scale... ");
Mat image = Imgcodecs.imread(location);
Imgproc.cvtColor(image, image, Imgproc.COLOR_BGR2GRAY);
Imgcodecs.imwrite("resources/Poli-gray.jpg", image);
//nouvel objet de type mat
Mat mu = new Mat(image.size(),CvType.CV_64F);
//application d'un filtre gaussien et enregistrement dans l'objet mu
Imgproc.GaussianBlur(image, mu, new Size(7, 7), 1.166);
//mu square
Mat mu_sq = new Mat(image.size(),CvType.CV_64F);
mu_sq = mu.mul(mu);
// mu sigma
Mat sigma = new Mat(image.size(), CvType.CV_64F);
Mat sigma2 = new Mat(image.size(), CvType.CV_32F);
sigma = image.mul(image);
//gaussian blur
Imgproc.GaussianBlur(sigma, sigma, new Size(7, 7), 1.166);
Imgcodecs.imwrite("resources/Poli-gray2.jpg", sigma );
Core.subtract(sigma,mu_sq,sigma);
Core.sqrt(sigma, sigma2);
}
}
I have tried to put everything in CV_32F but the same error, I have tried with core.pow but the same issue...
Could you help me?
Thanks
You should figure out where it happens (pow is not called directly in your code) and check the type of Mats there.
problem is most likely here:
(image is still CV_8U)