opencv - Setting iPhone lens position for focus -


this out there having trouble getting consistent calibration parameters on iphones. old trick focus phone infinity can sure obtained consistent camera matrix without recalibrating.

so question how come there isn't method allows manually set focus plebs attempting computer vision applications.

/*!  @method setfocusmodelockedwithlensposition:completionhandler:  @abstract     sets focusmode avcapturefocusmodelocked , locks lensposition @ explicit value.   @param lensposition     lens position, described in documentation lensposition property. value of avcapturelenspositioncurrent can used     indicate caller not wish specify value lensposition.  @param handler     block called when lensposition has been set value specified , focusmode set avcapturefocusmodelocked. if     setfocusmodelockedwithlensposition:completionhandler: called multiple times, completion handlers called in fifo order.      block receives timestamp matches of first buffer settings have been applied. note timestamp      synchronized device clock, , must converted master clock prior comparison timestamps of buffers      delivered via avcapturevideodataoutput. client may pass nil handler parameter if knowledge of operation's completion      not required.   @discussion     way of setting lensposition.     method throws nsrangeexception if lensposition set unsupported level.     method throws nsgenericexception if called without first obtaining exclusive access receiver using lockforconfiguration:. */ - (void)setfocusmodelockedwithlensposition:(float)lensposition completionhandler:(void (^)(cmtime synctime))handler ns_available_ios(8_0); 

here is

a method provided apple api in ios8 let manually set focus lens position.

some quick starter code

-(ibaction)focusandlock:(id)sender {     if (self.isfocuslocked)     {          nslog(@"unlock lens");         [[[self videodeviceinput] device] setexposuremode:avcaptureexposuremodeautoexpose];         [[[self videodeviceinput] device] setfocusmode:avcapturefocusmodeautofocus];         [self.focusandlock settitle:@"set focus lock" forstate:uicontrolstatenormal];         [self.focusandlock settitlecolor:[uicolor bluecolor] forstate:uicontrolstatenormal];         self.isfocuslocked = no;     }     else     {         nslog(@"lock lens");         nserror *error;         if ([[[self videodeviceinput] device] lockforconfiguration:&error])         {             [[[self videodeviceinput] device] setfocusmodelockedwithlensposition:[[self videodeviceinput] device].lensposition completionhandler:nil];             [[[self videodeviceinput] device] setexposuremode:avcaptureexposuremodelocked];             [[[self videodeviceinput] device] setfocusmode:avcapturefocusmodelocked];             [self.focusandlock settitle:[nsstring stringwithformat:@"focus locked: %f",[[self videodeviceinput] device].lensposition] forstate:uicontrolstatenormal];             [self.focusandlock settitlecolor:[uicolor greencolor] forstate:uicontrolstatenormal];             self.isfocuslocked = yes;             nsarray *paths = nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes);             nsstring *documentsdirectory = [paths objectatindex:0];             nsurl *selectedpath = [[nsurl alloc] initfileurlwithpath:[documentsdirectory stringbyappendingpathcomponent:@"focusdata.plist"]];             nsmutabledictionary *focusdict = [[nsmutabledictionary alloc] init];             [focusdict setvalue:[nsnumber numberwithfloat:[[self videodeviceinput] device].lensposition] forkey:@"focuslock"];             [focusdict writetourl:selectedpath atomically:yes];         }     } } 

Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -