Committed by
GitHub
Merge branch 'master' into dependabot/github_actions/actions/checkout-3.3.0
Showing
8 changed files
with
90 additions
and
49 deletions
| @@ -38,6 +38,16 @@ NSCameraUsageDescription - describe why your app needs access to the camera. Thi | @@ -38,6 +38,16 @@ NSCameraUsageDescription - describe why your app needs access to the camera. Thi | ||
| 38 | **If you want to use the local gallery feature from [image_picker](https://pub.dev/packages/image_picker)** | 38 | **If you want to use the local gallery feature from [image_picker](https://pub.dev/packages/image_picker)** |
| 39 | NSPhotoLibraryUsageDescription - describe why your app needs permission for the photo library. This is called Privacy - Photo Library Usage Description in the visual editor. | 39 | NSPhotoLibraryUsageDescription - describe why your app needs permission for the photo library. This is called Privacy - Photo Library Usage Description in the visual editor. |
| 40 | 40 | ||
| 41 | + Example, | ||
| 42 | + ``` | ||
| 43 | + <key>NSCameraUsageDescription</key> | ||
| 44 | + <string>This app needs camera access to scan QR codes</string> | ||
| 45 | + | ||
| 46 | + <key>NSPhotoLibraryUsageDescription</key> | ||
| 47 | + <string>This app needs photos access to get QR code from photo library</string> | ||
| 48 | + ``` | ||
| 49 | + | ||
| 50 | + | ||
| 41 | ### macOS | 51 | ### macOS |
| 42 | Ensure that you granted camera permission in XCode -> Signing & Capabilities: | 52 | Ensure that you granted camera permission in XCode -> Signing & Capabilities: |
| 43 | 53 |
| @@ -36,5 +36,8 @@ end | @@ -36,5 +36,8 @@ end | ||
| 36 | post_install do |installer| | 36 | post_install do |installer| |
| 37 | installer.pods_project.targets.each do |target| | 37 | installer.pods_project.targets.each do |target| |
| 38 | flutter_additional_macos_build_settings(target) | 38 | flutter_additional_macos_build_settings(target) |
| 39 | + target.build_configurations.each do |config| | ||
| 40 | + config.build_settings['MACOSX_DEPLOYMENT_TARGET'] = '10.13' | ||
| 41 | + end | ||
| 39 | end | 42 | end |
| 40 | end | 43 | end |
| @@ -26,7 +26,7 @@ | @@ -26,7 +26,7 @@ | ||
| 26 | 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; }; | 26 | 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; }; |
| 27 | 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; }; | 27 | 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; }; |
| 28 | 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; }; | 28 | 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; }; |
| 29 | - 5B9BD2ADBC68B74D80B57DF1 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EC099C2B6D6B30BFB3FA6DB8 /* Pods_Runner.framework */; }; | 29 | + 5348E36EDC155A01222C3599 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 41950513928B2DA794C685E3 /* Pods_Runner.framework */; }; |
| 30 | /* End PBXBuildFile section */ | 30 | /* End PBXBuildFile section */ |
| 31 | 31 | ||
| 32 | /* Begin PBXContainerItemProxy section */ | 32 | /* Begin PBXContainerItemProxy section */ |
| @@ -67,12 +67,12 @@ | @@ -67,12 +67,12 @@ | ||
| 67 | 33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = "<group>"; }; | 67 | 33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = "<group>"; }; |
| 68 | 33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = "<group>"; }; | 68 | 33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = "<group>"; }; |
| 69 | 33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = "<group>"; }; | 69 | 33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = "<group>"; }; |
| 70 | - 3CEE8DB43A84811F33EB0202 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = "<group>"; }; | 70 | + 41950513928B2DA794C685E3 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; |
| 71 | + 433FCBF2B1E3F653F96B3C79 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = "<group>"; }; | ||
| 71 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = "<group>"; }; | 72 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = "<group>"; }; |
| 72 | 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = "<group>"; }; | 73 | 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = "<group>"; }; |
| 73 | - A1CBC07680A8ED396DBB68C0 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; }; | ||
| 74 | - CAD760C57A57D903AB03B47A /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; }; | ||
| 75 | - EC099C2B6D6B30BFB3FA6DB8 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; | 74 | + 97D4F0103EE99761EF216A9C /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; }; |
| 75 | + B67CB61EED45BF13A197D997 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; }; | ||
| 76 | /* End PBXFileReference section */ | 76 | /* End PBXFileReference section */ |
| 77 | 77 | ||
| 78 | /* Begin PBXFrameworksBuildPhase section */ | 78 | /* Begin PBXFrameworksBuildPhase section */ |
| @@ -80,27 +80,19 @@ | @@ -80,27 +80,19 @@ | ||
| 80 | isa = PBXFrameworksBuildPhase; | 80 | isa = PBXFrameworksBuildPhase; |
| 81 | buildActionMask = 2147483647; | 81 | buildActionMask = 2147483647; |
| 82 | files = ( | 82 | files = ( |
| 83 | - 5B9BD2ADBC68B74D80B57DF1 /* Pods_Runner.framework in Frameworks */, | 83 | + 5348E36EDC155A01222C3599 /* Pods_Runner.framework in Frameworks */, |
| 84 | ); | 84 | ); |
| 85 | runOnlyForDeploymentPostprocessing = 0; | 85 | runOnlyForDeploymentPostprocessing = 0; |
| 86 | }; | 86 | }; |
| 87 | /* End PBXFrameworksBuildPhase section */ | 87 | /* End PBXFrameworksBuildPhase section */ |
| 88 | 88 | ||
| 89 | /* Begin PBXGroup section */ | 89 | /* Begin PBXGroup section */ |
| 90 | - 18927D60C719EB75FC0A6633 /* Frameworks */ = { | ||
| 91 | - isa = PBXGroup; | ||
| 92 | - children = ( | ||
| 93 | - EC099C2B6D6B30BFB3FA6DB8 /* Pods_Runner.framework */, | ||
| 94 | - ); | ||
| 95 | - name = Frameworks; | ||
| 96 | - sourceTree = "<group>"; | ||
| 97 | - }; | ||
| 98 | 20F8C9AA20C2A495C125E194 /* Pods */ = { | 90 | 20F8C9AA20C2A495C125E194 /* Pods */ = { |
| 99 | isa = PBXGroup; | 91 | isa = PBXGroup; |
| 100 | children = ( | 92 | children = ( |
| 101 | - CAD760C57A57D903AB03B47A /* Pods-Runner.debug.xcconfig */, | ||
| 102 | - A1CBC07680A8ED396DBB68C0 /* Pods-Runner.release.xcconfig */, | ||
| 103 | - 3CEE8DB43A84811F33EB0202 /* Pods-Runner.profile.xcconfig */, | 93 | + B67CB61EED45BF13A197D997 /* Pods-Runner.debug.xcconfig */, |
| 94 | + 97D4F0103EE99761EF216A9C /* Pods-Runner.release.xcconfig */, | ||
| 95 | + 433FCBF2B1E3F653F96B3C79 /* Pods-Runner.profile.xcconfig */, | ||
| 104 | ); | 96 | ); |
| 105 | path = Pods; | 97 | path = Pods; |
| 106 | sourceTree = "<group>"; | 98 | sourceTree = "<group>"; |
| @@ -123,7 +115,7 @@ | @@ -123,7 +115,7 @@ | ||
| 123 | 33CEB47122A05771004F2AC0 /* Flutter */, | 115 | 33CEB47122A05771004F2AC0 /* Flutter */, |
| 124 | 33CC10EE2044A3C60003C045 /* Products */, | 116 | 33CC10EE2044A3C60003C045 /* Products */, |
| 125 | 20F8C9AA20C2A495C125E194 /* Pods */, | 117 | 20F8C9AA20C2A495C125E194 /* Pods */, |
| 126 | - 18927D60C719EB75FC0A6633 /* Frameworks */, | 118 | + 64FFE901A03ED70F67D8DCD6 /* Frameworks */, |
| 127 | ); | 119 | ); |
| 128 | sourceTree = "<group>"; | 120 | sourceTree = "<group>"; |
| 129 | }; | 121 | }; |
| @@ -170,6 +162,14 @@ | @@ -170,6 +162,14 @@ | ||
| 170 | path = Runner; | 162 | path = Runner; |
| 171 | sourceTree = "<group>"; | 163 | sourceTree = "<group>"; |
| 172 | }; | 164 | }; |
| 165 | + 64FFE901A03ED70F67D8DCD6 /* Frameworks */ = { | ||
| 166 | + isa = PBXGroup; | ||
| 167 | + children = ( | ||
| 168 | + 41950513928B2DA794C685E3 /* Pods_Runner.framework */, | ||
| 169 | + ); | ||
| 170 | + name = Frameworks; | ||
| 171 | + sourceTree = "<group>"; | ||
| 172 | + }; | ||
| 173 | /* End PBXGroup section */ | 173 | /* End PBXGroup section */ |
| 174 | 174 | ||
| 175 | /* Begin PBXNativeTarget section */ | 175 | /* Begin PBXNativeTarget section */ |
| @@ -177,13 +177,13 @@ | @@ -177,13 +177,13 @@ | ||
| 177 | isa = PBXNativeTarget; | 177 | isa = PBXNativeTarget; |
| 178 | buildConfigurationList = 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */; | 178 | buildConfigurationList = 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */; |
| 179 | buildPhases = ( | 179 | buildPhases = ( |
| 180 | - 20903D1E9D9F08576541FFD7 /* [CP] Check Pods Manifest.lock */, | 180 | + 11C0752B00246A027DB2D859 /* [CP] Check Pods Manifest.lock */, |
| 181 | 33CC10E92044A3C60003C045 /* Sources */, | 181 | 33CC10E92044A3C60003C045 /* Sources */, |
| 182 | 33CC10EA2044A3C60003C045 /* Frameworks */, | 182 | 33CC10EA2044A3C60003C045 /* Frameworks */, |
| 183 | 33CC10EB2044A3C60003C045 /* Resources */, | 183 | 33CC10EB2044A3C60003C045 /* Resources */, |
| 184 | 33CC110E2044A8840003C045 /* Bundle Framework */, | 184 | 33CC110E2044A8840003C045 /* Bundle Framework */, |
| 185 | 3399D490228B24CF009A79C7 /* ShellScript */, | 185 | 3399D490228B24CF009A79C7 /* ShellScript */, |
| 186 | - DF45614760BB9B24F49B2055 /* [CP] Embed Pods Frameworks */, | 186 | + E6424ECF3C1308BAAF6E5E67 /* [CP] Embed Pods Frameworks */, |
| 187 | ); | 187 | ); |
| 188 | buildRules = ( | 188 | buildRules = ( |
| 189 | ); | 189 | ); |
| @@ -253,7 +253,7 @@ | @@ -253,7 +253,7 @@ | ||
| 253 | /* End PBXResourcesBuildPhase section */ | 253 | /* End PBXResourcesBuildPhase section */ |
| 254 | 254 | ||
| 255 | /* Begin PBXShellScriptBuildPhase section */ | 255 | /* Begin PBXShellScriptBuildPhase section */ |
| 256 | - 20903D1E9D9F08576541FFD7 /* [CP] Check Pods Manifest.lock */ = { | 256 | + 11C0752B00246A027DB2D859 /* [CP] Check Pods Manifest.lock */ = { |
| 257 | isa = PBXShellScriptBuildPhase; | 257 | isa = PBXShellScriptBuildPhase; |
| 258 | buildActionMask = 2147483647; | 258 | buildActionMask = 2147483647; |
| 259 | files = ( | 259 | files = ( |
| @@ -312,7 +312,7 @@ | @@ -312,7 +312,7 @@ | ||
| 312 | shellPath = /bin/sh; | 312 | shellPath = /bin/sh; |
| 313 | shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire"; | 313 | shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire"; |
| 314 | }; | 314 | }; |
| 315 | - DF45614760BB9B24F49B2055 /* [CP] Embed Pods Frameworks */ = { | 315 | + E6424ECF3C1308BAAF6E5E67 /* [CP] Embed Pods Frameworks */ = { |
| 316 | isa = PBXShellScriptBuildPhase; | 316 | isa = PBXShellScriptBuildPhase; |
| 317 | buildActionMask = 2147483647; | 317 | buildActionMask = 2147483647; |
| 318 | files = ( | 318 | files = ( |
| @@ -283,9 +283,9 @@ class MobileScannerController { | @@ -283,9 +283,9 @@ class MobileScannerController { | ||
| 283 | await _methodChannel.invokeMethod('torch', torchState.value.index); | 283 | await _methodChannel.invokeMethod('torch', torchState.value.index); |
| 284 | } | 284 | } |
| 285 | 285 | ||
| 286 | - /// Switches the torch on or off. | 286 | + /// Changes the state of the camera (front or back). |
| 287 | /// | 287 | /// |
| 288 | - /// Only works if torch is available. | 288 | + /// Does nothing if the device has no front camera. |
| 289 | Future<void> switchCamera() async { | 289 | Future<void> switchCamera() async { |
| 290 | await _methodChannel.invokeMethod('stop'); | 290 | await _methodChannel.invokeMethod('stop'); |
| 291 | final CameraFacing facingToUse = | 291 | final CameraFacing facingToUse = |
macos/Classes/DetectionSpeed.swift
0 → 100644
| 1 | import AVFoundation | 1 | import AVFoundation |
| 2 | import FlutterMacOS | 2 | import FlutterMacOS |
| 3 | import Vision | 3 | import Vision |
| 4 | -import UIKit | 4 | +import AppKit |
| 5 | 5 | ||
| 6 | public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler, FlutterTexture, AVCaptureVideoDataOutputSampleBufferDelegate { | 6 | public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler, FlutterTexture, AVCaptureVideoDataOutputSampleBufferDelegate { |
| 7 | 7 | ||
| @@ -25,6 +25,8 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler, | @@ -25,6 +25,8 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler, | ||
| 25 | // optional window to limit scan search | 25 | // optional window to limit scan search |
| 26 | var scanWindow: CGRect? | 26 | var scanWindow: CGRect? |
| 27 | 27 | ||
| 28 | + var detectionSpeed: DetectionSpeed = DetectionSpeed.noDuplicates | ||
| 29 | + | ||
| 28 | 30 | ||
| 29 | // var analyzeMode: Int = 0 | 31 | // var analyzeMode: Int = 0 |
| 30 | var analyzing: Bool = false | 32 | var analyzing: Bool = false |
| @@ -90,28 +92,22 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler, | @@ -90,28 +92,22 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler, | ||
| 90 | 92 | ||
| 91 | var i = 0 | 93 | var i = 0 |
| 92 | 94 | ||
| 95 | + | ||
| 93 | // Gets called when a new image is added to the buffer | 96 | // Gets called when a new image is added to the buffer |
| 94 | public func captureOutput(_ output: AVCaptureOutput, didOutput sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection) { | 97 | public func captureOutput(_ output: AVCaptureOutput, didOutput sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection) { |
| 95 | // Ignore invalid textureId | 98 | // Ignore invalid textureId |
| 96 | if textureId == nil { | 99 | if textureId == nil { |
| 97 | return | 100 | return |
| 98 | } | 101 | } |
| 99 | - | ||
| 100 | - i = i + 1; | ||
| 101 | - | ||
| 102 | - latestBuffer = CMSampleBufferGetImageBuffer(sampleBuffer) | ||
| 103 | - registry.textureFrameAvailable(textureId) | ||
| 104 | - | ||
| 105 | -// switch analyzeMode { | ||
| 106 | -// case 1: // barcode | ||
| 107 | - | ||
| 108 | - // Limit the analyzer because the texture output will freeze otherwise | ||
| 109 | - if i / 10 == 1 { | ||
| 110 | - i = 0 | ||
| 111 | - } else { | 102 | + guard let imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer) else { |
| 103 | + print("Failed to get image buffer from sample buffer.") | ||
| 112 | return | 104 | return |
| 113 | } | 105 | } |
| 106 | + latestBuffer = imageBuffer | ||
| 107 | + registry.textureFrameAvailable(textureId) | ||
| 114 | 108 | ||
| 109 | + if ((detectionSpeed == DetectionSpeed.normal || detectionSpeed == DetectionSpeed.noDuplicates) && i > 10 || detectionSpeed == DetectionSpeed.unrestricted) { | ||
| 110 | + i = 0 | ||
| 115 | let imageRequestHandler = VNImageRequestHandler( | 111 | let imageRequestHandler = VNImageRequestHandler( |
| 116 | cvPixelBuffer: latestBuffer, | 112 | cvPixelBuffer: latestBuffer, |
| 117 | orientation: .right) | 113 | orientation: .right) |
| @@ -121,8 +117,8 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler, | @@ -121,8 +117,8 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler, | ||
| 121 | if error == nil { | 117 | if error == nil { |
| 122 | if let results = request.results as? [VNBarcodeObservation] { | 118 | if let results = request.results as? [VNBarcodeObservation] { |
| 123 | for barcode in results { | 119 | for barcode in results { |
| 124 | - if scanWindow != nil { | ||
| 125 | - let match = isbarCodeInScanWindow(scanWindow!, barcode, buffer!.image) | 120 | + if self.scanWindow != nil { |
| 121 | + let match = self.isbarCodeInScanWindow(self.scanWindow!, barcode, self.latestBuffer) | ||
| 126 | if (!match) { | 122 | if (!match) { |
| 127 | continue | 123 | continue |
| 128 | } | 124 | } |
| @@ -146,10 +142,9 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler, | @@ -146,10 +142,9 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler, | ||
| 146 | } catch { | 142 | } catch { |
| 147 | print(error) | 143 | print(error) |
| 148 | } | 144 | } |
| 149 | - | ||
| 150 | -// default: // none | ||
| 151 | -// break | ||
| 152 | -// } | 145 | + } else { |
| 146 | + i+=1 | ||
| 147 | + } | ||
| 153 | } | 148 | } |
| 154 | 149 | ||
| 155 | func checkPermission(_ call: FlutterMethodCall, _ result: @escaping FlutterResult) { | 150 | func checkPermission(_ call: FlutterMethodCall, _ result: @escaping FlutterResult) { |
| @@ -193,11 +188,11 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler, | @@ -193,11 +188,11 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler, | ||
| 193 | scanWindow = CGRect(x: minX, y: minY, width: width, height: height) | 188 | scanWindow = CGRect(x: minX, y: minY, width: width, height: height) |
| 194 | } | 189 | } |
| 195 | 190 | ||
| 196 | - func isbarCodeInScanWindow(_ scanWindow: CGRect, _ barcode: Barcode, _ inputImage: UIImage) -> Bool { | ||
| 197 | - let barcodeBoundingBox = barcode.frame | 191 | + func isbarCodeInScanWindow(_ scanWindow: CGRect, _ barcode: VNBarcodeObservation, _ inputImage: CVImageBuffer) -> Bool { |
| 192 | + let size = CVImageBufferGetEncodedSize(inputImage) | ||
| 198 | 193 | ||
| 199 | - let imageWidth = inputImage.size.width; | ||
| 200 | - let imageHeight = inputImage.size.height; | 194 | + let imageWidth = size.width; |
| 195 | + let imageHeight = size.height; | ||
| 201 | 196 | ||
| 202 | let minX = scanWindow.minX * imageWidth | 197 | let minX = scanWindow.minX * imageWidth |
| 203 | let minY = scanWindow.minY * imageHeight | 198 | let minY = scanWindow.minY * imageHeight |
| @@ -205,7 +200,7 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler, | @@ -205,7 +200,7 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler, | ||
| 205 | let height = scanWindow.height * imageHeight | 200 | let height = scanWindow.height * imageHeight |
| 206 | 201 | ||
| 207 | let scaledScanWindow = CGRect(x: minX, y: minY, width: width, height: height) | 202 | let scaledScanWindow = CGRect(x: minX, y: minY, width: width, height: height) |
| 208 | - return scaledScanWindow.contains(barcodeBoundingBox) | 203 | + return scaledScanWindow.contains(barcode.boundingBox) |
| 209 | } | 204 | } |
| 210 | 205 | ||
| 211 | func start(_ call: FlutterMethodCall, _ result: @escaping FlutterResult) { | 206 | func start(_ call: FlutterMethodCall, _ result: @escaping FlutterResult) { |
| @@ -224,6 +219,9 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler, | @@ -224,6 +219,9 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler, | ||
| 224 | // let ratio: Int = argReader.int(key: "ratio") | 219 | // let ratio: Int = argReader.int(key: "ratio") |
| 225 | let torch: Bool = argReader.bool(key: "torch") ?? false | 220 | let torch: Bool = argReader.bool(key: "torch") ?? false |
| 226 | let facing: Int = argReader.int(key: "facing") ?? 1 | 221 | let facing: Int = argReader.int(key: "facing") ?? 1 |
| 222 | + let speed: Int = (call.arguments as! Dictionary<String, Any?>)["speed"] as? Int ?? 0 | ||
| 223 | + | ||
| 224 | + detectionSpeed = DetectionSpeed(rawValue: speed)! | ||
| 227 | 225 | ||
| 228 | // Set the camera to use | 226 | // Set the camera to use |
| 229 | position = facing == 0 ? AVCaptureDevice.Position.front : .back | 227 | position = facing == 0 ? AVCaptureDevice.Position.front : .back |
-
Please register or login to post a comment