Ask Your Question
0

How to display a Mat in ImageView?

asked 2013-04-24 03:00:18 -0600

s4eed gravatar image

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!

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
1

answered 2013-04-24 03:17:07 -0600

If you want to display something, you should give the time to the view to call it's internal redaw functionality. I know OpenCV provides this by the waitKey(10) option for namedWindows. I am guessing that you could use something sortlike?

Looking at the java docs it seems this should be possible in Android programming also

namedWindow("H-S Histogram", 1);
imshow("H-S Histogram", histImg);
waitKey(10);
edit flag offensive delete link more
1

answered 2014-01-31 04:57:10 -0600

lukassos gravatar image

updated 2014-01-31 04:57:57 -0600

Try this topic it worked well for me "Display image?"

edit flag offensive delete link more

Comments

Indeed a nice solution and guide for this kind of problems!

StevenPuttemans gravatar imageStevenPuttemans ( 2014-01-31 08:25:40 -0600 )edit

Question Tools

Stats

Asked: 2013-04-24 03:00:18 -0600

Seen: 19,903 times

Last updated: Jan 31 '14