Trying to get max fps from Android Camera -
Trying to get max fps from Android Camera -
i'm developing android application, , need max of fps camera.
i've been trying implement setpreviewcallbackwithbuffer can't work.
can give me illustration or explanation?
i've set timer, runs every 10 milliseconds , there run takepicture().is correct, or way max fps ?
i searched everywhere can't find explanation works me.
thank you.
edit 2:
startrecording.setonclicklistener( new view.onclicklistener() { public void onclick(view v) { if(!recording) { recording = true; thread.start(); cam.startpreview(); size previewsize=cam.getparameters().getpreviewsize(); int databuffersize=(int)(previewsize.height*previewsize.width*(imageformat.getbitsperpixel(cam.getparameters().getpreviewformat())/8.0)); cam.addcallbackbuffer(new byte[databuffersize]); cam.addcallbackbuffer(new byte[databuffersize]); cam.addcallbackbuffer(new byte[databuffersize]); cam.setpreviewcallbackwithbuffer(new previewcallback() { public void onpreviewframe(byte[] imagedata, photographic camera arg1) { seek { photos.add(imagedata); } catch(exception e) { system.out.println("error!"); } } }); } (...)
thank you!
problem #1: timer
quoting the documentation setpreviewcallbackwithbuffer()
:
installs callback invoked every preview frame, using buffers supplied addcallbackbuffer(byte[]), in add-on displaying them on screen. callback repeatedly called long preview active , buffers available. other preview callbacks overridden.
so, delete timer
. phone call setpreviewcallbackwithbuffer()
once, , called preview frames, ready processing.
quoting the documentation addcallbackbuffer()
:
for formats besides yv12, size of buffer determined multiplying preview image width, height, , bytes per pixel. width , height can read getpreviewsize(). bytes per pixel can computed getbitsperpixel(int) / 8, using image format getpreviewformat().
if using yv12 format, size can calculated using equations listed in setpreviewformat(int).
please follow instructions, rather guessing @ buffer size.
problem #3: adding buffersfurther quoting the documentation addcallbackbuffer()
:
adds pre-allocated buffer preview callback buffer queue. applications can add together 1 or more buffers queue. when preview frame arrives , there still @ to the lowest degree 1 available buffer, buffer used , removed queue. preview callback invoked buffer. if frame arrives , there no buffer left, frame discarded. applications should add together buffers when finish processing info in them.
call addcallbackbuffer()
few buffers front, when phone call setpreviewcallbackwithbuffer()
. in onpreviewframe()
, arrange background thread process frame's buffer. when work done, add together same buffer pool calling addcallbackbuffer()
. not maintain allocating new buffers.
android camera buffer fps
Comments
Post a Comment