Package apple.vision

Class VNGenerateOpticalFlowRequest

  • All Implemented Interfaces:
    NSCopying, NSObject

    public class VNGenerateOpticalFlowRequest
    extends VNTargetedImageRequest
    VNGenerateOpticalFlowRequest will determine directional change vectors for each pixel in the targeted image to transform it into the image processed by the request handler, 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. 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 { VNImageRequestHandler* imageRequestHandler = [[VNImageRequestHandler alloc] initWithCVPixelBuffer:fromImage options:@{}]; VNGenerateOpticalFlowRequest* request = [[VNGenerateOpticalFlowRequest alloc] initWithTargetedCVPixelBuffer:toImage options:@{}]; if (![imageRequestHandler performRequests:@[ request ] error:error]) { return nil; } return [[request results] firstObject]; } API-Since: 14.0
    • Constructor Detail

      • VNGenerateOpticalFlowRequest

        protected VNGenerateOpticalFlowRequest​(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 VNGenerateOpticalFlowRequestComputationAccuracyMedium. 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()
      • initWithTargetedCGImageOrientationOptions

        public VNGenerateOpticalFlowRequest initWithTargetedCGImageOrientationOptions​(@NotNull
                                                                                      @NotNull CGImageRef cgImage,
                                                                                      int orientation,
                                                                                      @NotNull
                                                                                      @NotNull NSDictionary<java.lang.String,​?> options)
        Description copied from class: VNTargetedImageRequest
        Create a new request with a targeted CGImage.
        Overrides:
        initWithTargetedCGImageOrientationOptions in class VNTargetedImageRequest
        Parameters:
        cgImage - The CGImageRef of the targeted image.
        orientation - The orientation of the image/buffer based on the EXIF specification. For details see kCGImagePropertyOrientation. The value has to be an integer from 1 to 8. This supersedes every other orientation information.
        options - A dictionary with options specifying auxiliary information for the image.
      • initWithTargetedCIImageOrientationOptions

        public VNGenerateOpticalFlowRequest initWithTargetedCIImageOrientationOptions​(@NotNull
                                                                                      @NotNull CIImage ciImage,
                                                                                      int orientation,
                                                                                      @NotNull
                                                                                      @NotNull NSDictionary<java.lang.String,​?> options)
        Description copied from class: VNTargetedImageRequest
        Create a new request with a targeted CIImage.
        Overrides:
        initWithTargetedCIImageOrientationOptions in class VNTargetedImageRequest
        Parameters:
        ciImage - The CIImage of the targeted image.
        orientation - The orientation of the image/buffer based on the EXIF specification. For details see kCGImagePropertyOrientation. The value has to be an integer from 1 to 8. This supersedes every other orientation information.
        options - A dictionary with options specifying auxiliary information for the image.
      • initWithTargetedCMSampleBufferOrientationOptions

        public VNGenerateOpticalFlowRequest initWithTargetedCMSampleBufferOrientationOptions​(@NotNull
                                                                                             @NotNull CMSampleBufferRef sampleBuffer,
                                                                                             int orientation,
                                                                                             @NotNull
                                                                                             @NotNull NSDictionary<java.lang.String,​?> options)
        Description copied from class: VNTargetedImageRequest
        Create a new request with a targeted CMSampleBuffer.
        Overrides:
        initWithTargetedCMSampleBufferOrientationOptions in class VNTargetedImageRequest
        Parameters:
        sampleBuffer - The CMSampleBuffer containing the CVImageBuffer to be used by the request.
        orientation - The orientation of the image/buffer based on the EXIF specification. For details see kCGImagePropertyOrientation. The value has to be an integer from 1 to 8. This supersedes every other orientation information.
        options - A dictionary with options specifying auxiliary information for the image. API-Since: 14.0
      • initWithTargetedCVPixelBufferOrientationOptions

        public VNGenerateOpticalFlowRequest initWithTargetedCVPixelBufferOrientationOptions​(@NotNull
                                                                                            @NotNull CVBufferRef pixelBuffer,
                                                                                            int orientation,
                                                                                            @NotNull
                                                                                            @NotNull NSDictionary<java.lang.String,​?> options)
        Description copied from class: VNTargetedImageRequest
        Create a new request that targets an image in a pixel buffer.
        Overrides:
        initWithTargetedCVPixelBufferOrientationOptions in class VNTargetedImageRequest
        Parameters:
        pixelBuffer - The pixel buffer containing the targeted image.
        orientation - The orientation of the image/buffer based on the EXIF specification. For details see kCGImagePropertyOrientation. The value has to be an integer from 1 to 8. This supersedes every other orientation information.
        options - A dictionary with options specifying auxiliary information for the image.
      • initWithTargetedImageDataOrientationOptions

        public VNGenerateOpticalFlowRequest initWithTargetedImageDataOrientationOptions​(@NotNull
                                                                                        @NotNull NSData imageData,
                                                                                        int orientation,
                                                                                        @NotNull
                                                                                        @NotNull NSDictionary<java.lang.String,​?> options)
        Description copied from class: VNTargetedImageRequest
        Create a new request with a targeted image data.
        Overrides:
        initWithTargetedImageDataOrientationOptions in class VNTargetedImageRequest
        Parameters:
        imageData - The data of the targeted image.
        orientation - The orientation of the image/buffer based on the EXIF specification. For details see kCGImagePropertyOrientation. The value has to be an integer from 1 to 8. This supersedes every other orientation information.
        options - A dictionary with options specifying auxiliary information for the image.
      • initWithTargetedImageURLOrientationOptions

        public VNGenerateOpticalFlowRequest initWithTargetedImageURLOrientationOptions​(@NotNull
                                                                                       @NotNull NSURL imageURL,
                                                                                       int orientation,
                                                                                       @NotNull
                                                                                       @NotNull NSDictionary<java.lang.String,​?> options)
        Description copied from class: VNTargetedImageRequest
        Create a new request with a targeted image URL.
        Overrides:
        initWithTargetedImageURLOrientationOptions in class VNTargetedImageRequest
        Parameters:
        imageURL - The URL of the targeted image.
        orientation - The orientation of the image/buffer based on the EXIF specification. For details see kCGImagePropertyOrientation. The value has to be an integer from 1 to 8. This supersedes every other orientation information.
        options - A dictionary with options specifying auxiliary information for the image.
      • 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)
      • 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 VNGenerateOpticalFlowRequestComputationAccuracyMedium. The computational time typically trends with the accuracy level. This parameter allows for selective tuning by the client application.
      • 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()
      • version_static

        public static long version_static()
      • 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. Setting this for revision 1 is a no-op as it is not ML-based. API-Since: 16.0
      • 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. Setting this for revision 1 is a no-op as it is not ML-based. API-Since: 16.0
      • useStoredAccessor

        @Deprecated
        public static boolean useStoredAccessor()
        Deprecated.