Skip to content

Commit fd5aca7

Browse files
docs: add correct api references
1 parent 3aa0f89 commit fd5aca7

15 files changed

+1070
-111
lines changed

docs/docs/06-api-reference/classes/ClassificationModule.md

Lines changed: 84 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,87 @@ Module for image classification tasks.
2424

2525
## Properties
2626

27+
### generateFromFrame()
28+
29+
> **generateFromFrame**: (`frameData`, ...`args`) => `any`
30+
31+
Defined in: [modules/BaseModule.ts:56](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/BaseModule.ts#L56)
32+
33+
Process a camera frame directly for real-time inference.
34+
35+
This method is bound to a native JSI function after calling `load()`,
36+
making it worklet-compatible and safe to call from VisionCamera's
37+
frame processor thread.
38+
39+
**Performance characteristics:**
40+
41+
- **Zero-copy path**: When using `frame.getNativeBuffer()` from VisionCamera v5,
42+
frame data is accessed directly without copying (fastest, recommended).
43+
- **Copy path**: When using `frame.toArrayBuffer()`, pixel data is copied
44+
from native to JS, then accessed from native code (slower, fallback).
45+
46+
**Usage with VisionCamera:**
47+
48+
```typescript
49+
const frameOutput = useFrameOutput({
50+
pixelFormat: 'rgb',
51+
onFrame(frame) {
52+
'worklet';
53+
// Zero-copy approach (recommended)
54+
const nativeBuffer = frame.getNativeBuffer();
55+
const result = model.generateFromFrame(
56+
{
57+
nativeBuffer: nativeBuffer.pointer,
58+
width: frame.width,
59+
height: frame.height,
60+
},
61+
...args
62+
);
63+
nativeBuffer.release();
64+
frame.dispose();
65+
},
66+
});
67+
```
68+
69+
#### Parameters
70+
71+
##### frameData
72+
73+
[`Frame`](../interfaces/Frame.md)
74+
75+
Frame data object with either nativeBuffer (zero-copy) or data (ArrayBuffer)
76+
77+
##### args
78+
79+
...`any`[]
80+
81+
Additional model-specific arguments (e.g., threshold, options)
82+
83+
#### Returns
84+
85+
`any`
86+
87+
Model-specific output (e.g., detections, classifications, embeddings)
88+
89+
#### See
90+
91+
[Frame](../interfaces/Frame.md) for frame data format details
92+
93+
#### Inherited from
94+
95+
`BaseModule.generateFromFrame`
96+
97+
---
98+
2799
### nativeModule
28100

29101
> **nativeModule**: `any` = `null`
30102
31-
Defined in: [modules/BaseModule.ts:8](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/BaseModule.ts#L8)
103+
Defined in: [modules/BaseModule.ts:17](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/BaseModule.ts#L17)
104+
105+
**`Internal`**
32106

33-
Native module instance
107+
Native module instance (JSI Host Object)
34108

35109
#### Inherited from
36110

@@ -42,9 +116,11 @@ Native module instance
42116

43117
> **delete**(): `void`
44118
45-
Defined in: [modules/BaseModule.ts:41](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/BaseModule.ts#L41)
119+
Defined in: [modules/BaseModule.ts:100](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/BaseModule.ts#L100)
46120

47-
Unloads the model from memory.
121+
Unloads the model from memory and releases native resources.
122+
123+
Always call this method when you're done with a model to prevent memory leaks.
48124

49125
#### Returns
50126

@@ -84,7 +160,9 @@ The classification result.
84160

85161
> `protected` **forwardET**(`inputTensor`): `Promise`\<[`TensorPtr`](../interfaces/TensorPtr.md)[]\>
86162
87-
Defined in: [modules/BaseModule.ts:23](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/BaseModule.ts#L23)
163+
Defined in: [modules/BaseModule.ts:80](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/BaseModule.ts#L80)
164+
165+
**`Internal`**
88166

89167
Runs the model's forward method with the given input tensors.
90168
It returns the output tensors that mimic the structure of output from ExecuTorch.
@@ -113,7 +191,7 @@ Array of output tensors.
113191

114192
> **getInputShape**(`methodName`, `index`): `Promise`\<`number`[]\>
115193
116-
Defined in: [modules/BaseModule.ts:34](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/BaseModule.ts#L34)
194+
Defined in: [modules/BaseModule.ts:91](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/BaseModule.ts#L91)
117195

118196
Gets the input shape for a given method and index.
119197

docs/docs/06-api-reference/classes/ExecutorchModule.md

Lines changed: 84 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,87 @@ General module for executing custom Executorch models.
2424

2525
## Properties
2626

27+
### generateFromFrame()
28+
29+
> **generateFromFrame**: (`frameData`, ...`args`) => `any`
30+
31+
Defined in: [modules/BaseModule.ts:56](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/BaseModule.ts#L56)
32+
33+
Process a camera frame directly for real-time inference.
34+
35+
This method is bound to a native JSI function after calling `load()`,
36+
making it worklet-compatible and safe to call from VisionCamera's
37+
frame processor thread.
38+
39+
**Performance characteristics:**
40+
41+
- **Zero-copy path**: When using `frame.getNativeBuffer()` from VisionCamera v5,
42+
frame data is accessed directly without copying (fastest, recommended).
43+
- **Copy path**: When using `frame.toArrayBuffer()`, pixel data is copied
44+
from native to JS, then accessed from native code (slower, fallback).
45+
46+
**Usage with VisionCamera:**
47+
48+
```typescript
49+
const frameOutput = useFrameOutput({
50+
pixelFormat: 'rgb',
51+
onFrame(frame) {
52+
'worklet';
53+
// Zero-copy approach (recommended)
54+
const nativeBuffer = frame.getNativeBuffer();
55+
const result = model.generateFromFrame(
56+
{
57+
nativeBuffer: nativeBuffer.pointer,
58+
width: frame.width,
59+
height: frame.height,
60+
},
61+
...args
62+
);
63+
nativeBuffer.release();
64+
frame.dispose();
65+
},
66+
});
67+
```
68+
69+
#### Parameters
70+
71+
##### frameData
72+
73+
[`Frame`](../interfaces/Frame.md)
74+
75+
Frame data object with either nativeBuffer (zero-copy) or data (ArrayBuffer)
76+
77+
##### args
78+
79+
...`any`[]
80+
81+
Additional model-specific arguments (e.g., threshold, options)
82+
83+
#### Returns
84+
85+
`any`
86+
87+
Model-specific output (e.g., detections, classifications, embeddings)
88+
89+
#### See
90+
91+
[Frame](../interfaces/Frame.md) for frame data format details
92+
93+
#### Inherited from
94+
95+
`BaseModule.generateFromFrame`
96+
97+
---
98+
2799
### nativeModule
28100

29101
> **nativeModule**: `any` = `null`
30102
31-
Defined in: [modules/BaseModule.ts:8](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/BaseModule.ts#L8)
103+
Defined in: [modules/BaseModule.ts:17](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/BaseModule.ts#L17)
104+
105+
**`Internal`**
32106

33-
Native module instance
107+
Native module instance (JSI Host Object)
34108

35109
#### Inherited from
36110

@@ -42,9 +116,11 @@ Native module instance
42116

43117
> **delete**(): `void`
44118
45-
Defined in: [modules/BaseModule.ts:41](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/BaseModule.ts#L41)
119+
Defined in: [modules/BaseModule.ts:100](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/BaseModule.ts#L100)
46120

47-
Unloads the model from memory.
121+
Unloads the model from memory and releases native resources.
122+
123+
Always call this method when you're done with a model to prevent memory leaks.
48124

49125
#### Returns
50126

@@ -85,7 +161,9 @@ An array of output tensor pointers.
85161

86162
> `protected` **forwardET**(`inputTensor`): `Promise`\<[`TensorPtr`](../interfaces/TensorPtr.md)[]\>
87163
88-
Defined in: [modules/BaseModule.ts:23](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/BaseModule.ts#L23)
164+
Defined in: [modules/BaseModule.ts:80](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/BaseModule.ts#L80)
165+
166+
**`Internal`**
89167

90168
Runs the model's forward method with the given input tensors.
91169
It returns the output tensors that mimic the structure of output from ExecuTorch.
@@ -114,7 +192,7 @@ Array of output tensors.
114192

115193
> **getInputShape**(`methodName`, `index`): `Promise`\<`number`[]\>
116194
117-
Defined in: [modules/BaseModule.ts:34](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/BaseModule.ts#L34)
195+
Defined in: [modules/BaseModule.ts:91](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/BaseModule.ts#L91)
118196

119197
Gets the input shape for a given method and index.
120198

docs/docs/06-api-reference/classes/ImageEmbeddingsModule.md

Lines changed: 84 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,87 @@ Module for generating image embeddings from input images.
2424

2525
## Properties
2626

27+
### generateFromFrame()
28+
29+
> **generateFromFrame**: (`frameData`, ...`args`) => `any`
30+
31+
Defined in: [modules/BaseModule.ts:56](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/BaseModule.ts#L56)
32+
33+
Process a camera frame directly for real-time inference.
34+
35+
This method is bound to a native JSI function after calling `load()`,
36+
making it worklet-compatible and safe to call from VisionCamera's
37+
frame processor thread.
38+
39+
**Performance characteristics:**
40+
41+
- **Zero-copy path**: When using `frame.getNativeBuffer()` from VisionCamera v5,
42+
frame data is accessed directly without copying (fastest, recommended).
43+
- **Copy path**: When using `frame.toArrayBuffer()`, pixel data is copied
44+
from native to JS, then accessed from native code (slower, fallback).
45+
46+
**Usage with VisionCamera:**
47+
48+
```typescript
49+
const frameOutput = useFrameOutput({
50+
pixelFormat: 'rgb',
51+
onFrame(frame) {
52+
'worklet';
53+
// Zero-copy approach (recommended)
54+
const nativeBuffer = frame.getNativeBuffer();
55+
const result = model.generateFromFrame(
56+
{
57+
nativeBuffer: nativeBuffer.pointer,
58+
width: frame.width,
59+
height: frame.height,
60+
},
61+
...args
62+
);
63+
nativeBuffer.release();
64+
frame.dispose();
65+
},
66+
});
67+
```
68+
69+
#### Parameters
70+
71+
##### frameData
72+
73+
[`Frame`](../interfaces/Frame.md)
74+
75+
Frame data object with either nativeBuffer (zero-copy) or data (ArrayBuffer)
76+
77+
##### args
78+
79+
...`any`[]
80+
81+
Additional model-specific arguments (e.g., threshold, options)
82+
83+
#### Returns
84+
85+
`any`
86+
87+
Model-specific output (e.g., detections, classifications, embeddings)
88+
89+
#### See
90+
91+
[Frame](../interfaces/Frame.md) for frame data format details
92+
93+
#### Inherited from
94+
95+
`BaseModule.generateFromFrame`
96+
97+
---
98+
2799
### nativeModule
28100

29101
> **nativeModule**: `any` = `null`
30102
31-
Defined in: [modules/BaseModule.ts:8](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/BaseModule.ts#L8)
103+
Defined in: [modules/BaseModule.ts:17](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/BaseModule.ts#L17)
104+
105+
**`Internal`**
32106

33-
Native module instance
107+
Native module instance (JSI Host Object)
34108

35109
#### Inherited from
36110

@@ -42,9 +116,11 @@ Native module instance
42116

43117
> **delete**(): `void`
44118
45-
Defined in: [modules/BaseModule.ts:41](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/BaseModule.ts#L41)
119+
Defined in: [modules/BaseModule.ts:100](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/BaseModule.ts#L100)
46120

47-
Unloads the model from memory.
121+
Unloads the model from memory and releases native resources.
122+
123+
Always call this method when you're done with a model to prevent memory leaks.
48124

49125
#### Returns
50126

@@ -84,7 +160,9 @@ A Float32Array containing the image embeddings.
84160

85161
> `protected` **forwardET**(`inputTensor`): `Promise`\<[`TensorPtr`](../interfaces/TensorPtr.md)[]\>
86162
87-
Defined in: [modules/BaseModule.ts:23](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/BaseModule.ts#L23)
163+
Defined in: [modules/BaseModule.ts:80](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/BaseModule.ts#L80)
164+
165+
**`Internal`**
88166

89167
Runs the model's forward method with the given input tensors.
90168
It returns the output tensors that mimic the structure of output from ExecuTorch.
@@ -113,7 +191,7 @@ Array of output tensors.
113191

114192
> **getInputShape**(`methodName`, `index`): `Promise`\<`number`[]\>
115193
116-
Defined in: [modules/BaseModule.ts:34](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/BaseModule.ts#L34)
194+
Defined in: [modules/BaseModule.ts:91](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/BaseModule.ts#L91)
117195

118196
Gets the input shape for a given method and index.
119197

0 commit comments

Comments
 (0)