Toggle navigation
Toggle navigation
This project
Loading...
Sign in
flutter_package
/
mobile_scanner
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Navaron Bracke
2024-09-10 12:11:00 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
94bbad4f754f3850742001944166823d01336648
94bbad4f
1 parent
84a121e0
support formats on iOS for analyze image
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
3 deletions
ios/Classes/MobileScanner.swift
ios/Classes/MobileScannerPlugin.swift
ios/Classes/MobileScanner.swift
View file @
94bbad4
...
...
@@ -432,7 +432,8 @@ public class MobileScanner: NSObject, AVCaptureVideoDataOutputSampleBufferDelega
}
/// Analyze a single image
func
analyzeImage
(
image
:
UIImage
,
position
:
AVCaptureDevice
.
Position
,
callback
:
@escaping
BarcodeScanningCallback
)
{
func
analyzeImage
(
image
:
UIImage
,
position
:
AVCaptureDevice
.
Position
,
barcodeScannerOptions
:
BarcodeScannerOptions
?,
callback
:
@escaping
BarcodeScanningCallback
)
{
let
image
=
VisionImage
(
image
:
image
)
image
.
orientation
=
imageOrientation
(
deviceOrientation
:
UIDevice
.
current
.
orientation
,
...
...
@@ -440,6 +441,8 @@ public class MobileScanner: NSObject, AVCaptureVideoDataOutputSampleBufferDelega
position
:
position
)
let
scanner
:
BarcodeScanner
=
barcodeScannerOptions
!=
nil
?
BarcodeScanner
.
barcodeScanner
(
options
:
barcodeScannerOptions
!
)
:
BarcodeScanner
.
barcodeScanner
()
scanner
.
process
(
image
,
completion
:
callback
)
}
...
...
ios/Classes/MobileScannerPlugin.swift
View file @
94bbad4
...
...
@@ -253,7 +253,9 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin {
/// Analyzes a single image.
private
func
analyzeImage
(
_
call
:
FlutterMethodCall
,
_
result
:
@escaping
FlutterResult
)
{
let
uiImage
=
UIImage
(
contentsOfFile
:
call
.
arguments
as?
String
??
""
)
let
formats
:
Array
<
Int
>
=
(
call
.
arguments
as!
Dictionary
<
String
,
Any
?
>
)[
"formats"
]
as?
Array
??
[]
let
scannerOptions
:
BarcodeScannerOptions
?
=
buildBarcodeScannerOptions
(
formats
)
let
uiImage
=
UIImage
(
contentsOfFile
:
(
call
.
arguments
as!
Dictionary
<
String
,
Any
?
>
)[
"filePath"
]
as?
String
??
""
)
if
(
uiImage
==
nil
)
{
result
(
FlutterError
(
code
:
"MobileScanner"
,
...
...
@@ -262,7 +264,8 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin {
return
}
mobileScanner
.
analyzeImage
(
image
:
uiImage
!
,
position
:
AVCaptureDevice
.
Position
.
back
,
callback
:
{
barcodes
,
error
in
mobileScanner
.
analyzeImage
(
image
:
uiImage
!
,
position
:
AVCaptureDevice
.
Position
.
back
,
barcodeScannerOptions
:
scannerOptions
,
callback
:
{
barcodes
,
error
in
if
error
!=
nil
{
DispatchQueue
.
main
.
async
{
result
(
FlutterError
(
code
:
"MobileScanner"
,
...
...
Please
register
or
login
to post a comment