Ok, I have set the minimum deployment target to iOS 18.3 but it is still unable to find MLTensor in scope. Do I need to create my own struct of MLTensor somehow? Here is my current code:
import CoreML
class BallTracker {
let model: BallTrackerPreprocess
init() {
self.model = try! BallTrackerPreprocess(configuration: MLModelConfiguration())
}
func processFrame(from frames: [CVPixelBuffer]) -> MLTensor? {
// f1 is current, f2 is prev, f3 is previous prev
guard frames.count == 3 else { return nil }
let width = CVPixelBufferGetWidth(frames[0])
let height = CVPixelBufferGetHeight(frames[0])
let shape: [Int] = [3, height, width]
let tensor = MLTensor(concatenating: frames.map { MLTensor(pixelBuffer: $0) }, dimension: 0)
do {
let prediction = try model.prediction(input_frames: tensor)
return prediction.var_366
}
catch {
print("error: \(error)")
return nil
}
}
}