Bilateral filter error, Assertion failed ((src.type() == CV_8UC1 || src.type() == CV_8UC3) && src.da

0

Bilateral filter error, Assertion failed ((src.type() == CV_8UC1 || src.type() == CV_8UC3) && src.data != dst.data)

edit

asked Jun 12 '16

​编辑

BaKa
6 ●1 ●1 ●5

updated Jun 12 '16

​编辑

berak
32993 ●7 ●81 ●312

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!!

Comments

1

It's possible the Bitmap has a different number of channels. 4 is the most likely. Check for that.

​编辑Tetragramm (Jun 12 '16)edit

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

​编辑BaKa (Jun 12 '16)edit

1

Use the cvtColor function with COLOR_BGRA2BGR as the color code. See the documentation for more details.

​编辑Tetragramm (Jun 12 '16)edit

Thanks for you help, i can use it now!

​编辑BaKa (Jun 12 '16)edit

Bilateral filter error, Assertion failed ((src.type() == CV_8UC1 || src.type() == CV_8UC3) && src.data != dst.data) - OpenCV Q&A Forum

Bilateral filter error, Assertion failed ((src.type() == CV_8UC1 || src.type() == CV_8UC3) && src.data != dst.data) - OpenCV Q&A Forum

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值