ios - AVCaptureSession doesn't read PDF417 with front camera but works with the back -
i'm trying avcapturesession on front end photographic camera read pdf417 barcode, refuses read same barcodes on front end photographic camera read no problem on back. there setting i'm missing or have front end photographic camera appearing "mirrored?"
i tried same thing qr code , works no problem on both front end , cameras.
_session = [[avcapturesession alloc] init]; nsarray *videodevices = [avcapturedevice deviceswithmediatype:avmediatypevideo]; for( avcapturedevice *device in videodevices ) { if( device.position == avcapturedevicepositionfront ) { _device = device; break; } } // couldn't find 1 on front, default video device. if( ! _device) { _device = [avcapturedevice defaultdevicewithmediatype:avmediatypevideo]; }
// _device = [avcapturedevice defaultdevicewithmediatype:avmediatypevideo];
nserror *error = nil; if( _device.isautofocusrangerestrictionsupported ) { if( [_device lockforconfiguration:&error] ) { [_device setautofocusrangerestriction:avcaptureautofocusrangerestrictionnear]; [_device unlockforconfiguration]; } } _input = [avcapturedeviceinput deviceinputwithdevice:_device error:&error]; if (_input) { [_session addinput:_input]; } else { nslog(@"error: %@", error); } _output = [[avcapturemetadataoutput alloc] init]; [_output setmetadataobjectsdelegate:self queue:dispatch_get_main_queue()]; [_session addoutput:_output];
// _output.metadataobjecttypes = [_output availablemetadataobjecttypes]; _output.metadataobjecttypes = @[avmetadataobjecttypepdf417code ];
_prevlayer = [avcapturevideopreviewlayer layerwithsession:_session]; _prevlayer.frame = self.view.bounds; _prevlayer.videogravity = avlayervideogravityresizeaspectfill; [self updatepreviewlayerfororientation:[[uiapplication sharedapplication] statusbarorientation] ]; [self.view.layer addsublayer:_prevlayer]; [_session startrunning];
ios objective-c avfoundation avcapturesession pdf417
No comments:
Post a Comment