I see a linear slow down as more trackers are added in the loop below. According to the WWDC video I was hoping that performAll run all these request in parallel, but apparently not for TrackObjectRequest....
#if DEBUG
print("Frame processor: \(requests.count) tracking requests")
var observationCount: Int = 0
let trackingStart = Date()
#endif
for await observation in handler.performAll(requests) {
if case .trackObject(let request, let trackedBlock) = observation {
#if DEBUG
observationCount += 1
#endif
guard let trackedBlock = trackedBlock,
trackedBlock.confidence <= FrameProcessingThresholds.blockTrackedConfidenceThreshold else {
// lost track of the block, remove the tracker
blockTrackers.removeValue(forKey: request)
continue
}
trackedBlocks[blockTrackers[request]!] = trackedBlock.boundingBox
}
}
#if DEBUG
print("Frame processor: \(observationCount) observations")
print("Frame processor: tracker took \(Date().timeIntervalSince(trackingStart)) seconds")
#endif