-
-
Save rolfbjarne/c4b20adea4aae44d53c3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AVCaptureSession *session = [[AVCaptureSession alloc] init]; | |
AVCaptureDevice *camera = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo]; | |
AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:camera error:nil]; | |
[session addInput:input]; | |
AVCaptureMetadataOutput *output = [[AVCaptureMetadataOutput alloc] init]; | |
CGRect region = CGRectMake (self.view.bounds.origin.x + 10, self.view.bounds.size.height / 2 - 35, self.view.bounds.size.width - 20, 70); | |
[session addOutput:output]; | |
AVCaptureVideoPreviewLayer *previewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:session]; | |
previewLayer.masksToBounds = YES; | |
previewLayer.videoGravity = AVLayerVideoGravityResize; | |
previewLayer.frame = [[UIScreen mainScreen] bounds]; | |
CGRect reg = [output metadataOutputRectOfInterestForRect: region]; | |
NSLog (@"region: %f %f %f %f", region.origin.x, region.origin.y, region.size.width, region.size.height); | |
NSLog (@"reg: %f %f %f %f", reg.origin.x, reg.origin.y, reg.size.width, reg.size.height); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
region: 10.000000 349.000000 1004.000000 70.000000
reg: 10.000000 349.000000 1004.000000 70.000000