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
casvanluijtelaar
2022-06-07 15:57:30 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
86429442d08cecf07fbad5e513d4d82db79da10a
86429442
1 parent
2272755b
cleanup
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
6 deletions
ios/Classes/SwiftMobileScannerPlugin.swift
ios/Classes/SwiftMobileScannerPlugin.swift
View file @
8642944
...
...
@@ -231,6 +231,7 @@ public class SwiftMobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHan
videoOutput
.
alwaysDiscardsLateVideoFrames
=
true
videoOutput
.
setSampleBufferDelegate
(
self
,
queue
:
DispatchQueue
.
main
)
captureSession
.
addOutput
(
videoOutput
)
for
connection
in
videoOutput
.
connections
{
connection
.
videoOrientation
=
.
portrait
...
...
@@ -243,22 +244,22 @@ public class SwiftMobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHan
let
demensions
=
CMVideoFormatDescriptionGetDimensions
(
device
.
activeFormat
.
formatDescription
)
/// limit captureSession area of interest to the scanWindow if provided
let
scanWindowData
:
Array
?
=
argReader
.
in
tArray
(
key
:
"scanWindow"
)
let
scanWindowData
:
Array
?
=
argReader
.
floa
tArray
(
key
:
"scanWindow"
)
if
(
scanWindowData
!=
nil
)
{
let
captureMetadataOutput
=
AVCaptureMetadataOutput
()
let
x
=
CGFloat
(
scanWindowData
!
[
0
]
/
Int
(
demensions
.
width
))
let
y
=
CGFloat
(
scanWindowData
!
[
1
]
/
Int
(
demensions
.
height
))
let
w
=
CGFloat
((
scanWindowData
!
[
2
]
-
scanWindowData
!
[
0
])
/
Int
(
demensions
.
width
))
let
h
=
CGFloat
((
scanWindowData
!
[
3
]
-
scanWindowData
!
[
1
])
/
Int
(
demensions
.
height
))
let
x
=
scanWindowData
!
[
0
]
/
CGFloat
(
demensions
.
width
)
let
y
=
scanWindowData
!
[
1
]
/
CGFloat
(
demensions
.
height
)
let
w
=
scanWindowData
!
[
2
]
-
scanWindowData
!
[
0
]
/
CGFloat
(
demensions
.
width
)
let
h
=
scanWindowData
!
[
3
]
-
scanWindowData
!
[
1
]
/
CGFloat
(
demensions
.
height
)
captureMetadataOutput
.
rectOfInterest
=
CGRect
(
x
:
x
,
y
:
y
,
width
:
w
,
height
:
h
)
captureSession
.
addOutput
(
captureMetadataOutput
)
}
let
width
=
Double
(
demensions
.
height
)
let
height
=
Double
(
demensions
.
width
)
let
size
=
[
"width"
:
width
,
"height"
:
height
]
...
...
@@ -392,4 +393,8 @@ class MapArgumentReader {
return
args
?[
key
]
as?
[
Int
]
}
func
floatArray
(
key
:
String
)
->
[
CGFloat
]?
{
return
args
?[
key
]
as?
[
CGFloat
]
}
}
...
...
Please
register
or
login
to post a comment