convert Bitmap to Mat after capture image using android camera

Utils.bitmapToMat converts an Android Bitmap to an OpenCV Mat. It requires a bitmap of type ARGB_8888 or RGB_565.

import org.opencv.android.Utils;

Mat mat = new Mat();    
Bitmap bmp32 = bmp.copy(Bitmap.Config.ARGB_8888, true);
Utils.bitmapToMat(bmp32, mat);

Mat tmp = new Mat (bmp.getWidth(), bmp.getHeight(), CvType.CV_8UC1);

OpenCV Mat constructor expects rows, cols pair instead of width, height as its arguments, invert them.

Try:

Mat tmp = new Mat (bmp.getHeight(), bmp.getWidth(), CvType.CV_8UC1);