使用GaussianBlur和OpenCV for Android时,Eclipse会出错

前端之家收集整理的这篇文章主要介绍了使用GaussianBlur和OpenCV for Android时,Eclipse会出错前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我发布了我的代码的一小部分,因为我不断得到一个我似乎无法摆脱的奇怪错误.问题可以在这一行找到:Imgproc.GaussianBlur(mGray,mGray,new Size(5,5),2.2,2);
public Mat onCameraFrame(Mat inputFrame) {
    mGray = new Mat();
    Imgproc.cvtColor(mRgba,Imgproc.COLOR_RGBA2GRAY);    
    // doing a gaussian blur prevents getting a lot of false hits
    Imgproc.GaussianBlur(mGray,new Size (5,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;
}

我从Eclipse得到的错误是:

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

我正在使用tutorial3 Camera-control(OpenCV for Android版本2.4.4)的编辑版本,其输出显示为Canny的边缘检测.我需要GaussianBlur来摆脱一些较小的细节.有谁知道这行代码究竟出了什么问题?

解决方法

这段代码工作正常.只需根据需要重新排序参数.
Imgproc.GaussianBlur(mGray,new Size(15,15),50);

大小意味着您将其用作内核大小.内核大小也必须是奇数!图50示出了X方向上的内核标准偏差.

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

这里sigma通过50,所以sigmaX = sigmaY = 50

原文链接:https://www.f2er.com/android/314683.html

猜你在找的Android相关文章