Showing
1 changed file
with
9 additions
and
4 deletions
| @@ -90,9 +90,13 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler, | @@ -90,9 +90,13 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler, | ||
| 90 | 90 | ||
| 91 | var i = 0 | 91 | var i = 0 |
| 92 | 92 | ||
| 93 | - | ||
| 94 | // Gets called when a new image is added to the buffer | 93 | // Gets called when a new image is added to the buffer |
| 95 | public func captureOutput(_ output: AVCaptureOutput, didOutput sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection) { | 94 | public func captureOutput(_ output: AVCaptureOutput, didOutput sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection) { |
| 95 | + // Ignore invalid textureId | ||
| 96 | + if textureId == nil { | ||
| 97 | + return | ||
| 98 | + } | ||
| 99 | + | ||
| 96 | i = i + 1; | 100 | i = i + 1; |
| 97 | 101 | ||
| 98 | latestBuffer = CMSampleBufferGetImageBuffer(sampleBuffer) | 102 | latestBuffer = CMSampleBufferGetImageBuffer(sampleBuffer) |
| @@ -107,9 +111,10 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler, | @@ -107,9 +111,10 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler, | ||
| 107 | } else { | 111 | } else { |
| 108 | return | 112 | return |
| 109 | } | 113 | } |
| 110 | - let imageRequestHandler = VNImageRequestHandler( | ||
| 111 | - cvPixelBuffer: latestBuffer, | ||
| 112 | - orientation: .right) | 114 | + |
| 115 | + let imageRequestHandler = VNImageRequestHandler( | ||
| 116 | + cvPixelBuffer: latestBuffer, | ||
| 117 | + orientation: .right) | ||
| 113 | 118 | ||
| 114 | do { | 119 | do { |
| 115 | try imageRequestHandler.perform([VNDetectBarcodesRequest { (request, error) in | 120 | try imageRequestHandler.perform([VNDetectBarcodesRequest { (request, error) in |
-
Please register or login to post a comment