Skip to content

Instantly share code, notes, and snippets.

@rolfbjarne

rolfbjarne/test.m Secret

Created Sep 30, 2014
Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner Author

@rolfbjarne rolfbjarne commented Sep 30, 2014

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