Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to display a Mat in ImageView?

I'm going to display a mat object in ImageView in Android. I tried this code :

public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
    Mat mRgb = inputFrame.rgba();
    Mat mGray = inputFrame.gray();
    Bitmap img = Bitmap.createBitmap(mRgb.cols(), mRgb.rows(),Bitmap.Config.ARGB_8888);
    Utils.matToBitmap(mRgb, img);
    if( mGrayImageView != null )
       mGrayImageView.setImageBitmap(img);// <---- this is my ImageView 
    return inputFrame.rgba();

}

but nothing displayed in ImageView!