Skip to content

Commit f7a5130

Browse files
authored
docs: OCR standarization of variable naming (#523)
## Description <!-- Provide a concise and descriptive summary of the changes implemented in this PR. --> ### Introduces a breaking change? - [ ] Yes - [ ] No ### Type of change - [ ] Bug fix (change which fixes an issue) - [ ] New feature (change which adds functionality) - [ ] Documentation update (improves or adds clarity to existing documentation) - [ ] Other (chores, tests, code style improvements etc.) ### Tested on - [ ] iOS - [ ] Android ### Testing instructions <!-- Provide step-by-step instructions on how to test your changes. Include setup details if necessary. --> ### Screenshots <!-- Add screenshots here, if applicable --> ### Related issues <!-- Link related issues here using #issue-number --> ### Checklist - [ ] I have performed a self-review of my code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have updated the documentation accordingly - [ ] My changes generate no new warnings ### Additional notes <!-- Include any additional information, assumptions, or context that reviewers might need to understand this PR. -->
1 parent e9d0a9e commit f7a5130

10 files changed

Lines changed: 26 additions & 26 deletions

File tree

docs/docs/02-hooks/02-computer-vision/useOCR.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,13 @@ For more information on loading resources, take a look at [loading models](../..
134134

135135
The hook returns an object with the following properties:
136136

137-
| Field | Type | Description |
138-
| ------------------ | -------------------------------------------- | ------------------------------------------------------------------------------------------- |
139-
| `forward` | `(input: string) => Promise<OCRDetection[]>` | A function that accepts an image (url, b64) and returns an array of `OCRDetection` objects. |
140-
| `error` | <code>string &#124; null</code> | Contains the error message if the model loading failed. |
141-
| `isGenerating` | `boolean` | Indicates whether the model is currently processing an inference. |
142-
| `isReady` | `boolean` | Indicates whether the model has successfully loaded and is ready for inference. |
143-
| `downloadProgress` | `number` | Represents the download progress as a value between 0 and 1. |
137+
| Field | Type | Description |
138+
| ------------------ | -------------------------------------------------- | ------------------------------------------------------------------------------------------- |
139+
| `forward` | `(imageSource: string) => Promise<OCRDetection[]>` | A function that accepts an image (url, b64) and returns an array of `OCRDetection` objects. |
140+
| `error` | <code>string &#124; null</code> | Contains the error message if the model loading failed. |
141+
| `isGenerating` | `boolean` | Indicates whether the model is currently processing an inference. |
142+
| `isReady` | `boolean` | Indicates whether the model has successfully loaded and is ready for inference. |
143+
| `downloadProgress` | `number` | Represents the download progress as a value between 0 and 1. |
144144

145145
## Running the model
146146

docs/docs/02-hooks/02-computer-vision/useVerticalOCR.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,13 @@ For more information on loading resources, take a look at [loading models](../..
147147

148148
The hook returns an object with the following properties:
149149

150-
| Field | Type | Description |
151-
| ------------------ | -------------------------------------------- | ------------------------------------------------------------------------------------------- |
152-
| `forward` | `(input: string) => Promise<OCRDetection[]>` | A function that accepts an image (url, b64) and returns an array of `OCRDetection` objects. |
153-
| `error` | <code>string &#124; null</code> | Contains the error message if the model loading failed. |
154-
| `isGenerating` | `boolean` | Indicates whether the model is currently processing an inference. |
155-
| `isReady` | `boolean` | Indicates whether the model has successfully loaded and is ready for inference. |
156-
| `downloadProgress` | `number` | Represents the download progress as a value between 0 and 1. |
150+
| Field | Type | Description |
151+
| ------------------ | -------------------------------------------------- | ------------------------------------------------------------------------------------------- |
152+
| `forward` | `(imageSource: string) => Promise<OCRDetection[]>` | A function that accepts an image (url, b64) and returns an array of `OCRDetection` objects. |
153+
| `error` | <code>string &#124; null</code> | Contains the error message if the model loading failed. |
154+
| `isGenerating` | `boolean` | Indicates whether the model is currently processing an inference. |
155+
| `isReady` | `boolean` | Indicates whether the model has successfully loaded and is ready for inference. |
156+
| `downloadProgress` | `number` | Represents the download progress as a value between 0 and 1. |
157157

158158
## Running the model
159159

docs/docs/03-typescript-api/02-computer-vision/OCRModule.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const detections = await ocrModule.forward(imageUri);
2525
| Method | Type | Description |
2626
| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
2727
| `load` | `(model: { detectorSource: ResourceSource; recognizerLarge: ResourceSource; recognizerMedium: ResourceSource; recognizerSmall: ResourceSource; language: OCRLanguage }, onDownloadProgressCallback?: (progress: number) => void): Promise<void>` | Loads the model, where `detectorSource` is a string that specifies the location of the detector binary, `recognizerLarge` is a string that specifies the location of the recognizer binary file which accepts input images with a width of 512 pixels, `recognizerMedium` is a string that specifies the location of the recognizer binary file which accepts input images with a width of 256 pixels, `recognizerSmall` is a string that specifies the location of the recognizer binary file which accepts input images with a width of 128 pixels, and `language` is a parameter that specifies the language of the text to be recognized by the OCR. |
28-
| `forward` | `(input: string): Promise<OCRDetections[]>` | Executes the model's forward pass, where `input` can be a fetchable resource or a Base64-encoded string. |
28+
| `forward` | `(imageSource: string): Promise<OCRDetections[]>` | Executes the model's forward pass, where `imageSource` can be a fetchable resource or a Base64-encoded string. |
2929
| `delete` | `(): void` | Release the memory held by the module. Calling `forward` afterwards is invalid. Note that you cannot delete model while it's generating. |
3030

3131
<details>

docs/docs/03-typescript-api/02-computer-vision/VerticalOCRModule.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const detections = await verticalOCRModule.forward(imageUri);
2929
| Method | Type | Description |
3030
| --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
3131
| `load` | `(model: { detectorLarge: ResourceSource; detectorNarrow: ResourceSource; recognizerLarge: ResourceSource; recognizerSmall: ResourceSource; language: OCRLanguage }, independentCharacters: boolean, onDownloadProgressCallback?: (progress: number) => void): Promise<void>` | Loads the model, where `detectorLarge` is a string that specifies the location of the recognizer binary file which accepts input images with a width of 1280 pixels, `detectorNarrow` is a string that specifies the location of the detector binary file which accepts input images with a width of 320 pixels, `recognizerLarge` is a string that specifies the location of the recognizer binary file which accepts input images with a width of 512 pixels, `recognizerSmall` is a string that specifies the location of the recognizer binary file which accepts input images with a width of 64 pixels, and `language` is a parameter that specifies the language of the text to be recognized by the OCR. |
32-
| `forward` | `(input: string): Promise<OCRDetections[]>` | Executes the model's forward pass, where `input` can be a fetchable resource or a Base64-encoded string. |
32+
| `forward` | `(imageSource: string): Promise<OCRDetections[]>` | Executes the model's forward pass, where `imageSource` can be a fetchable resource or a Base64-encoded string. |
3333
| `delete` | `(): void` | Release the memory held by the module. Calling `forward` afterwards is invalid. Note that you cannot delete model while it's generating. |
3434

3535
<details>

packages/react-native-executorch/src/controllers/OCRController.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export class OCRController {
7272
}
7373
};
7474

75-
public forward = async (input: string) => {
75+
public forward = async (imageSource: string) => {
7676
if (!this.isReady) {
7777
throw new Error(getError(ETError.ModuleNotLoaded));
7878
}
@@ -83,7 +83,7 @@ export class OCRController {
8383
try {
8484
this.isGenerating = true;
8585
this.isGeneratingCallback(this.isGenerating);
86-
return await this.nativeModule.generate(input);
86+
return await this.nativeModule.generate(imageSource);
8787
} catch (e) {
8888
throw new Error(getError(e));
8989
} finally {

packages/react-native-executorch/src/controllers/VerticalOCRController.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export class VerticalOCRController {
8080
}
8181
};
8282

83-
public forward = async (input: string) => {
83+
public forward = async (imageSource: string) => {
8484
if (!this.isReady) {
8585
throw new Error(getError(ETError.ModuleNotLoaded));
8686
}
@@ -91,7 +91,7 @@ export class VerticalOCRController {
9191
try {
9292
this.isGenerating = true;
9393
this.isGeneratingCallback(this.isGenerating);
94-
return await this.ocrNativeModule.generate(input);
94+
return await this.ocrNativeModule.generate(imageSource);
9595
} catch (e) {
9696
throw new Error(getError(e));
9797
} finally {

packages/react-native-executorch/src/hooks/computer_vision/useOCR.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ interface OCRModule {
77
error: string | null;
88
isReady: boolean;
99
isGenerating: boolean;
10-
forward: (input: string) => Promise<OCRDetection[]>;
10+
forward: (imageSource: string) => Promise<OCRDetection[]>;
1111
downloadProgress: number;
1212
}
1313

packages/react-native-executorch/src/hooks/computer_vision/useVerticalOCR.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ interface OCRModule {
77
error: string | null;
88
isReady: boolean;
99
isGenerating: boolean;
10-
forward: (input: string) => Promise<OCRDetection[]>;
10+
forward: (imageSource: string) => Promise<OCRDetection[]>;
1111
downloadProgress: number;
1212
}
1313

packages/react-native-executorch/src/modules/computer_vision/OCRModule.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ export class OCRModule {
3131
);
3232
}
3333

34-
async forward(input: string) {
35-
return await this.controller.forward(input);
34+
async forward(imageSource: string) {
35+
return await this.controller.forward(imageSource);
3636
}
3737

3838
delete() {

packages/react-native-executorch/src/modules/computer_vision/VerticalOCRModule.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ export class VerticalOCRModule {
3535
);
3636
}
3737

38-
async forward(input: string) {
39-
return await this.controller.forward(input);
38+
async forward(imageSource: string) {
39+
return await this.controller.forward(imageSource);
4040
}
4141

4242
delete() {

0 commit comments

Comments
 (0)