Android screenshot using Opencv [closed]

asked 2016-08-30 22:48:54 -0600

Shulz gravatar image

How do I make a screenshot using Opencv (android) and convert it to an Image. I myself have made a code for screenshot see link here. The output of this image is black which is not I wanted. Is there also a possibility of using a mat here?

public void camera_b(View v)
{
    String path = Environment.getExternalStorageDirectory().toString() + "/" + "hellp.jpg";

    v = getWindow().getDecorView().getRootView();
    v.setDrawingCacheEnabled(true);
    Bitmap bitmap = Bitmap.createBitmap(v.getDrawingCache());
    v.setDrawingCacheEnabled(false);

    OutputStream out = null;
    File imageFile = new File(path);

    try {
        out = new FileOutputStream(imageFile);
        // choose JPEG format
        bitmap.compress(Bitmap.CompressFormat.JPEG, 90, out);
        out.flush();
    } catch (FileNotFoundException e) {
        // manage exception
    } catch (IOException e) {
        // manage exception
    } finally {

        try {
            if (out != null) {
                out.close();
            }

        } catch (Exception exc) {
        }

    }
}
edit retag flag offensive reopen merge delete

Closed for the following reason question is off-topic or not relevant by berak
close date 2016-08-31 01:30:39.694382

Comments

unfortunately, this is all unrelated to opencv.

(you 'll have to use plain android api methods to achieve this, and asking about that is beyond the scope of this site.)

berak gravatar imageberak ( 2016-08-31 00:53:37 -0600 )edit

My simplest question is that, is there a possibility of taking a screenshot of the phone using opencv? (the code there is plain android api but does not display the exact image)

Shulz gravatar imageShulz ( 2016-08-31 06:39:50 -0600 )edit

simply: NO. (on any os, including phones, you need OS services for this, and opencv does not handle this)

berak gravatar imageberak ( 2016-08-31 06:45:26 -0600 )edit