feat: round output JSON floats to 2dp + unify ensure_ascii for asr/asrx
This commit is contained in:
@@ -129,7 +129,7 @@ struct SwiftOCR: ParsableCommand {
|
||||
"y": Int((1.0 - bb.origin.y - bb.size.height) * CGFloat(cgH)),
|
||||
"width": Int(bb.size.width * CGFloat(cgW)),
|
||||
"height": Int(bb.size.height * CGFloat(cgH)),
|
||||
"confidence": conf
|
||||
"confidence": Double(round(conf * 100)) / 100
|
||||
]
|
||||
texts.append(item)
|
||||
}
|
||||
@@ -137,7 +137,7 @@ struct SwiftOCR: ParsableCommand {
|
||||
if !texts.isEmpty {
|
||||
ocrFrames.append([
|
||||
"frame": frameNumber,
|
||||
"timestamp": timestamp,
|
||||
"timestamp": Double(round(timestamp * 100)) / 100,
|
||||
"texts": texts
|
||||
])
|
||||
}
|
||||
|
||||
@@ -155,9 +155,9 @@ struct SwiftPose: ParsableCommand {
|
||||
let py = CGFloat(h) - point.location.y * CGFloat(h)
|
||||
keypoints.append([
|
||||
"name": rawName.isEmpty ? "\(joint)" : rawName,
|
||||
"x": px,
|
||||
"y": py,
|
||||
"confidence": point.confidence,
|
||||
"x": Double(round(px * 100)) / 100,
|
||||
"y": Double(round(py * 100)) / 100,
|
||||
"confidence": Double(round(point.confidence * 100)) / 100,
|
||||
])
|
||||
if point.confidence > 0.1 {
|
||||
minX = min(minX, px)
|
||||
@@ -186,7 +186,7 @@ struct SwiftPose: ParsableCommand {
|
||||
if !persons.isEmpty {
|
||||
poseFrames.append([
|
||||
"frame": frameNum,
|
||||
"timestamp": timestamp,
|
||||
"timestamp": Double(round(timestamp * 100)) / 100,
|
||||
"persons": persons,
|
||||
])
|
||||
}
|
||||
@@ -201,7 +201,7 @@ struct SwiftPose: ParsableCommand {
|
||||
// Write output
|
||||
let outputDict: [String: Any] = [
|
||||
"frame_count": poseFrames.count,
|
||||
"fps": fps,
|
||||
"fps": Double(round(fps * 100)) / 100,
|
||||
"frames": poseFrames,
|
||||
]
|
||||
if let jsonData = try? JSONSerialization.data(withJSONObject: outputDict, options: [.prettyPrinted]) {
|
||||
|
||||
Reference in New Issue
Block a user