openxc / android-webcam

Android library to access a USB webcam feed

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Black rectangle instead of photo

Tsyshnatiy-zz opened this issue · comments

Hi, guys

I'm trying to use this lib for saving frames into memory.
I've changed only run method of WebcamPreview class

Bitmap bitmap = mWebcamManager.getFrame();
Canvas canvas = mHolder.lockCanvas();
if(canvas != null) {
drawOnCanvas(canvas, bitmap);
mHolder.unlockCanvasAndPost(canvas);
}
FileOutputStream out = null;
try {
out = new FileOutputStream("/storage/sdcard0/DCIM/1.png");
bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (out != null) {
out.close();
}
} catch (IOException e) {
e.printStackTrace();
}

}

Also I've removed the cycle, so I get only one frame and save it.
All other things are unchanged.
I've set user to media for webcam (it is on video2, not on video0) and group camera(It was root).
crw------- media camera 81, 2 2015-02-19 22:39 video2

But I have only black rectangle 640*480 instead of the saved frame.
Maybe I've missed something?

Oh, forget to say - I'm trying to run example for android-webcam library.
Working on android-studio.
I suspect video frames should appear on custom view in the example, but I see nothing.