Hi everyone,
I managed until now with help of the forum to install openCV with extra modules and to get a model for the StructuredEdgeDetection and to implement it correctly to android. My problem now is with method detectEdges which gives an error every time I try to execute it. Here is my code :
//bitmap to detect it's edges
Mat rgba = new Mat();
Utils.bitmapToMat(bitmap, rgba);
//same bitmap to to greyscale it
Mat grey = new Mat();
Utils.bitmapToMat(bitmap, grey);
StructuredEdgeDetection pDollar = createStructuredEdgeDetection(DATA_PATH + "SEDmodel" + ".yml");
//convert the source Mat object to float
Mat src = new Mat();
rgba.convertTo(src, CvType.CV_32FC3, 1.0 / 255.0);
//convert the destination Mat to float
Mat edges = new Mat(grey.size(), CvType.CV_8UC1);
Imgproc.cvtColor(grey, edges, Imgproc.COLOR_RGB2GRAY, 4);
grey.convertTo(edges, CvType.CV_32FC3, 1.0 / 255.0);
//try to detect the edges
pDollar.detectEdges(src, edges);
//convert the edges to Mat
Mat output = new Mat();
edges.convertTo(output, CvType.CV_8UC1, 255.0);
//convert Mat to bitmap to display it
Bitmap resultBitmap = Bitmap.createBitmap(edges.cols(), edges.rows(), Bitmap.Config.ARGB_8888);
Utils.matToBitmap(edges, resultBitmap);
return resultBitmap;
The error that I'm getting :
Caused by: CvException [org.opencv.core.CvException: cv::Exception: OpenCV(3.4.0-dev) /Users/Chao/opencv_contrib/modules/ximgproc/src/structured_edge_detection.cpp:529: error: (-215) _src.type() == (((5) & ((1 << 3) - 1)) + (((3)-1) << 3)) in function virtual void cv::ximgproc::StructuredEdgeDetectionImpl::detectEdges(cv::InputArray, cv::OutputArray) const
I checked the line 529 in structured_edge_detection.cpp (link) as shown in the error and I saw this :
* The function detects edges in src and draw them to dst
*
* \param _src : source image (RGB, float, in [0;1]) to detect edges
* \param _dst : destination image (grayscale, float, in [0;1])
* where edges are drawn
And to my understanding that's what I did in the code snippet above. Any help is much appreciated.