Package apple.vision

Class VNTrackOpticalFlowRequest

  • All Implemented Interfaces:
    NSCopying, NSObject

    public class VNTrackOpticalFlowRequest
    extends VNStatefulRequest
    `VNTrackOpticalFlowRequest` will determine directional change vectors for each pixel from a previous to current image, reporting this result with a single `VNPixelBufferObservation`. Because this request works at the pixel level, both images must have the same dimensions in order for the request to be successfully performed. Setting a region of interest will isolate where the change determination is performed; however, the resultant observation will still be reported with a full resolution `VNPixelBufferObservation. Being a stateful request, at least two images must me processed in order to produce an observation. Optical flow requests are very resource intensive, so it is recommended that only one request at a time be created and that the handler where the request was issued be released immediately after generating optical flows. Example usage: - (nullable VNPixelBufferObservation*) opticalFlowFromImage:(CVPixelBufferRef)fromImage toImage:(CVPixelBuffer)toImage error:(NSError**)error { VNTrackOpticalFlowRequest* request = [[VNTrackOpticalFlowRequest alloc] init]; VNImageRequestHandler* imageRequestHandler = [[VNImageRequestHandler alloc] initWithCVPixelBuffer:fromImage options:@{}]; if (![imageRequestHandler performRequests:@[ request ] error:error]) { return nil; } imageRequestHandler = [[VNImageRequestHandler alloc] initWithCVPixelBuffer:toImage options:@{}]; if (![imageRequestHandler performRequests:@[ request ] error:error]) { return nil; } return [[request results] firstObject]; } API-Since: 17.0
    • Constructor Detail

      • VNTrackOpticalFlowRequest

        protected VNTrackOpticalFlowRequest​(org.moe.natj.general.Pointer peer)
    • Method Detail

      • accessInstanceVariablesDirectly

        public static boolean accessInstanceVariablesDirectly()
      • automaticallyNotifiesObserversForKey

        public static boolean automaticallyNotifiesObserversForKey​(@NotNull
                                                                   @NotNull java.lang.String key)
      • cancelPreviousPerformRequestsWithTarget

        public static void cancelPreviousPerformRequestsWithTarget​(@NotNull
                                                                   @NotNull java.lang.Object aTarget)
      • cancelPreviousPerformRequestsWithTargetSelectorObject

        public static void cancelPreviousPerformRequestsWithTargetSelectorObject​(@NotNull
                                                                                 @NotNull java.lang.Object aTarget,
                                                                                 @NotNull
                                                                                 @NotNull org.moe.natj.objc.SEL aSelector,
                                                                                 @Nullable
                                                                                 @Nullable java.lang.Object anArgument)
      • classFallbacksForKeyedArchiver

        @NotNull
        public static @NotNull NSArray<java.lang.String> classFallbacksForKeyedArchiver()
      • classForKeyedUnarchiver

        @NotNull
        public static @NotNull org.moe.natj.objc.Class classForKeyedUnarchiver()
      • computationAccuracy

        public long computationAccuracy()
        The level of accuracy used to compute the optical flow. Default is VNTrackOpticalFlowRequestComputationAccuracyMedium. The computational time typically trends with the accuracy level. This parameter allows for selective tuning by the client application.
      • currentRevision

        public static long currentRevision()
      • debugDescription_static

        public static java.lang.String debugDescription_static()
      • defaultRevision

        public static long defaultRevision()
      • description_static

        public static java.lang.String description_static()
      • hash_static

        public static long hash_static()
      • init

        public VNTrackOpticalFlowRequest init()
        Create a new request that can statefully track the optical from from one image to another. This is a convenience initializer for a frame analysis spacing of kCMTimeZero and a nil completion handler.
        Overrides:
        init in class VNStatefulRequest
      • initWithFrameAnalysisSpacingCompletionHandler

        public VNTrackOpticalFlowRequest initWithFrameAnalysisSpacingCompletionHandler​(CMTime frameAnalysisSpacing,
                                                                                       @Nullable
                                                                                       VNStatefulRequest.Block_initWithFrameAnalysisSpacingCompletionHandler completionHandler)
        Description copied from class: VNStatefulRequest
        Create a new video-based stateful request.
        Overrides:
        initWithFrameAnalysisSpacingCompletionHandler in class VNStatefulRequest
        Parameters:
        frameAnalysisSpacing - The reciprocal of maximum rate at which buffers will be processed. The request will not process buffers that fall within the frameAnalysisSpacing after it has performed the analysis. The analysis is not done by wall time but by analysis of of the time stamps of the samplebuffers being processed.
        completionHandler - The block to be invoked after the request has completed its processing. The completion handler gets executed on the same dispatch queue as the request being executed.
      • instanceMethodSignatureForSelector

        public static NSMethodSignature instanceMethodSignatureForSelector​(org.moe.natj.objc.SEL aSelector)
      • instancesRespondToSelector

        public static boolean instancesRespondToSelector​(org.moe.natj.objc.SEL aSelector)
      • isSubclassOfClass

        public static boolean isSubclassOfClass​(org.moe.natj.objc.Class aClass)
      • keepNetworkOutput

        public boolean keepNetworkOutput()
        Setting this to `YES` will keep the raw pixel buffer coming from the the ML network. The default is `NO`. When set to `YES`, the outputPixelFormat is ignored.
      • keyPathsForValuesAffectingValueForKey

        @NotNull
        public static @NotNull NSSet<java.lang.String> keyPathsForValuesAffectingValueForKey​(@NotNull
                                                                                             @NotNull java.lang.String key)
      • outputPixelFormat

        public int outputPixelFormat()
        Pixel format type of the output buffer. Valid values are `kCVPixelFormatType_TwoComponent32Float` and `kCVPixelFormatType_TwoComponent16Half`. Default is `kCVPixelFormatType_TwoComponent32Float`.
      • resolveClassMethod

        public static boolean resolveClassMethod​(org.moe.natj.objc.SEL sel)
      • resolveInstanceMethod

        public static boolean resolveInstanceMethod​(org.moe.natj.objc.SEL sel)
      • setComputationAccuracy

        public void setComputationAccuracy​(long value)
        The level of accuracy used to compute the optical flow. Default is VNTrackOpticalFlowRequestComputationAccuracyMedium. The computational time typically trends with the accuracy level. This parameter allows for selective tuning by the client application.
      • setKeepNetworkOutput

        public void setKeepNetworkOutput​(boolean value)
        Setting this to `YES` will keep the raw pixel buffer coming from the the ML network. The default is `NO`. When set to `YES`, the outputPixelFormat is ignored.
      • setOutputPixelFormat

        public void setOutputPixelFormat​(int value)
        Pixel format type of the output buffer. Valid values are `kCVPixelFormatType_TwoComponent32Float` and `kCVPixelFormatType_TwoComponent16Half`. Default is `kCVPixelFormatType_TwoComponent32Float`.
      • setVersion_static

        public static void setVersion_static​(long aVersion)
      • superclass_static

        public static org.moe.natj.objc.Class superclass_static()
      • supportedRevisions

        @NotNull
        public static @NotNull NSIndexSet supportedRevisions()
      • useStoredAccessor

        @Deprecated
        public static boolean useStoredAccessor()
        Deprecated.
      • version_static

        public static long version_static()