Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

no, you are not allowed to open a window on your own on android.

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;
}

no, you are not allowed to open a window on your own on android. 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;
}