Skip to content

Commit

Permalink
remove unsued code block
Browse files Browse the repository at this point in the history
  • Loading branch information
navaronbracke committed Nov 26, 2024
1 parent 596c050 commit c1bb161
Showing 1 changed file with 1 addition and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,7 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler,
return
}

let barcodes: [VNBarcodeObservation] = results.compactMap({ barcode in
// If there is a scan window, check if the barcode is within said scan window.
// if self?.scanWindow != nil && cgImage != nil && !(self?.isBarcodeInsideScanWindow(barcodeObservation: barcode, imageSize: CGSize(width: cgImage!.width, height: cgImage!.height)) ?? false) {
// return nil
// }
//
let barcodes: [VNBarcodeObservation] = results.compactMap({ barcode in
return barcode
})

Expand Down Expand Up @@ -208,20 +203,9 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler,
}

// Set the region of interest to match scanWindow
// if let scanWindow = self?.scanWindow {
// barcodeRequest.regionOfInterest = scanWindow
// }
// Set the region of interest to match scanWindow
if let scanWindow = self?.scanWindow {
barcodeRequest.regionOfInterest = scanWindow
}


// !(self?.isBarcodeInsideScanWindow(barcodeObservation: barcode, imageSize: CGSize(width: cgImage!.width, height: cgImage!.height))
// if (self?.scanWindow != nil) {
// barcodeRequest.regionOfInterest = self!.scanWindow!
// }


try imageRequestHandler.perform([barcodeRequest])
} catch let error {
Expand Down Expand Up @@ -279,24 +263,6 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler,
result(nil)
}

func isBarcodeInsideScanWindow(barcodeObservation: VNBarcodeObservation, imageSize: CGSize) -> Bool {
let boundingBox = barcodeObservation.boundingBox

// Adjust boundingBox by inverting the y-axis
let adjustedBoundingBox = CGRect(
x: boundingBox.minX,
y: 1.0 - boundingBox.maxY,
width: boundingBox.width,
height: boundingBox.height
)

let intersects = scanWindow!.contains(adjustedBoundingBox)

// Check if the adjusted bounding box intersects with or is within the scan window
return intersects
}


private func getVideoOrientation() -> AVCaptureVideoOrientation {
#if os(iOS)
var videoOrientation: AVCaptureVideoOrientation
Expand Down

0 comments on commit c1bb161

Please sign in to comment.