-
-
Notifications
You must be signed in to change notification settings - Fork 523
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: support formats for analyze image #1177
fix: support formats for analyze image #1177
Conversation
| analyzeImage (Gallery) | :heavy_check_mark: | :heavy_check_mark: | :x: | :x: | | ||
| returnImage | :heavy_check_mark: | :heavy_check_mark: | :x: | :x: | | ||
| analyzeImage (Gallery) | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :x: | | ||
| returnImage | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :x: | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forgot to update this one for returnImage
@@ -134,16 +134,7 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin { | |||
self.mobileScanner.timeoutSeconds = Double(timeoutMs) / Double(1000) | |||
MobileScannerPlugin.returnImage = returnImage | |||
|
|||
let formatList = formats.map { format in return BarcodeFormat(rawValue: format)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was refactored & moved to reuse it
"rawValue": self.payloadStringValue ?? "", | ||
"format": self.symbology.toInt ?? -1, | ||
"corners": [ | ||
["x": topLeft.x, "y": topLeft.y], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The VNBarcodeResult had these corner points, but we did not pass them through
let symbologies:[VNBarcodeSymbology] = argReader.toSymbology() | ||
|
||
guard let fileUrl: URL = URL(string: argReader.string(key: "filePath") ?? "") else { | ||
// TODO: fix error code |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will unify the error codes in a follow up PR
formats.removeWhere((element) => element == BarcodeFormat.unknown); | ||
} | ||
final List<BarcodeFormat> formats = [ | ||
for (final BarcodeFormat format in options.formats) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for literal to optimize away the remove where
return const SizedBox(); | ||
} | ||
|
||
return CustomPaint( | ||
painter: BarcodeOverlay( | ||
barcodeCorners: scannedBarcode.corners, | ||
barcodeSize: barcodeCapture.size, | ||
barcodeSize: scannedBarcode.size, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The "barcode size" is wrong here
@@ -151,28 +151,16 @@ class MobileScannerHandler( | |||
null | |||
} | |||
|
|||
var barcodeScannerOptions: BarcodeScannerOptions? = null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was refactored & moved to reuse it.
|
||
val position = | ||
if (facing == 0) CameraSelector.DEFAULT_FRONT_CAMERA else CameraSelector.DEFAULT_BACK_CAMERA | ||
|
||
val detectionSpeed: DetectionSpeed = if (speed == 0) DetectionSpeed.NO_DUPLICATES | ||
else if (speed ==1) DetectionSpeed.NORMAL else DetectionSpeed.UNRESTRICTED | ||
val detectionSpeed: DetectionSpeed = when (speed) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was a refactor that was proposed by the Kotlin language tooling
/// Barcode scanner for results | ||
var scanner = BarcodeScanner.barcodeScanner() | ||
/// The long lived barcode scanner for scanning barcodes from a camera preview. | ||
var scanner: BarcodeScanner? = nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let image = VisionImage(image: image) | ||
image.orientation = imageOrientation( | ||
deviceOrientation: UIDevice.current.orientation, | ||
defaultOrientation: .portrait, | ||
position: position | ||
) | ||
|
||
let scanner: BarcodeScanner = barcodeScannerOptions != nil ? BarcodeScanner.barcodeScanner(options: barcodeScannerOptions!) : BarcodeScanner.barcodeScanner() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Create a short lived scanner for the analyze image call
This PR adds support for specifying the formats for analyze image.
It also adds the (normalized) barcode size for the barcodes on the web and adds support for analyze image on MacOS.
Fixes #1069