Android screenshot using Opencv [closed]
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) {
}
}
}
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.)
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)
simply: NO. (on any os, including phones, you need OS services for this, and opencv does not handle this)