Skip to content

Commit c0d1c47

Browse files
Merge pull request #213 from dynamsoft-docs/preview
Preview
2 parents 304b557 + f2c93e2 commit c0d1c47

20 files changed

+1532
-4
lines changed

_config.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,14 @@ cordova-api: /capture-vision/docs/mobile/programming/cordova/api-reference/
3333
cordova-release-notes: /capture-vision/docs/mobile/programming/cordova/release-notes/
3434
cordova-guide: /capture-vision/docs/mobile/programming/cordova/user-guide/
3535

36-
flutter: /capture-vision/docs/mobile/programming/flutter/
37-
flutter-api: /capture-vision/docs/mobile/programming/flutter/api-reference/
38-
flutter-release-notes: /capture-vision/docs/mobile/programming/flutter/release-notes/
39-
flutter-guide: /capture-vision/docs/mobile/programming/flutter/user-guide/
36+
dcv_flutter: /capture-vision/docs/mobile/programming/flutter/
37+
dcv_flutter_api: /capture-vision/docs/mobile/programming/flutter/api-reference/
38+
dbr_flutter: /barcode-reader/docs/mobile/programming/flutter/
39+
dbr_flutter_api: /barcode-reader/docs/mobile/programming/flutter/api-reference/
40+
dcp_flutter: /code-parser/docs/mobile/programming/flutter/
41+
dcp_flutter_api: /code-parser/docs/mobile/programming/flutter/api-reference/
42+
dce_flutter: /camera-enhancer/docs/mobile/programming/flutter/
43+
dce_flutter_api: /camera-enhancer/docs/mobile/programming/flutter/api-reference/
4044

4145
xamarin: /capture-vision/docs/mobile/programming/xamarin/
4246
xamarin-api: /capture-vision/docs/mobile/programming/xamarin/api-reference/
Lines changed: 336 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,336 @@
1+
---
2+
layout: default-layout
3+
title: CaptureVisionRouter - Dynamsoft Capture Vision Flutter
4+
description: CaptureVisionRouter class of Dynamsoft Capture Vision Router contains all of the core methods to use Dynamsoft Capture Vision.
5+
keywords: CaptureVisionRouter, Barcode Reader, capture, flutter, foundational
6+
needGenerateH3Content: true
7+
needAutoGenerateSidebar: true
8+
noTitleIndex: true
9+
breadcrumbText: CaptureVisionRouter
10+
---
11+
12+
# CaptureVisionRouter Class
13+
14+
The `CaptureVisionRouter` class defines how a user interacts with image-processing and semantic-processing Dynamsoft products in their applications.
15+
16+
A `CaptureVisionRouter` instance accepts and processes images from an image source and returns processing results which may contain final results or intermediate results. The instance can also process video frames coming from a camera or a different image source as well, therefore providing the ability to capture results via an interactive video scenario or from static images.
17+
18+
## Definition
19+
20+
*Assembly:* dynamsoft_capture_vision_flutter
21+
22+
```dart
23+
class CaptureVisionRouter
24+
```
25+
26+
## Capture Methods
27+
28+
| Method | Description |
29+
| --- | --- |
30+
| [`capture`](#capture) | Processes an image using the specified template and outputs a CapturedResult. |
31+
| [`captureFile`](#capturefile) | Processes an image from a file path using the specified template. |
32+
| [`captureFileBytes`](#capturefilebytes) | Processes an image from a byte array using the specified template. |
33+
| [`startCapturing`](#startcapturing) | Starts the capturing process using the specified template. |
34+
| [`stopCapturing`](#stopcapturing) | Stops the capturing process and closes the camera. |
35+
36+
## Settings Management Methods
37+
38+
| Method | Description |
39+
| --- | --- |
40+
| [`getSimplifiedSettings`](#getsimplifiedsettings) | Returns a subset of the full applied settings as a SimplifiedCaptureVisionSettings object. |
41+
| [`getTemplateNames`](#gettemplatenames) | Returns a list of all available Capture Vision template names. |
42+
| [`initSettings`](#initsettings) | Initializes the settings using a JSON template string. |
43+
| [`initSettingsFromFile`](#initsettingsfromfile) | Initializes the settings using a JSON template file. |
44+
| [`outputSettings`](#outputsettings) | Outputs the specified template's settings as a JSON string. |
45+
| [`outputSettingsToFile`](#outputsettingstofile) | Outputs the specified template's settings to a JSON file. |
46+
| [`resetSettings`](#resetsettings) | Resets all settings to their default values. |
47+
| [`switchCapturingTemplate`](#switchcapturingtemplate) | Switches the template used by the Capture Vision Router instance to the specified template name. |
48+
| [`updateSettings`](#updatesettings) | Updates the specified template settings using a SimplifiedCaptureVisionSettings object. |
49+
50+
## Resource Management Methods
51+
52+
| Method | Description |
53+
| --- | --- |
54+
| [`clearDLModelBuffers`](#cleardlmodelbuffers) | Clears the buffer used by deep learning models to free up memory and resources. |
55+
| [`getIntermediateResultManager`](#getintermediateresultmanager) | Retrieves the IntermediateResultManager instance which allows the user to snap the original image. |
56+
| [`setGlobalIntraOpNumThreads`](#setglobalintraopnumthreads) | Sets the global number of threads used internally by the library for model execution. |
57+
58+
## Result Management Methods
59+
60+
| Method | Description |
61+
| --- | --- |
62+
| [`addResultFilter`](#addresultfilter) | Adds a result filter to process the captured results. |
63+
| [`addResultReceiver`](#addresultreceiver) | Adds a result receiver that listens for any captured results. |
64+
| [`removeAllResultFilters`](#removeallresultfilters) | Removes all the result filters from the Capture Vision Router instance. |
65+
| [`removeAllResultReceivers`](#removeallresultreceivers) | Removes all result receivers from the Capture Vision Router instance. |
66+
| [`removeResultFilter`](#removeresultfilter) | Removes a previously added result filter. |
67+
| [`removeResultReceiver`](#removeresultreceiver) | Removes a previously added result receiver. |
68+
69+
## Input Source Methods
70+
71+
| Method | Description |
72+
| --- | --- |
73+
| [`setInput`](#setinput) | Sets up an image source to provide images for continuous processing. |
74+
75+
### addResultFilter
76+
77+
Adds a result filter to process the captured results. This filter is of type [`MultiFrameResultCrossFilter`](../utility/multi-frame-cross-filter.md).
78+
79+
```dart
80+
Future<void> addResultFilter(MultiFrameResultCrossFilter filter)
81+
```
82+
83+
**Remarks**
84+
85+
Adding a result filter is not needed for the operation of the Capture Vision Router, but it can help improve the accuracy of the results by verifying them across multiple image frames.
86+
87+
### addResultReceiver
88+
89+
Adds a result receiver that listens for any captured results. This receiver is a callback function that is triggered once a captured result is produced - whether it is successful, cancelled, or failed.
90+
91+
```dart
92+
Future<void> addResultReceiver(CapturedResultReceiver receiver)
93+
```
94+
95+
**Remarks**
96+
97+
To learn about the different result receivers that you can add, please refer to [`CapturedResultReceiver`](captured-result-receiver.md). Please note that adding a result receiver is necessary to getting the results that are produced by the Capture Vision Router instance.
98+
99+
### capture
100+
101+
Processes an image using the specified template and processes it - outputting a [`CapturedResult`](captured-result.md) containing the result(s) if there was no exception or error thrown.
102+
103+
```dart
104+
Future<CapturedResult> capture(ImageData imageData, String templateName) async
105+
```
106+
107+
**Remarks**
108+
109+
The template that is used during processing can be a preset template (one of [`EnumPresetTemplate`](../enum/preset-template.md)) or a customized JSON template that you create or that is provided to you by the Dynamsoft team. This method is to be used specifically when working with *static images*.
110+
111+
### captureFile
112+
113+
Processes an image from a file (specified by a file path) using the specified template, returning the [`CapturedResult`](captured-result.md) once the process is done.
114+
115+
```dart
116+
Future<CapturedResult> captureFile(String filePath, String templateName) async
117+
```
118+
119+
**Remarks**
120+
121+
The template that is used during processing can be a preset template (one of [`EnumPresetTemplate`](../enum/preset-template.md)) or a customized JSON template that you create or that is provided to you by the Dynamsoft team. This method is to be used specifically when working with *static images*.
122+
123+
### captureFileBytes
124+
125+
Processes an image from a byte array using the specified template, returning the [`CapturedResult`](captured-result.md) once the process is done.
126+
127+
```dart
128+
Future<CapturedResult> captureFileBytes(Uint8List bytes, String templateName) async
129+
```
130+
131+
**Remarks**
132+
133+
The template that is used during processing can be a preset template (one of [`EnumPresetTemplate`](../enum/preset-template.md)) or a customized JSON template that you create or that is provided to you by the Dynamsoft team. This method is to be used specifically when working with *static images*.
134+
135+
### clearDLModelBuffers
136+
137+
Clears the buffer used by deep learning models to free up memory and resources used by the Capture Vision Router instance for its operation.
138+
139+
```dart
140+
static Future<void> clearDLModelBuffers()
141+
```
142+
143+
### getIntermediateResultManager
144+
145+
Retrieves the [`IntermediateResultManager`](../utility/intermediate-result-manager.md) instance which allows the user to snap the original image that contains the captured result.
146+
147+
```dart
148+
IntermediateResultManager getIntermediateResultManager()
149+
```
150+
151+
**Remarks**
152+
153+
In order to get the original image that the captured result was taken from (especially in an interactive video scenario where the input is a camera feed), you will need to use the [`getOriginalImage`](../utility/intermediate-result-manager.md#getoriginalimage) method of the `IntermediateResultManager` instance.
154+
155+
### getSimplifiedSettings
156+
157+
Returns a subset of the full applied settings as a [`SimplifiedCaptureVisionSettings`](simplified-capture-vision-settings.md) object. This object contains the simplified settings of the Capture Vision Router instance, which in turn contains the simplified settings of the functional product used.
158+
159+
```dart
160+
Future<SimplifiedCaptureVisionSettings?> getSimplifiedSettings(String templateName) async
161+
```
162+
163+
**Remarks**
164+
165+
The templateName parameter represents the Capture Vision template that has been applied, whether it is a [preset template](../enum/preset-template.md) or a custom template defined in a JSON template file or string. To learn how to use the `getSimplifiedSettings`, please refer to this [section of the Foundational User Guide]({{ site.dbr_flutter }}foundational-user-guide.md#using-simplifiedcapturevisionsettings).
166+
167+
### getTemplateNames
168+
169+
Returns a list of all available Capture Vision template names when a custom template is used via [`initSettings`](#initsettings).
170+
171+
```dart
172+
Future<List<String>> getTemplateNames() async
173+
```
174+
175+
**Remarks**
176+
177+
A single template file/string can contain multiple Capture Vision templates, so this method will list each of the template(s) contained within the single template file/string. Each template can then be used with any of the capture methods, but only one at a time.
178+
179+
### initSettings
180+
181+
Initializes the settings of the `CaptureVisionRouter` instance using a JSON template (as a JSON string). To learn how to use a customized JSON template, please refer to this [section of the Foundational User Guide]({{ site.dbr_flutter }}foundational-user-guide.md#using-a-json-template).
182+
183+
```dart
184+
Future<void> initSettings(String content)
185+
```
186+
187+
> *Exception* - "Failed to initialize settings"
188+
189+
### initSettingsFromFile
190+
191+
Initializes the settings of the `CaptureVisionRouter` instance using a JSON template (as a JSON file). To learn how to use a customized JSON template, please refer to this [section of the Foundational User Guide]({{ site.dbr_flutter }}foundational-user-guide.md#using-a-json-template).
192+
193+
```dart
194+
Future<void> initSettingsFromFile(String filePath) async
195+
```
196+
197+
> *Exception* - "Failed to initialize settings from file"
198+
199+
### outputSettings
200+
201+
Outputs the specified Capture Vision template's settings as a JSON string. If `includeDefaultValues` is set to true, the output will include the default settings values.
202+
203+
```dart
204+
Future<String?> outputSettings(String templateName, bool includeDefaultValues) async
205+
```
206+
207+
> *Exception* - "Failed to output settings"
208+
209+
### outputSettingsToFile
210+
211+
Outputs the specified Capture Vision template's settings to a JSON file. If `includeDefaultValues` is set to true, the output will include the default settings values.
212+
213+
```dart
214+
Future<void> outputSettingsToFile(String templateName, String filePath, bool includeDefaultValues) async
215+
```
216+
217+
> *Exception* - "Failed to output settings to file"
218+
219+
### removeAllResultFilters
220+
221+
Removes all the result filters from the Capture Vision Router instance.
222+
223+
```dart
224+
Future<void> removeAllResultFilters()
225+
```
226+
227+
### removeAllResultReceivers
228+
229+
Removes all result receivers from the Capture Vision Router instance.
230+
231+
```dart
232+
Future<void> removeAllResultReceivers()
233+
```
234+
235+
### removeResultFilter
236+
237+
Removes a previously added result filter.
238+
239+
```dart
240+
Future<void> removeResultFilter(MultiFrameResultCrossFilter filter)
241+
```
242+
243+
### removeResultReceiver
244+
245+
Removes a previously added result receiver.
246+
247+
```dart
248+
Future<void> removeResultReceiver(CapturedResultReceiver receiver)
249+
```
250+
251+
### resetSettings
252+
253+
Resets all of the settings to their default values.
254+
255+
```dart
256+
Future<void> resetSettings() async
257+
```
258+
259+
> *Exception* - "Failed to reset settings"
260+
261+
### setGlobalIntraOpNumThreads
262+
263+
Sets the global number of threads used internally by the library for model execution. This parameter could help regulate the resources needed to operate the Capture Vision Router instance.
264+
265+
```dart
266+
static Future<void> setGlobalIntraOpNumThreads(int intraOpNumThreads)
267+
```
268+
269+
**Remarks**
270+
271+
Setting the `intraOpNumThreads` input parameter to 0 lets the system decide the optimal number of threads. The default value is 0.
272+
273+
### setInput
274+
275+
Sets up an image source to provide images for continuous processing. This method is mainly used when configuring a camera (via the [`CameraEnhancer`](../camera-enhancer/camera-enhancer.md)) as an input source.
276+
277+
```dart
278+
Future<void> setInput(ImageSourceAdapter input) async
279+
```
280+
281+
**Remarks**
282+
283+
In most cases, the `ImageSourceAdapter` that will be used is a Camera Enhancer ([`CameraEnhancer`](../camera-enhancer/camera-enhancer.md)) instance to allow the user to use their phone's built-in camera.
284+
285+
> *Exception* - "Failed to set input"
286+
287+
### startCapturing
288+
289+
Starts the capturing process using the specified template. Any result(s) (of type [`CapturedResult`](captured-result.md)) that are received while the capture process is underway will be relayed by a result receiver, which is a callback function that is triggered once a captured result is found.
290+
291+
```dart
292+
Future<void> startCapturing(String templateName)
293+
```
294+
295+
**Remarks**
296+
297+
The template that is used during processing can be a preset template (one of [`EnumPresetTemplate`](../enum/preset-template.md)) or a customized JSON template that you create or that is provided to you by the Dynamsoft team.
298+
299+
> *Exception* - "Failed to start capturing"
300+
301+
### stopCapturing
302+
303+
Stops the capturing process and closes the camera.
304+
305+
```dart
306+
Future<void> stopCapturing()
307+
```
308+
309+
### switchCapturingTemplate
310+
311+
Switched the template used by the Capture Vision Router instance to the specified template name.
312+
313+
```dart
314+
Future<void> switchCapturingTemplate(String templateName) async
315+
```
316+
317+
**Remarks**
318+
319+
For the `templateName` input parameter, this can be either the name of the `CaptureVisionTemplate` in a custom JSON template file/string or the name of one of the preset templates available via [`EnumPresetTemplate`](../enum/preset-template.md).
320+
321+
> *Exception* - "Failed to switch template"
322+
323+
### updateSettings
324+
325+
Updates the specified template settings of the `CaptureVisionRouter` instance using a [`SimplifiedCaptureVisionSettings`](simplified-capture-vision-settings.md) object. To learn how to update the settings using the SimplifiedCaptureVisionSettings class - please refer to this [section of the Foundational User Guide]({{ site.dbr_flutter }}foundational-user-guide.md#using-simplifiedcapturevisionsettings).
326+
327+
```dart
328+
Future<void> updateSettings(String templateName, SimplifiedCaptureVisionSettings settings)
329+
```
330+
331+
**Remarks**
332+
333+
For the `templateName` input parameter, this can be either the name of the `CaptureVisionTemplate` in a custom JSON template file/string or the name of one of the preset templates available via [`EnumPresetTemplate`](../enum/preset-template.md).
334+
335+
> *Exception* - "Failed to update settings"
336+

0 commit comments

Comments
 (0)