I have a problem with GaborFilter in Android. I try to implement this filter because CannyFilter is too weak for my purposes. I want to use it to get edges with great accuracy from the image provided by the user but when I call this method I get problems with src.type. Does my image is in wrong format?
GaborFilter implementation:
private Bitmap gaborFilter(Bitmap bitmap){
Mat tmp = new Mat();
Utils.bitmapToMat(bitmap, tmp);
Mat edges = new Mat(tmp.size(), CvType.CV_32F);
//tmp.convertTo(tmp, CvType.CV_8U);
//Imgproc.cvtColor(tmp, edges, Imgproc.COLOR_RGB2GRAY, 4);
double sigma = 15, theta = 4.71, lambda = 50, gamma = 0.6;
Mat kernel = Imgproc.getGaborKernel(new Size(3,3),sigma,theta,lambda,gamma);
Imgproc.filter2D(tmp, edges, CvType.CV_32F, kernel);
Bitmap resultBitmap = Bitmap.createBitmap(tmp.cols(), tmp.rows(), Bitmap.Config.ARGB_8888);
Utils.matToBitmap(dst, resultBitmap);
return resultBitmap;
}
Error that I received:
java.lang.RuntimeException: Failure
delivering result ResultInfo{who=null,
request=11, result=-1, data=Intent {
dat=content://com.android.providers.media.documents/document/image:42
flg=0x1 }} to activity
{com.example.janekxyz.teest/com.example.janekxyz.teest.MainActivity}:
CvException
[org.opencv.core.CvException:
/build/master_pack-android/opencv/modules/java/generator/src/cpp/utils.cpp:98:
error: (-215) src.type() == CV_8UC1 ||
src.type() == CV_8UC3 || src.type() ==
CV_8UC4 in function void
Java_org_opencv_android_Utils_nMatToBitmap2(JNIEnv*,
jclass, jlong, jobject, jboolean)]
Any thoughts how can I make this code run?
P.S.
I'm new to OpenCV.