Files
L'électron rare 660d493ad6 feat(wire): skeleton2D frame payload
Add FrameTag.skeleton2D (raw 6) and Skeleton2DPayload for
2D-projected ARKit joints: 91×SIMD2<Float> + 91 valid bytes,
big-endian wire format mirroring SkeletonPayload style.

Note: raw value is 6 (not 5 as drafted) because face=5 is taken.
2026-06-30 19:15:16 +02:00

32 lines
994 B
Swift
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import XCTest
@testable import AVLiveWire
final class Skeleton2DPayloadTests: XCTestCase {
func testRoundTrip() {
var p = Skeleton2DPayload()
for i in 0..<Skeleton2DPayload.jointCount {
p.points[i] = SIMD2(Float(i) * 0.001, Float(i) * 0.002)
p.valid[i] = (i % 2 == 0)
}
let data = p.encoded()
let r = Skeleton2DPayload(decoding: data)
XCTAssertNotNil(r)
XCTAssertEqual(r!.points[10].x, p.points[10].x, accuracy: 1e-6)
XCTAssertEqual(r!.valid[10], p.valid[10])
XCTAssertEqual(r!.valid[11], p.valid[11])
}
func testByteCount() {
// 91 joints × 2 floats × 4 bytes + 91 valid bytes = 91*8+91 = 819
XCTAssertEqual(Skeleton2DPayload.byteCount, 91 * 8 + 91)
}
func testRejectsWrongSize() {
XCTAssertNil(Skeleton2DPayload(decoding: Data([0, 1, 2])))
}
func testFrameTagSkeleton2D() {
XCTAssertEqual(FrameTag.skeleton2D.rawValue, 6)
}
}