High speed Capture request Android Marshmallow -
i'm having issues setting capture request high speed video. intend capture @ 120 fps on nexus 6p. set minimum api 23, since don't plan deploy app other phone.
where i'm not quite understanding how capture request work. right now, i'm doing best change code within camera2video sample in google's samples. link sample google
here of relevant code:
private void startpreview() { if (null == mcameradevice || !mtextureview.isavailable() || null == mpreviewsize) { return; } try { setupmediarecorder(); surfacetexture texture = mtextureview.getsurfacetexture(); assert texture != null; texture.setdefaultbuffersize(mpreviewsize.getwidth(), mpreviewsize.getheight()); mpreviewbuilder = mcameradevice.createcapturerequest(cameradevice.template_record); list<surface> surfaces = new arraylist<surface>(); surface previewsurface = new surface(texture); surfaces.add(previewsurface); mpreviewbuilder.addtarget(previewsurface); surface recordersurface = mmediarecorder.getsurface(); surfaces.add(recordersurface); mpreviewbuilder.addtarget(recordersurface); mcameradevice.createconstrainedhighspeedcapturesession(surfaces, new cameracapturesession.statecallback() { //mcameradevice.createcapturesession(surfaces, new cameracapturesession.statecallback() { @override public void onconfigured(cameracapturesession cameracapturesession) { //mpreviewsession = cameracapturesession; mpreviewsession2 = cameracapturesession; updatepreview(); } @override public void onconfigurefailed(cameracapturesession cameracapturesession) { activity activity = getactivity(); if (null != activity) { toast.maketext(activity, "failed", toast.length_short).show(); } } }, mbackgroundhandler); } catch (cameraaccessexception e) { e.printstacktrace(); } catch (illegalargumentexception e) { e.printstacktrace(); } catch (ioexception e) { e.printstacktrace(); } } /** * update camera preview. {@link #startpreview()} needs called in advance. */ private void updatepreview() { if (null == mcameradevice) { return; } try { setupcapturerequestbuilder(mpreviewbuilder); handlerthread thread = new handlerthread("camerapreview"); thread.start(); mpreviewbuilder2 = mpreviewsession2.createhighspeedrequestlist(mpreviewbuilder.build()); //mpreviewbuilder2 = //mpreviewsession.setrepeatingrequest(mpreviewbuilder.build(), null, mbackgroundhandler); mpreviewsession.setrepeatingburst(mpreviewbuilder2, null, mbackgroundhandler); } catch (cameraaccessexception e) { e.printstacktrace(); } catch (illegalargumentexception e) { e.printstacktrace(); } catch(exception e){ e.printstacktrace(); } } private void setupcapturerequestbuilder(capturerequest.builder builder) { builder.set(capturerequest.control_mode, camerametadata.control_mode_auto); range<integer> fpsrange = range.create(120, 120); builder.set(capturerequest.control_ae_target_fps_range, fpsrange); } i have no problem getting code updatepreview. unfortunately, there i've hit roadblock on how give setrepeatingburst capture requests. know constructor different sample's setrepeatingrequest. therefore, need find way give setrepeatingburst surfaces, control_mode request , target_fps_range request.
/** * camera preview. */ private capturerequest.builder mpreviewbuilder; list<capturerequest> mpreviewbuilder2; /** * reference current {@link android.hardware.camera2.cameracapturesession} * preview. */ private cameracapturesession mpreviewsession; private cameraconstrainedhighspeedcapturesession mpreviewsession2; any figuring out how make work correctly helpful. haven't found on net in order , there isn't article in stackoverflow mentioning of highspeed capture functions. largest issue here trying understand how createconstrainedhighspeedcapturesession gives cameraconstrainedhighspeedcapturesession session. can use createhighspeedrequestlist.
i had similar problem, solved using question.
in case think should work if call
mpreviewsession2.setrepeatingburst(mpreviewbuilder2, null, mbackgroundhandler); instead of
mpreviewsession.setrepeatingburst(mpreviewbuilder2, null, mbackgroundhandler); since setting repeatingburst on cameraconstrainedhighspeedcapturesession
i made github repository showing how create highspeed recording session using camera2 api.
https://github.com/thesleort/android-slow-motion-camera2.git
Comments
Post a Comment