Reputation: 373
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!!
Upvotes: 0
Views: 6208
Reputation: 812
I got the same problem, and after some reading document, i found the solution. Your Mat read from bitmap wasn't have type 8UC1 or 8UC3, so you should convert it to 8UC3
Imgproc.cvtColor(originalMat,originalMat,Imgproc.COLOR_BGRA2BGR);
Now you can use bilateralFilter :)
Upvotes: 1