docs: Fix highlight

This commit is contained in:
Marc Rousavy 2023-09-27 12:15:42 +02:00
parent 4830ba8bf6
commit bb7549bc01
2 changed files with 15 additions and 11 deletions

View File

@ -69,10 +69,6 @@ public class FaceDetectorFrameProcessorPlugin extends FrameProcessorPlugin {
}
```
:::note
The Frame Processor Plugin will be exposed to JS through the `VisionCameraProxy` object. In this case, it would be `VisionCameraProxy.getFrameProcessorPlugin("detectFaces")`.
:::
4. **Implement your Frame Processing.** See the [Example Plugin (Java)](https://github.com/mrousavy/react-native-vision-camera/blob/main/package/example/android/app/src/main/java/com/mrousavy/camera/example/ExampleFrameProcessorPlugin.java) for reference.
5. Create a new Java file which registers the Frame Processor Plugin in a React Package, for the Face Detector plugin this file will be called `FaceDetectorFrameProcessorPluginPackage.java`:
@ -106,6 +102,10 @@ public class FaceDetectorFrameProcessorPluginPackage implements ReactPackage {
}
```
:::note
The Frame Processor Plugin will be exposed to JS through the `VisionCameraProxy` object. In this case, it would be `VisionCameraProxy.getFrameProcessorPlugin("detectFaces")`.
:::
6. Register the package in MainApplication.java
```java
@ -140,10 +140,6 @@ class FaceDetectorFrameProcessorPlugin: FrameProcessorPlugin() {
}
```
:::note
The Frame Processor Plugin will be exposed to JS through the `VisionCameraProxy` object. In this case, it would be `VisionCameraProxy.getFrameProcessorPlugin("detectFaces")`.
:::
4. **Implement your Frame Processing.** See the [Example Plugin (Java)](https://github.com/mrousavy/react-native-vision-camera/blob/main/package/example/android/app/src/main/java/com/mrousavy/camera/example/ExampleFrameProcessorPlugin.java) for reference.
5. Create a new Kotlin file which registers the Frame Processor Plugin in a React Package, for the Face Detector plugin this file will be called `FaceDetectorFrameProcessorPluginPackage.kt`:
@ -173,6 +169,10 @@ class FaceDetectorFrameProcessorPluginPackage : ReactPackage {
}
```
:::note
The Frame Processor Plugin will be exposed to JS through the `VisionCameraProxy` object. In this case, it would be `VisionCameraProxy.getFrameProcessorPlugin("detectFaces")`.
:::
6. Register the package in MainApplication.java
```java

View File

@ -64,10 +64,12 @@ For reference see the [CLI's docs](https://github.com/mateusz1913/vision-camera-
}
+ (void) load {
// highlight-start
[FrameProcessorPluginRegistry addFrameProcessorPlugin:@"detectFaces"
withInitializer:^FrameProcessorPlugin*(NSDictionary* options) {
return [[FaceDetectorFrameProcessorPlugin alloc] initWithOptions:options];
}];
// highlight-end
}
@end
@ -99,7 +101,9 @@ The Frame Processor Plugin will be exposed to JS through the `VisionCameraProxy`
```swift
@objc(FaceDetectorFrameProcessorPlugin)
public class FaceDetectorFrameProcessorPlugin: FrameProcessorPlugin {
public override func callback(_ frame: Frame!, withArguments arguments: [String:Any]) -> Any {
public override func callback(_ frame: Frame!,
withArguments arguments: [String:Any]) -> Any {
let buffer = frame.buffer
let orientation = frame.orientation
// code goes here
@ -123,12 +127,12 @@ public class FaceDetectorFrameProcessorPlugin: FrameProcessorPlugin {
{
// ...
// hightlight-start
// highlight-start
[FrameProcessorPluginRegistry addFrameProcessorPlugin:@"detectFaces"
withInitializer:^FrameProcessorPlugin*(NSDictionary* options) {
return [[FaceDetectorFrameProcessorPlugin alloc] initWithOptions:options];
}];
// hightlight-end
// highlight-end
return [super application:application didFinishLaunchingWithOptions:launchOptions];
}