2021-05-06 06:11:55 -06:00
|
|
|
//
|
|
|
|
// FrameProcessorPlugin.h
|
|
|
|
// VisionCamera
|
|
|
|
//
|
|
|
|
// Created by Marc Rousavy on 01.05.21.
|
2021-06-01 05:07:57 -06:00
|
|
|
// Copyright © 2021 mrousavy. All rights reserved.
|
2021-05-06 06:11:55 -06:00
|
|
|
//
|
|
|
|
|
2023-02-27 03:18:03 -07:00
|
|
|
#pragma once
|
2021-05-06 06:11:55 -06:00
|
|
|
|
2021-06-09 02:57:05 -06:00
|
|
|
#import "Frame.h"
|
2023-09-01 04:58:32 -06:00
|
|
|
#import <Foundation/Foundation.h>
|
2021-05-06 06:11:55 -06:00
|
|
|
|
2023-09-01 04:58:32 -06:00
|
|
|
/// The base class for a Frame Processor Plugin which can be called synchronously from a JS Frame
|
|
|
|
/// Processor.
|
2023-02-27 03:18:03 -07:00
|
|
|
///
|
2023-09-01 04:58:32 -06:00
|
|
|
/// Subclass this class in a Swift or Objective-C class and override the `callback:withArguments:`
|
|
|
|
/// method, and implement your Frame Processing there.
|
2023-07-21 09:52:30 -06:00
|
|
|
///
|
2023-09-01 04:58:32 -06:00
|
|
|
/// Use `[FrameProcessorPluginRegistry addFrameProcessorPlugin:]` to register the Plugin to the
|
|
|
|
/// VisionCamera Runtime.
|
2023-02-27 03:18:03 -07:00
|
|
|
@interface FrameProcessorPlugin : NSObject
|
2021-05-06 06:11:55 -06:00
|
|
|
|
2023-10-19 02:35:14 -06:00
|
|
|
/// The initializer for a Frame Processor Plugin class that takes optional object that consists
|
|
|
|
/// options passed from JS layer
|
|
|
|
- (instancetype _Nonnull)initWithOptions:(NSDictionary* _Nullable)options;
|
|
|
|
|
2023-02-27 03:18:03 -07:00
|
|
|
/// The actual callback when calling this plugin. Any Frame Processing should be handled there.
|
|
|
|
/// Make sure your code is optimized, as this is a hot path.
|
2023-09-01 04:58:32 -06:00
|
|
|
- (id _Nullable)callback:(Frame* _Nonnull)frame withArguments:(NSDictionary* _Nullable)arguments;
|
2023-07-21 09:52:30 -06:00
|
|
|
|
|
|
|
@end
|
2023-10-19 02:35:14 -06:00
|
|
|
|
|
|
|
#define VISION_CONCAT2(A, B) A##B
|
|
|
|
#define VISION_CONCAT(A, B) VISION_CONCAT2(A, B)
|
|
|
|
|
|
|
|
#define VISION_EXPORT_FRAME_PROCESSOR(frame_processor_class, frame_processor_plugin_name) \
|
|
|
|
+(void)load { \
|
|
|
|
[FrameProcessorPluginRegistry addFrameProcessorPlugin:@ #frame_processor_plugin_name \
|
|
|
|
withInitializer:^FrameProcessorPlugin*(NSDictionary* _Nullable options) { \
|
|
|
|
return [[frame_processor_class alloc] initWithOptions:options]; \
|
|
|
|
}]; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define VISION_EXPORT_SWIFT_FRAME_PROCESSOR(frame_processor_class, frame_processor_plugin_name) \
|
|
|
|
\
|
|
|
|
@interface frame_processor_class (FrameProcessorPluginLoader) \
|
|
|
|
@end \
|
|
|
|
\
|
|
|
|
@implementation frame_processor_class (FrameProcessorPluginLoader) \
|
|
|
|
\
|
|
|
|
__attribute__((constructor)) static void VISION_CONCAT(initialize_, frame_processor_plugin_name)(void) { \
|
|
|
|
[FrameProcessorPluginRegistry addFrameProcessorPlugin:@ #frame_processor_plugin_name \
|
|
|
|
withInitializer:^FrameProcessorPlugin* _Nonnull(NSDictionary* _Nullable options) { \
|
|
|
|
return [[frame_processor_class alloc] initWithOptions:options]; \
|
|
|
|
}]; \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
@end
|