Bilateral filter error, Assertion failed ((src.type() == CV_8UC1 || src.type() == CV_8UC3) && src.data != dst.data)
My code is shown in the following:
Bitmap b = BitmapFactory.decodeResource(getResources(), R.drawable.image1);
int width = b.getWidth();
int height = b.getHeight();
Mat tmp = new Mat (width, height, CvType.CV_8UC3);
Mat tmp2 = tmp.clone();
Utils.bitmapToMat(b, tmp);
Imgproc.bilateralFilter(tmp,tmp2,10,50,10);
and give the following error,
OpenCV Error: Assertion failed ((src.type() == CV_8UC1 || src.type() == CV_8UC3) && src.data != dst.data) in void cv::bilateralFilter_8u(const cv::Mat&, cv::Mat&, int, double, double, int), file /Volumes/Linux/builds/master_pack-android/opencv/modules/imgproc/src/smooth.cpp, line 3145
May i ask what's wrong with my code, Thanks a lot!!
It's possible the Bitmap has a different number of channels. 4 is the most likely. Check for that.
i have checked the channel of the src, it has 4 channels, but now i am confused about how to change the number of channels of the src btw thanks for your comment
Use the cvtColor function with COLOR_BGRA2BGR as the color code. See the documentation for more details.
Thanks for you help, i can use it now!