Merge pull request #228 from bletchley/feature/barcode-screen-coordinates

transform barcode metadata points to screen coordinates
This commit is contained in:
Zack Story 2016-04-03 11:00:12 -07:00
commit 067a37146c
1 changed files with 6 additions and 4 deletions

View File

@ -712,18 +712,20 @@ didFinishRecordingToOutputFileAtURL:(NSURL *)outputFileURL
for (AVMetadataMachineReadableCodeObject *metadata in metadataObjects) {
for (id barcodeType in [self getBarCodeTypes]) {
if (metadata.type == barcodeType) {
// Transform the meta-data coordinates to screen coords
AVMetadataMachineReadableCodeObject *transformed = (AVMetadataMachineReadableCodeObject *)[_previewLayer transformedMetadataObjectForMetadataObject:metadata];
NSDictionary *event = @{
@"type": metadata.type,
@"data": metadata.stringValue,
@"bounds": @{
@"origin": @{
@"x": [NSString stringWithFormat:@"%f", metadata.bounds.origin.x],
@"y": [NSString stringWithFormat:@"%f", metadata.bounds.origin.y]
@"x": [NSString stringWithFormat:@"%f", transformed.bounds.origin.x],
@"y": [NSString stringWithFormat:@"%f", transformed.bounds.origin.y]
},
@"size": @{
@"height": [NSString stringWithFormat:@"%f", metadata.bounds.size.height],
@"width": [NSString stringWithFormat:@"%f", metadata.bounds.size.width],
@"height": [NSString stringWithFormat:@"%f", transformed.bounds.size.height],
@"width": [NSString stringWithFormat:@"%f", transformed.bounds.size.width],
}
}
};