java - Android Camera Preview - take only a part of the screen data -
i want take part of the screen data preview video callback reduce time of process. probleme know how take whole screen onpreviewframe:
@override public void onpreviewframe(byte[] data, camera camera) { mydata = data; // +get camera resolution x, y }
and data image :
private bitmap getbitmapfromyuv(byte[] data, int width, int height) { bytearrayoutputstream out = new bytearrayoutputstream(); yuvimage yuvimage = new yuvimage(data, imageformat.nv21, width, height, null); yuvimage.compresstojpeg(new rect(0, 0, width, height), 100, out); byte[] imagebytes = out.tobytearray(); bitmap image = bitmapfactory.decodebytearray(imagebytes, 0, imagebytes.length); return image; }
and take part of image taken want :
cutimage = bitmap.createbitmap(image, xoffset, yoffset, customwidth, customheight);
the problem need take lots of images apply image processing on , that's why want reduce time takes images. instead of taking whole screen , crop it, want immediatly cropped image. there way part of screen data ?
ok found something, still record data of camera when using compresstojpeg crop picture custom rect. maybe there better before still improvement. here changes :
yuvimage.compresstojpeg(new rect(offsetx, offsety, sizecapturex + offsetx, sizecapturey + offsety ), 100, out);
Comments
Post a Comment