Ask Your Question
0

How to display processed Mat format image for android

asked 2017-06-28 01:58:02 -0600

Bipin gravatar image

updated 2017-06-29 03:46:37 -0600

berak gravatar image

Is there any equivalent function to imshow() for android? Since imshow() is not working for android

imshow() is working for Linux only. I want to display image for android device. Does any imshow() equivalent function for andrid?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-06-29 03:42:22 -0600

berak gravatar image

updated 2017-06-29 03:43:09 -0600

no, you are not allowed to open a window on your own on android, so imshow() cannot work.

if you are using the webcam, use the onCameraFrame method, any Mat returned from there will be displayed on the main panel.

if you 're just reading images from somewhere, you can also use the native android ImageView , but then you have to convert your Mat to BufferedImage, like this:

public static BufferedImage bufferedImage(Mat m) {
    int type = BufferedImage.TYPE_BYTE_GRAY;
    if ( m.channels() > 1 ) {
        type = BufferedImage.TYPE_3BYTE_BGR;
    }
    BufferedImage image = new BufferedImage(m.cols(),m.rows(), type);
    m.get(0,0,((DataBufferByte)image.getRaster().getDataBuffer()).getData()); // get all the pixels
    return image;
}
edit flag offensive delete link more

Comments

how to pass my created mat value in this?

Ajay Gohel gravatar imageAjay Gohel ( 2017-12-04 07:30:19 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2017-06-28 01:58:02 -0600

Seen: 1,264 times

Last updated: Jun 29 '17