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-09 14:04:10 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
54c609f187d028269506d8d085a4f1d0cad7c490
54c609f1
1 parent
5c618204
add size & corners for MacOS
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
3 deletions
macos/mobile_scanner/Sources/mobile_scanner/MobileScannerPlugin.swift
macos/mobile_scanner/Sources/mobile_scanner/MobileScannerPlugin.swift
View file @
54c609f
...
...
@@ -542,10 +542,24 @@ extension CGImage {
}
extension
VNBarcodeObservation
{
private
func
distanceBetween
(
_
p1
:
CGPoint
,
_
p2
:
CGPoint
)
->
CGFloat
{
return
sqrt
(
pow
(
p1
.
x
-
p2
.
x
,
2
)
+
pow
(
p1
.
y
-
p2
.
y
,
2
))
}
public
func
toMap
()
->
[
String
:
Any
?]
{
return
[
"rawValue"
:
self
.
payloadStringValue
??
""
,
"format"
:
self
.
symbology
.
toInt
??
-
1
,
"corners"
:
[
[
"x"
:
Double
(
topLeft
.
x
),
"y"
:
Double
(
topLeft
.
y
)],
[
"x"
:
Double
(
topRight
.
x
),
"y"
:
Double
(
topRight
.
y
)],
[
"x"
:
Double
(
bottomRight
.
x
),
"y"
:
Double
(
bottomRight
.
y
)],
[
"x"
:
Double
(
bottomLeft
.
x
),
"y"
:
Double
(
bottomLeft
.
y
)],
],
"format"
:
symbology
.
toInt
??
-
1
,
"rawValue"
:
payloadStringValue
??
""
,
"size"
:
[
"width"
:
Double
(
distanceBetween
(
topLeft
,
topRight
)),
"height"
:
Double
(
distanceBetween
(
topLeft
,
bottomLeft
)),
],
]
}
}
...
...
@@ -585,7 +599,7 @@ extension VNBarcodeSymbology {
}
}
var
toInt
:
Int
?
{
var
toInt
:
Int
?
{
if
#available(macOS 12.0, *)
{
if
(
self
==
VNBarcodeSymbology
.
codabar
){
return
8
...
...
Please
register
or
login
to post a comment