简体   繁体   中英

Issues with medianBlur in OpenCV on Android

I'm trying to use a medianBlur in my first OpenCV application on Android. It's a modification of "Image-manipulations" sample app. Everything runs perfectly except my implementation of medianBlur. While my application is working on a device, I choose the medianBlur option from the menu and then the whole app crashes. Here's the code of medianBlur implementation in my app:

 case ImageManipulationsActivity.VIEW_MODE_MEDIAN:
   capture.retrieve(mRgba, Highgui.CV_CAP_ANDROID_COLOR_FRAME_RGBA); 
    if (mRgbaInnerWindow == null || mGrayInnerWindow == null)
       CreateAuxiliaryMats();
 Imgproc.medianBlur(mGrayInnerWindow, mIntermediateMat, 2);
 Core.convertScaleAbs(mIntermediateMat, mIntermediateMat, 10, 0);
 Imgproc.cvtColor(mIntermediateMat, mGrayInnerWindow, Imgproc.COLOR_GRAY2BGRA, 4);
 break;

Can you tell me what is wrong with the code? Other lines of code connected with the medianBlur implementation should be correct, because they're written in the same way as other features of the app like Canny filter. Can you provide me a sample code how to use medianBlur filter in OpenCV for Android? I'm new to OpenCV and Android programming, so please forgive me any mistakes I have made

  1. Catch exceptions.
  2. Read the documentation to know valid values for method arguments. Documentation explicitly says that aperture size must be odd and greater than 1, but you set it to 2.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM