feat: Reintroduce Macros for Frame Processor Plugin registration (#2027)
in VisionCamera v1 & v2 there were two ObjC macros that were helping in creation/registration of Frame Processors, but these were removed with v3 This PR reintroduces such macros, which will not only make FP development easier, but also it will also fix issues people had with registration of Swift Frame Processors (+load vs +initialize issues) Docs were also updated to reflect that the macros should be used to correctly initialize and register ObjC/Swift Frame Processors
This commit is contained in:
@@ -40,7 +40,7 @@ public class ExampleFrameProcessorPlugin extends FrameProcessorPlugin {
|
||||
return map;
|
||||
}
|
||||
|
||||
ExampleFrameProcessorPlugin() {
|
||||
|
||||
ExampleFrameProcessorPlugin(@Nullable Map<String, Object> options) {
|
||||
Log.d("ExamplePlugin", " - options: " + options.toString());
|
||||
}
|
||||
}
|
||||
|
@@ -4,7 +4,11 @@ import android.util.Log
|
||||
import com.mrousavy.camera.frameprocessor.Frame
|
||||
import com.mrousavy.camera.frameprocessor.FrameProcessorPlugin
|
||||
|
||||
class ExampleKotlinFrameProcessorPlugin: FrameProcessorPlugin() {
|
||||
class ExampleKotlinFrameProcessorPlugin(options: Map<String, Any>?): FrameProcessorPlugin(options) {
|
||||
init {
|
||||
Log.d("ExampleKotlinPlugin", " - options" + options?.toString())
|
||||
}
|
||||
|
||||
override fun callback(frame: Frame, params: Map<String, Any>?): Any? {
|
||||
if (params == null) {
|
||||
return null
|
||||
|
@@ -65,7 +65,7 @@ public class MainApplication extends Application implements ReactApplication {
|
||||
DefaultNewArchitectureEntryPoint.load();
|
||||
}
|
||||
|
||||
FrameProcessorPluginRegistry.addFrameProcessorPlugin("example_plugin", options -> new ExampleFrameProcessorPlugin());
|
||||
FrameProcessorPluginRegistry.addFrameProcessorPlugin("example_kotlin_swift_plugin", options -> new ExampleKotlinFrameProcessorPlugin());
|
||||
FrameProcessorPluginRegistry.addFrameProcessorPlugin("example_plugin", options -> new ExampleFrameProcessorPlugin(options));
|
||||
FrameProcessorPluginRegistry.addFrameProcessorPlugin("example_kotlin_swift_plugin", options -> new ExampleKotlinFrameProcessorPlugin(options));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user