ios - Detecting with KVO when Adjusting focus is done - not correct on iPhone 6+ -
i want take still image avcapturestillimageoutput
, when adjusting focus done, i'm using key-value observing so, when testing on iphone 6+ ios 10 method
- (void)observevalueforkeypath:(nsstring *)keypath ofobject:(id)object change:(nsdictionary *)change context:(void *)context { if( [keypath isequaltostring:@"adjustingfocus"] ) { bool adjustingfocus = [ [change objectforkey:nskeyvaluechangenewkey] isequaltonumber:[nsnumber numberwithint:1] ]; if (adjustingfocus) { nslog(@"adjusting focus started"); } else { nslog(@"adjustingfocus done"); } } }
some times gets called several times, first time detect focus done screen blurry , still image captured. i've noticed in case (blurry image) method called 2 more times (when starting , finishing adjust focus). there way detect focus not adjusted , wait next call or way called once?
i've found single focusing "event" yields sequence of start, stop, start, stop in rapid succession far kvo concerned. mitigate this, keep track of timestamp when hear "start" , if next "stop" event comes in before threshold of time has passed (i used 300ms), disregard "stop" event because i'm sure "start" come (which ignore because have "started"), , final "stop" comes after more 300ms after first "start" consider true end of focusing event.
Comments
Post a Comment