standard local deviation in android
hi, i have implented local standard deviation in android and i got this error.
10-30 21:23:27.999: E/cv::error()(8900): OpenCV Error: Assertion failed (src.dims == 2 && info.height == (uint32_t)src.rows && info.width == (uint32_t)src.cols) in void Java_org_opencv_android_Utils_nMatToBitmap2(JNIEnv, jclass, jlong, jobject, jboolean), file /home/reports/ci/slave_desktop/50-SDK/opencv/modules/java/generator/src/cpp/utils.cpp, line 97 10-30 21:23:28.009: E/org.opencv.android.Utils(8900): nMatToBitmap catched cv::Exception: /home/reports/ci/slave_desktop/50-SDK/opencv/modules/java/generator/src/cpp/utils.cpp:97: error: (-215) src.dims == 2 && info.height == (uint32_t)src.rows && info.width == (uint32_t)src.cols in function void Java_org_opencv_android_Utils_nMatToBitmap2(JNIEnv, jclass, jlong, jobject, jboolean) 10-30 21:23:28.009: W/dalvikvm(8900): threadid=1: thread exiting with uncaught exception (group=0x41bb3798) 10-30 21:23:28.009: E/AndroidRuntime(8900): FATAL EXCEPTION: main 10-30 21:23:28.009: E/AndroidRuntime(8900): CvException [org.opencv.core.CvException: /home/reports/ci/slave_desktop/50-SDK/opencv/modules/java/generator/src/cpp/utils.cpp:97: error: (-215) src.dims == 2 && info.height == (uint32_t)src.rows && info.width == (uint32_t)src.cols in function void Java_org_opencv_android_Utils_nMatToBitmap2(JNIEnv*, jclass, jlong, jobject, jboolean)
and here is the code:-
Imgproc.cvtColor(rgb, gry, Imgproc.COLOR_RGB2GRAY);
int rows = gry.rows(); int cols = gry.cols();
rows--; cols--;
Toast.makeText(getApplicationContext(),"rows =" + rows+cols,Toast.LENGTH_LONG).show();
Mat tmp = new Mat(rows+2, cols+2, gry.type());
Imgproc.copyMakeBorder(tmp, tmp, 1, 1, 1, 1, 1);
rows = tmp.rows();cols=tmp.cols();
rows = rows-1;cols = cols-1;
for(int i=2;i<rows-2;i++)
{
for(int j=2;j<cols-2;j++)
{
int sum1=0;
int sum2=0;
block = tmp.rowRange(i-2,i+3).colRange(j-2,j+3);
sum1 = (int) Core.sumElems(block).val[0];
sum2 = (int) Core.sumElems(block.mul(block)).val[0];
int mean = sum1/25;
int variance = -(mean*mean -(sum2/25));
int deviation = (int) Math.sqrt(variance);
tmp .put(i-2, j-2, deviation);
}
}
Bitmap scale = Bitmap.createBitmap(gry.cols(), gry.rows(), Bitmap.Config.ARGB_8888);
I am not able to get the output, i think there is some matrix related error.I hope you understand what I'm asking , Thanks for any suggestion . android opencv
I don't have the solution, but the key is here: "Error: Assertion failed (src.dims == 2 && info.height == (uint32_t)src.rows && info.width == (uint32_t)src.cols)"
That means that somewhere, you are doing something where the dimensions doesn't fit. I don't know which dev environment you are using, but when I have this kind of error I put breakpoints at multiple places, the cycle through the program manually to see at which line/instruction the program fails. Then, I analyze what are the variables, parameters, etc. involved and I they are of the correct format. This is not always easy but this is the way to go! Then you'll be able maybe to ask another question, more narrow, with the specific line or instruction at fault.