Skip to content

Instantly share code, notes, and snippets.

@rolfbjarne
Created September 30, 2014 09:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rolfbjarne/c4b20adea4aae44d53c3 to your computer and use it in GitHub Desktop.
Save rolfbjarne/c4b20adea4aae44d53c3 to your computer and use it in GitHub Desktop.
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);
@rolfbjarne
Copy link
Author

region: 10.000000 349.000000 1004.000000 70.000000
reg: 10.000000 349.000000 1004.000000 70.000000

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment