# Multiple-File Processing Methods - CaptureVisionRouter Class

| Method                                                              | Description                                                                  |
| ------------------------------------------------------------------- | ---------------------------------------------------------------------------- |
| [`setInput`](#setinput)                                             | Sets an image source to provide images for consecutive processing.         |
| [`getInput`](#getinput)                                             | Gets the attached image source adapter object of the capture vision router.         |
| [`addCaptureStateListener`](#addcapturestatelistener)               | Adds an object that listens to the state changes of the capture process.     |
| [`removeCaptureStateListener`](#removecapturestatelistener)         | Removes an object which listens to the state changes of the capture process. |
| [`addImageSourceStateListener`](#addimagesourcestatelistener)       | Adds an object that listens to state changes of the image source.            |
| [`removeImageSourceStateListener`](#removeimagesourcestatelistener) | Removes an object which listens to state changes of the image source.        |
| [`addResultReceiver`](#addresultreceiver)                           | Adds an object as the receiver of captured results.                          |
| [`removeResultReceiver`](#removeresultreceiver)                     | Removes an object which was added as a receiver of captured results.         |
| [`addResultFilter`](#addresultfilter)                               | Adds an object as the filter of captured results.                          |
| [`removeResultFilter`](#removeresultfilter)                         | Removes an object which was added as a filter of captured results.         |
| [`startCapturing`](#startcapturing)                                 | Starts to process images consecutively.                                      |
| [`stopCapturing`](#stopcapturing)                                   | Stops the consecutive processing.                                          |
| [`pauseCapturing`](#pausecapturing)                                 | Pauses the capture process. The current thread will be blocked until the capture process is resumed. |
| [`resumeCapturing`](#resumecapturing)                               | Resumes the capture process. The current thread will be unblocked after the capture process is resumed. |
| [`switchCapturingTemplate`](#switchcapturingtemplate)      | Switches the capturing template during the image processing workflow.                            |

## setInput

Sets an image source to provide images for consecutive processing.

```java
public void setInput(ImageSourceAdapter pAdapter) throws CaptureVisionException
```

**Parameters**

`pAdapter` Specifies an object which has implemented the `ImageSourceAdapter` interface.

**Exceptions**

[`CaptureVisionException`](https://www.dynamsoft.com/capture-vision/docs/server/programming/java/api-reference/capture-vision-router/capture-vision-exception.md)

**See Also**

[ImageSourceAdapter](https://www.dynamsoft.com/capture-vision/docs/server/programming/java/api-reference/core/basic-classes/image-source-adapter.md)

[DirectoryFetcher](https://www.dynamsoft.com/capture-vision/docs/server/programming/java/api-reference/utility/directory-fetcher.md)

[FileFetcher](https://www.dynamsoft.com/capture-vision/docs/server/programming/java/api-reference/utility/file-fetcher.md)

## getInput

Gets the attached image source adapter object of the capture vision router. 

```java
public ImageSourceAdapter getInput()
```

**Return Value**

Returns the attached image source adapter object of the capture vision router.

**See Also**

[ImageSourceAdapter](https://www.dynamsoft.com/capture-vision/docs/server/programming/java/api-reference/core/basic-classes/image-source-adapter.md)

[DirectoryFetcher](https://www.dynamsoft.com/capture-vision/docs/server/programming/java/api-reference/utility/directory-fetcher.md)

[FileFetcher](https://www.dynamsoft.com/capture-vision/docs/server/programming/java/api-reference/utility/file-fetcher.md)

## addCaptureStateListener

Adds an object that listens to the state changes of the capture process.

```java
public void addCaptureStateListener(CaptureStateListener listener) throws CaptureVisionException
```

**Parameters**

`listener` Specifies a listening object of the type [`CaptureStateListener`](https://www.dynamsoft.com/capture-vision/docs/server/programming/java/api-reference/capture-vision-router/auxiliary-classes/capture-state-listener.md) to be added.

**Exceptions**

[`CaptureVisionException`](https://www.dynamsoft.com/capture-vision/docs/server/programming/java/api-reference/capture-vision-router/capture-vision-exception.md)

**See Also**

[CaptureStateListener](https://www.dynamsoft.com/capture-vision/docs/server/programming/java/api-reference/capture-vision-router/auxiliary-classes/capture-state-listener.md)

## removeCaptureStateListener

Removes an object which listens to the state changes of the capture process.

```java
public void removeCaptureStateListener(CaptureStateListener listener) throws CaptureVisionException
```

**Parameters**

`listener` Specifies a listening object of the type [`CaptureStateListener`](https://www.dynamsoft.com/capture-vision/docs/server/programming/java/api-reference/capture-vision-router/auxiliary-classes/capture-state-listener.md) to be removed.

**Exceptions**

[`CaptureVisionException`](https://www.dynamsoft.com/capture-vision/docs/server/programming/java/api-reference/capture-vision-router/capture-vision-exception.md)

**See Also**

[CaptureStateListener](https://www.dynamsoft.com/capture-vision/docs/server/programming/java/api-reference/capture-vision-router/auxiliary-classes/capture-state-listener.md)

## addImageSourceStateListener

Adds an object that listens to state changes of the image source.

```java
public void addImageSourceStateListener(ImageSourceStateListener listener) throws CaptureVisionException
```

**Parameters**

`listener` Specifies a listening object of the type [`ImageSourceStateListener`](https://www.dynamsoft.com/capture-vision/docs/server/programming/java/api-reference/capture-vision-router/auxiliary-classes/image-source-state-listener.md) to be added.

**Exceptions**

[`CaptureVisionException`](https://www.dynamsoft.com/capture-vision/docs/server/programming/java/api-reference/capture-vision-router/capture-vision-exception.md)

**See Also**

[ImageSourceStateListener](https://www.dynamsoft.com/capture-vision/docs/server/programming/java/api-reference/capture-vision-router/auxiliary-classes/image-source-state-listener.md)

## removeImageSourceStateListener

Removes an object which listens to state changes of the image source.

```java
public void removeImageSourceStateListener(ImageSourceStateListener listener) throws CaptureVisionException
```

**Parameters**

`listener` Specifies a listening object of the type [`ImageSourceStateListener`](https://www.dynamsoft.com/capture-vision/docs/server/programming/java/api-reference/capture-vision-router/auxiliary-classes/image-source-state-listener.md) to be removed.

**Exceptions**

[`CaptureVisionException`](https://www.dynamsoft.com/capture-vision/docs/server/programming/java/api-reference/capture-vision-router/capture-vision-exception.md)

**See Also**

[ImageSourceStateListener](https://www.dynamsoft.com/capture-vision/docs/server/programming/java/api-reference/capture-vision-router/auxiliary-classes/image-source-state-listener.md)

## addResultReceiver

Adds an object as the receiver of captured results.

```java
public void addResultReceiver(CapturedResultReceiver receiver) throws CaptureVisionException
```

**Parameters**

`receiver` Specifies a receiver object of the type [`CapturedResultReceiver`](https://www.dynamsoft.com/capture-vision/docs/server/programming/java/api-reference/capture-vision-router/auxiliary-classes/captured-result-receiver.md) to be added.

**Exceptions**

[`CaptureVisionException`](https://www.dynamsoft.com/capture-vision/docs/server/programming/java/api-reference/capture-vision-router/capture-vision-exception.md)

**See Also**

[CapturedResultReceiver](https://www.dynamsoft.com/capture-vision/docs/server/programming/java/api-reference/capture-vision-router/auxiliary-classes/captured-result-receiver.md)

## removeResultReceiver

Removes an object which was added as a receiver of captured results.

```java
public void removeResultReceiver(CapturedResultReceiver receiver) throws CaptureVisionException
```

**Parameters**

`receiver` Specifies a receiver object of the type [`CapturedResultReceiver`](https://www.dynamsoft.com/capture-vision/docs/server/programming/java/api-reference/capture-vision-router/auxiliary-classes/captured-result-receiver.md) to be removed.

**Exceptions**

[`CaptureVisionException`](https://www.dynamsoft.com/capture-vision/docs/server/programming/java/api-reference/capture-vision-router/capture-vision-exception.md)

**See Also**

[CapturedResultReceiver](https://www.dynamsoft.com/capture-vision/docs/server/programming/java/api-reference/capture-vision-router/auxiliary-classes/captured-result-receiver.md)

## addResultFilter

Adds an object as the filter of captured results.

```java
public void addResultFilter(CapturedResultFilter filter) throws CaptureVisionException
```

**Parameters**

`filter` Specifies a filter object of the type [`CapturedResultFilter`](https://www.dynamsoft.com/capture-vision/docs/server/programming/java/api-reference/capture-vision-router/auxiliary-classes/captured-result-filter.md) to be added.

**Exceptions**

[`CaptureVisionException`](https://www.dynamsoft.com/capture-vision/docs/server/programming/java/api-reference/capture-vision-router/capture-vision-exception.md)

**See Also**

[CapturedResultFilter](https://www.dynamsoft.com/capture-vision/docs/server/programming/java/api-reference/capture-vision-router/auxiliary-classes/captured-result-filter.md)

## removeResultFilter

Removes an object which was added as a filter of captured results.

```java
public void removeResultFilter(CapturedResultFilter filter)
```

**Parameters**

`filter` Specifies a filter object of the type [`CapturedResultFilter`](https://www.dynamsoft.com/capture-vision/docs/server/programming/java/api-reference/capture-vision-router/auxiliary-classes/captured-result-filter.md) to be removed.

**See Also**

[CapturedResultFilter](https://www.dynamsoft.com/capture-vision/docs/server/programming/java/api-reference/capture-vision-router/auxiliary-classes/captured-result-filter.md)

## startCapturing

Starts to process images consecutively.

```java
public CaptureVisionError startCapturing() throws CaptureVisionException
public CaptureVisionError startCapturing(String templateName, boolean waitForThreadExit) throws CaptureVisionException
```

**Parameters**

`templateName` Specifies a `CaptureVisionTemplate` to use for capturing.

`waitForThreadExit` Indicates whether to wait for the capture process to complete before returning.

**Remarks**

- There are two types of `CaptureVisionTemplate`: the [preset ones](https://www.dynamsoft.com/capture-vision/docs/server/programming/java/api-reference/capture-vision-router/enum-preset-template.md) which come with the SDK and the custom ones that get initialized when the user calls [initSettings](https://www.dynamsoft.com/capture-vision/docs/server/programming/java/api-reference/capture-vision-router/settings.md#initsettings) / [initSettingsFromFile](https://www.dynamsoft.com/capture-vision/docs/server/programming/java/api-reference/capture-vision-router/settings.md#initsettingsfromfile).
- When using a custom template, the parameter `templateName` should be the name of the [`CaptureVisionTemplate` object](https://www.dynamsoft.com/capture-vision/docs/core/parameters/reference/capture-vision-template/index.md) in the JSON template file.
- Please be aware that the preset `CaptureVisionTemplates` will be overwritten should the user call `initSettings` / `initSettingsFromFile` and pass his own settings.
- If parameter `templateName` is not specified, the preset one named 'Default' will be used. However, if the preset ones have been overwritten as described above, the first `CaptureVisionTemplate` from the user's own settings will be used instead.

**Return Value**

Returns a `CaptureVisionError` object that contains error information.

**Exceptions**

[`CaptureVisionException`](https://www.dynamsoft.com/capture-vision/docs/server/programming/java/api-reference/capture-vision-router/capture-vision-exception.md)

**See Also**

[CaptureVisionError](https://www.dynamsoft.com/capture-vision/docs/server/programming/java/api-reference/capture-vision-router/capture-vision-error.md)

## stopCapturing

Stops the multiple-file processing.

```java
public void stopCapturing()
public void stopCapturing(boolean waitForRemainingTasks, boolean waitForThreadExit)
```

**Parameters**

`waitForRemainingTasks` Indicates whether to wait for the remaining tasks to complete before returning. The default value is True.  
`waitForThreadExit` Indicates whether to wait for the capture process to complete before returning. The default value is True.

## pauseCapturing

Pauses the capture process. The current thread will be blocked until the capture process is resumed.

```java
public void pauseCapturing()
```

## resumeCapturing

Resumes the capture process. The current thread will be unblocked after the capture process is resumed.

```java
public void resumeCapturing()
```

## switchCapturingTemplate

Switches the capturing template during the image processing workflow.

```java
public void switchCapturingTemplate(String templateName) throws CaptureVisionException
```

**Parameters**

`templateName` The name of the new capturing template to apply.

**Exceptions**

[`CaptureVisionException`](https://www.dynamsoft.com/capture-vision/docs/server/programming/java/api-reference/capture-vision-router/capture-vision-exception.md)

**Remarks**

- Introduced in Dynamsoft Barcode Reader SDK version 11.2.1000 and Dynamsoft Capture Vision version 3.2.1000.
