@@ -167,12 +167,7 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler,
167
167
return
168
168
}
169
169
170
- let barcodes : [ VNBarcodeObservation ] = results. compactMap ( { barcode in
171
- // If there is a scan window, check if the barcode is within said scan window.
172
- // if self?.scanWindow != nil && cgImage != nil && !(self?.isBarcodeInsideScanWindow(barcodeObservation: barcode, imageSize: CGSize(width: cgImage!.width, height: cgImage!.height)) ?? false) {
173
- // return nil
174
- // }
175
- //
170
+ let barcodes : [ VNBarcodeObservation ] = results. compactMap ( { barcode in
176
171
return barcode
177
172
} )
178
173
@@ -208,20 +203,9 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler,
208
203
}
209
204
210
205
// Set the region of interest to match scanWindow
211
- // if let scanWindow = self?.scanWindow {
212
- // barcodeRequest.regionOfInterest = scanWindow
213
- // }
214
- // Set the region of interest to match scanWindow
215
206
if let scanWindow = self ? . scanWindow {
216
207
barcodeRequest. regionOfInterest = scanWindow
217
208
}
218
-
219
-
220
- // !(self?.isBarcodeInsideScanWindow(barcodeObservation: barcode, imageSize: CGSize(width: cgImage!.width, height: cgImage!.height))
221
- // if (self?.scanWindow != nil) {
222
- // barcodeRequest.regionOfInterest = self!.scanWindow!
223
- // }
224
-
225
209
226
210
try imageRequestHandler. perform ( [ barcodeRequest] )
227
211
} catch let error {
@@ -279,24 +263,6 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler,
279
263
result ( nil )
280
264
}
281
265
282
- func isBarcodeInsideScanWindow( barcodeObservation: VNBarcodeObservation , imageSize: CGSize ) -> Bool {
283
- let boundingBox = barcodeObservation. boundingBox
284
-
285
- // Adjust boundingBox by inverting the y-axis
286
- let adjustedBoundingBox = CGRect (
287
- x: boundingBox. minX,
288
- y: 1.0 - boundingBox. maxY,
289
- width: boundingBox. width,
290
- height: boundingBox. height
291
- )
292
-
293
- let intersects = scanWindow!. contains ( adjustedBoundingBox)
294
-
295
- // Check if the adjusted bounding box intersects with or is within the scan window
296
- return intersects
297
- }
298
-
299
-
300
266
private func getVideoOrientation( ) -> AVCaptureVideoOrientation {
301
267
#if os(iOS)
302
268
var videoOrientation : AVCaptureVideoOrientation
0 commit comments