Eclipse gives error when using GaussianBlur with OpenCV for Android

[亡魂溺海] 提交于 2019-12-30 18:28:24

问题


I posted a little part of my code, cause i keep getting a strange error that I can't seem to get rid of. The problem can be found on this line: Imgproc.GaussianBlur(mGray, mGray, new Size (5,5), 2.2, 2);

public Mat onCameraFrame(Mat inputFrame) {
    mGray = new Mat();
    Imgproc.cvtColor(mRgba, mGray, Imgproc.COLOR_RGBA2GRAY);    
    // doing a gaussian blur prevents getting a lot of false hits
    Imgproc.GaussianBlur(mGray, mGray, new Size (5,5), 2.2, 2);
    // Values 3 and 4are the LowerThreshold and UpperThreshold.
    Imgproc.Canny(inputFrame, mIntermediateMat, 80, 100);
    Imgproc.cvtColor(mIntermediateMat,mRgba, Imgproc.COLOR_GRAY2BGRA, 4);
    return mIntermediateMat;
}

The error i get from Eclipse is:

The method GaussianBlur(Mat,Mat,Size,double,double) in 
the type imgproc is not applicable for the arguments (Mat,Mat,CameraSize,int,int)

I am using an edited version of tutorial3 Camera-control (OpenCV for Android version 2.4.4) where the output is shown as Canny's edge detection. I need the GaussianBlur to get rid of some of the smaller details. Does anyone know what exactly is wrong in this line of the code?


回答1:


This code works fine. Just reorder the parameters as you need.

Imgproc.GaussianBlur(mGray, mGray, new Size(15,15),50);

Size means that you will use it as kernel size. Also kernel size must be odd! 50 shows the kernel standard deviation in the X direction.

Formula : sigma = 0.3 * ((kSize-1)*0.5 - 1) + 0.8

Here sigma is passed 50 so sigmaX = sigmaY = 50




回答2:


I got this solution from Alexander Smorkalov, and it worked. Just change the Imgproc.GaussianBlur(mGray, mGray, new Size (5,5), 2.2, 2); to Imgproc.GaussianBlur(mGray, mGray, new org.opencv.core.Size (5,5), 2.2, 2);



来源:https://stackoverflow.com/questions/15208184/eclipse-gives-error-when-using-gaussianblur-with-opencv-for-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!