Android canny edge detection opencv error Assertion failed

asked 2020-05-17 06:52:51 -0500

updated 2020-05-20 06:38:06 -0500

supra56 gravatar image

I would make edge detection of the image in Android with openv. But I got this error :

E/cv::error()( 2698): OpenCV Error: Assertion failed (_dx.type() == (((3) & ((1 << 3) - 1)) + (((1)-1) << 3)) || _dx.type() == (((3) & ((1 << 3) - 1)) + (((3)-1) << 3))) in void cv::Canny(cv::InputArray, cv::InputArray, cv::OutputArray, double, double, bool), file /build/master_pack-android/opencv/modules/imgproc/src/canny.cpp, line 1039

E/org.opencv.imgproc( 2698): imgproc::Canny_11() caught cv::Exception: /build/master_pack-android/opencv/modules/imgproc/src/canny.cpp:1039: error: (-215) _dx.type() == (((3) & ((1 << 3) - 1)) + (((1)-1) << 3)) || _dx.type() == (((3) & ((1 << 3) - 1)) + (((3)-1) << 3)) in function void cv::Canny(cv::InputArray, cv::InputArray, cv::OutputArray, double, double, bool)

My Codes :

Mat rgba = new Mat(); Utils.bitmapToMat(bitmap, rgba);
Mat edges = new Mat(rgba.size(), CvType.CV_8UC1);
cvtColor(rgba, edges, Imgproc.COLOR_BGR2GRAY, 4);
Canny(rgba, edges, 80, 90);
BitmapHelper.showBitmap(this, bitmap, imageView);
Bitmap resultBitmap = Bitmap.createBitmap(edges.cols(), edges.rows(), Bitmap.Config.ARGB_8888);
Utils.matToBitmap(edges, resultBitmap); 
BitmapHelper.showBitmap(this, resultBitmap, detectEdgesImageView);

How I can resolve this problem?

I need your help.

edit retag flag offensive close merge delete

Comments

1

you probably wanted to do Canny on the grayscale image (which goes unused in your code) , not the rgba image

berak gravatar imageberak ( 2020-05-20 06:47:09 -0500 )edit

@berak yes I would make this.

MehmetYanmaz gravatar imageMehmetYanmaz ( 2020-05-22 13:41:17 -0500 )edit

so, now, where are we here ?

berak gravatar imageberak ( 2020-05-22 13:49:13 -0500 )edit

@berak I would make a edge detection app. I founded this code but the cide doesn't work. I doesnt had a good English. I hope you can understand.

MehmetYanmaz gravatar imageMehmetYanmaz ( 2020-05-22 15:13:34 -0500 )edit