camera - autofocus in android jellybean -
i working on little android image processing project.
earlier testing code on samsung galaxy ace , code fine.
now have got new phone samsung galaxy grand has 8 megapixel photographic camera , android jellybean.
the image quality has reduced much. seems photographic camera isn't autofoccsing.
i tried many tutorials on auto focus image quality remains same
screenshot: http://wikisend.com/download/527870/device-2013-02-12-181021.png
public class tracklaser extends activity { private preview mpreview; private drawontop mdrawontop; public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); super.oncreate(savedinstancestate); // hide window title. getwindow().setflags(windowmanager.layoutparams.flag_fullscreen, windowmanager.layoutparams.flag_fullscreen); requestwindowfeature(window.feature_no_title); // create our preview view , set content of our activity. // create our drawontop view. mdrawontop = new drawontop(this); mpreview = new preview(this, mdrawontop); setcontentview(mpreview); addcontentview(mdrawontop, new layoutparams(layoutparams.wrap_content, layoutparams.wrap_content)); } } @suppresslint("drawallocation") class drawontop extends view { bitmap mbitmap; paint mpaintblack; paint mpaintyellow; paint mpaintred; paint mpaintwhite; paint mpaintgreen; paint mpaintblue; byte[] myuvdata; int[] mrgbdata; int x,y; int mimagewidth, mimageheight; public drawontop(context context) { super(context); mbitmap = null; myuvdata = null; mrgbdata = null; } @override protected void ondraw(canvas canvas) { // } // end ondraw method static public void decodeyuv420sp(int[] rgb, byte[] yuv420sp, int width, int height) { // } // ---------------------------------------------------------------------- class preview extends surfaceview implements surfaceholder.callback { surfaceholder mholder; photographic camera mcamera; drawontop mdrawontop; boolean mfinished; preview(context context, drawontop drawontop) { super(context); mdrawontop = drawontop; mfinished = false; // install surfaceholder.callback notified when // underlying surface created , destroyed. mholder = getholder(); mholder.addcallback(this); } public void surfacecreated(surfaceholder holder) { mcamera = camera.open(); seek { mcamera.setpreviewdisplay(holder); mcamera.autofocus(myautofocuscallback); // preview callback used whenever new viewfinder frame available mcamera.setpreviewcallback(new previewcallback() { public void onpreviewframe(byte[] data, photographic camera camera) { if ( (mdrawontop == null) || mfinished ) return; if (mdrawontop.mbitmap == null) { // initialize draw-on-top companion camera.parameters params = camera.getparameters(); mdrawontop.mimagewidth = params.getpreviewsize().width; mdrawontop.mimageheight = params.getpreviewsize().height; mdrawontop.mbitmap = bitmap.createbitmap(mdrawontop.mimagewidth, mdrawontop.mimageheight, bitmap.config.rgb_565); mdrawontop.mrgbdata = new int[mdrawontop.mimagewidth * mdrawontop.mimageheight]; mdrawontop.myuvdata = new byte[data.length]; } // pass yuv info draw-on-top companion system.arraycopy(data, 0, mdrawontop.myuvdata, 0, data.length); mdrawontop.invalidate(); } }); } grab (ioexception exception) { mcamera.release(); mcamera = null; } } public void surfacedestroyed(surfaceholder holder) { // surface destroyed when return, stop preview. // because cameradevice object not shared resource, it's // of import release when activity paused. mfinished = true; mcamera.setpreviewcallback(null); mcamera.stoppreview(); mcamera.release(); mcamera = null; } public void surfacechanged(surfaceholder holder, int format, int w, int h) { camera.parameters parameters = mcamera.getparameters(); parameters.setfocusmode(camera.parameters.focus_mode_auto); mcamera.setparameters(parameters); mcamera.startpreview(); mcamera.autofocus(myautofocuscallback); } autofocuscallback myautofocuscallback = new autofocuscallback(){ public void onautofocus(boolean arg0, photographic camera arg1) { log.w("myapp", "autofocussed"); }}; }
android camera autofocus
No comments:
Post a Comment