android - Camera2 api problems firing flash/no flash images -


i explain case. i'm trying application in every 5 seconds take image, 1 without flash, , after 5 seconds 1 flash, , repeat every time. take 1 without flash, 1 flash, 1 without flash, 1 flash... infinitely.

the case code can in devices, same code won't work in others want. i.e:

  • bq aquaris x5 plus : no-flash image correct, flash image white.
  • bq aquaris e5 : won't fire flash.

how can possible, devices in have tried legacy hardware support level camera2 api.

this important methods in code (i can't post code due char limit). started google example:

this setautoflash mentioned above.

private void setautoflash(capturerequest.builder requestbuilder) {         if (mflashsupported) {             if(phototaken) {                 requestbuilder.set(capturerequest.control_ae_mode,capturerequest.control_ae_mode_on_auto_flash);                 requestbuilder.set(capturerequest.flash_mode, capturerequest.flash_mode_off);             }else{                 requestbuilder.set(capturerequest.flash_mode, capturerequest.flash_mode_single);             }         }     } 

this other 1 works in devices , bq aquaris e5 doesn't fire flash in bq aquaris x5 plus.

private void setautoflash(capturerequest.builder requestbuilder) {         if (mflashsupported) {             if(phototaken) {                 requestbuilder.set(capturerequest.control_ae_mode,capturerequest.control_ae_mode_on_auto_flash);                 requestbuilder.set(capturerequest.flash_mode, capturerequest.flash_mode_off);             }else{                 requestbuilder.set(capturerequest.control_ae_mode,capturerequest.control_ae_mode_on_always_flash);                 requestbuilder.set(capturerequest.flash_mode, capturerequest.flash_mode_off);             }         }     } 

and capturestillpicture

private void capturestillpicture() {         try {             final activity activity = getactivity();             if (null == activity || null == mcameradevice) {                 return;             }             // capturerequest.builder use take picture.             final capturerequest.builder capturebuilder = mcameradevice.createcapturerequest(cameradevice.template_still_capture);             capturebuilder.addtarget(mimagereader.getsurface());              // use same ae , af modes preview.             capturebuilder.set(capturerequest.control_af_mode,                     capturerequest.control_af_mode_continuous_picture);             setautoflash(capturebuilder);              // orientation             int rotation = activity.getwindowmanager().getdefaultdisplay().getrotation();             capturebuilder.set(capturerequest.jpeg_orientation, getorientation(rotation));              cameracapturesession.capturecallback capturecallback                     = new cameracapturesession.capturecallback() {                 @override                 public void oncapturecompleted(@nonnull cameracapturesession session,                                                @nonnull capturerequest request,                                                @nonnull totalcaptureresult result) {                     showtoast("saved: " + mfile);                     log.d(tag, mfile.tostring());                     unlockfocus();                 }             };              mcapturesession.stoprepeating();             mcapturesession.capture(capturebuilder.build(), capturecallback, null);             phototaken = !phototaken;          } catch (cameraaccessexception e) {             e.printstacktrace();         } } 

the question is, doing wrong doesn't work in devices? great.

there 2 levels of control flash - manual, , controlled auto-exposure routine. you're mixing them together.

if want fire flash manually, need set ae_mode either ae_mode_off or ae_mode_on; not of flash modes. then, flash_mode control whether flash in torch mode, off, or fire once given request.

since you're leave ae_mode in 1 of flash states, flash_mode should not matter, barring bug in specific device.

if want guarantee flash firing in every other picture, need use ae_mode_on_always_flash force-flash photos, , need use ae_mode_on no-flash phoots; don't touch flash_mode. right now, auto_flash, it's device whether fire flash or not, you'll see different behavior different devices , lighting conditions - fire, won't.

the other key thing you're not doing running precapture sequence; essential flash pictures, because allows device fire preflash determine correct flash power, focus, , white balance.

to run precapture, set ae_mode desired, , set ae_precapture_trigger start 1 request. transition ae_state precapture, , it'll stay there number of frames; once ae_state no longer precapture, can issue actual image capture request. make sure keep ae_mode consistent throughout this.

the sample app camera2basic implements precapture sequence, take there; has optimizations skip precapture in case scene not dark enough need flash, since want force-fire flash, that's not relevant you.


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -