Showing
1 changed file
with
8 additions
and
7 deletions
| @@ -241,23 +241,24 @@ public class SwiftMobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHan | @@ -241,23 +241,24 @@ public class SwiftMobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHan | ||
| 241 | captureSession.commitConfiguration() | 241 | captureSession.commitConfiguration() |
| 242 | captureSession.startRunning() | 242 | captureSession.startRunning() |
| 243 | 243 | ||
| 244 | + let demensions = CMVideoFormatDescriptionGetDimensions(device.activeFormat.formatDescription) | ||
| 245 | + | ||
| 246 | + | ||
| 244 | /// limit captureSession area of interest to the scanWindow if provided | 247 | /// limit captureSession area of interest to the scanWindow if provided |
| 245 | let scanWindowData: Array? = argReader.intArray(key: "scanWindow") | 248 | let scanWindowData: Array? = argReader.intArray(key: "scanWindow") |
| 246 | if(scanWindowData != nil) { | 249 | if(scanWindowData != nil) { |
| 247 | 250 | ||
| 248 | let captureMetadataOutput = AVCaptureMetadataOutput() | 251 | let captureMetadataOutput = AVCaptureMetadataOutput() |
| 249 | 252 | ||
| 250 | - captureMetadataOutput.rectOfInterest = CGRect( | ||
| 251 | - x: scanWindowData![0], | ||
| 252 | - y: scanWindowData![1], | ||
| 253 | - width: scanWindowData![2] - scanWindowData![0], | ||
| 254 | - height: scanWindowData![3] - scanWindowData![1]) | 253 | + let x = CGFloat(scanWindowData![0] / Int(demensions.width)) |
| 254 | + let y = CGFloat(scanWindowData![1] / Int(demensions.height)) | ||
| 255 | + let w = CGFloat((scanWindowData![2] - scanWindowData![0]) / Int(demensions.width)) | ||
| 256 | + let h = CGFloat((scanWindowData![3] - scanWindowData![1]) / Int(demensions.height)) | ||
| 255 | 257 | ||
| 258 | + captureMetadataOutput.rectOfInterest = CGRect(x: x, y: y, width: w, height: h) | ||
| 256 | captureSession.addOutput(captureMetadataOutput) | 259 | captureSession.addOutput(captureMetadataOutput) |
| 257 | } | 260 | } |
| 258 | 261 | ||
| 259 | - | ||
| 260 | - let demensions = CMVideoFormatDescriptionGetDimensions(device.activeFormat.formatDescription) | ||
| 261 | let width = Double(demensions.height) | 262 | let width = Double(demensions.height) |
| 262 | let height = Double(demensions.width) | 263 | let height = Double(demensions.width) |
| 263 | let size = ["width": width, "height": height] | 264 | let size = ["width": width, "height": height] |
-
Please register or login to post a comment