createml - CreateMLComponents: How to implement a custom pose selector for appending to Downsampler? - Stack Overflow

admin2025-04-21  5

For the purpose of CreateMLComponents poses filtering I'm implementing a custom pose selector which is inherited from TemporalTransformer protocol.

Here is how I'm going to use the selector:

let pipeline = Downsampler(factor: factor).appending(CustomPoseSelector())

Here is the selector implementation:

import CreateMLComponents

struct CustomPoseSelector: TemporalTransformer {
    typealias OutputSequence = [Pose]
    
    typealias Input = Pose
    typealias Output = Pose
    
    func transformTemporalData(_ input: [Pose]) -> [Pose] {
        return filterPoses(from: input)
    }
}

I encountered an error inside this code. Here is the message:

Type 'CustomPoseSelector' does not conform to protocol 'TemporalTransformer' Possibly intended match 'CustomPoseSelector.OutputSequence' (aka 'Array') does not conform to 'TemporalSequence'

I wrote the following code to conform [Pose] to TemporalSequence:

extension Array: @retroactive TemporalSequence where Element == Pose {
    public typealias Feature = Pose
}

Unfortunately this code returns the following error:

'TemporalSequence' requires the types 'Array.Element' (aka 'Pose') and 'TemporalFeature<Array.Feature>' (aka 'TemporalFeature') be equivalent

I'll appreciate any help in fixing the error as well as any proposals of alternative ways for CreateMLComponents poses filtering.

转载请注明原文地址:http://anycun.com/QandA/1745165225a90403.html