Ask Your Question
1

Displaying processed image on screen

asked 2016-03-08 01:32:08 -0500

VPallavi gravatar image

Hello all!!

I'm working on an Android project with OpenCV library on Eclipse Platform. In this project I'm stuck at a point where I need to display the Mat image on the screen after it has been processed.

Overview: 1. Browsing an image from the phone. 2. Performing certain processing on it. 3. Saving the result image file in the same folder.

Now, after the first 2 processes I want to display the result image on the screen. I'm able to save it in the same folder but unable to display.

Please help me!!

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2016-03-08 02:35:05 -0500

berak gravatar image

you can convert it to a Bitmap, and draw it to an ImageView:

public void helloworld() {
        // make a mat and draw something
        Mat m = Mat.zeros(100,400, CvType.CV_8UC3);
        Core.putText(m, "hi there ;)", new Point(30,80), 
                Core.FONT_HERSHEY_SCRIPT_SIMPLEX, 2.2, new Scalar(200,200,0),2);

        // convert to bitmap:
        Bitmap bm = Bitmap.createBitmap(m.cols(), m.rows(),Bitmap.Config.ARGB_8888);
        Utils.matToBitmap(m, bm);

        // find the imageview and draw it!
        ImageView iv = (ImageView) findViewById(R.id.imageView1);
        iv.setImageBitmap(bm);
}
edit flag offensive delete link more

Comments

@berak: Sorry for replying too late.. In this image should already be stored in some folder like drawable. But in my case image is stored in sdcard (which is just being processed). So how to display that??

VPallavi gravatar imageVPallavi ( 2016-03-16 00:37:54 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2016-03-08 01:32:08 -0500

Seen: 108 times

Last updated: Mar 08 '16