# ContoursUnit

The `ContoursUnit` class represents a unit that contains contours as intermediate results. It is derived from the `IntermediateResultUnit` class.

## Definition

*Package:* com.dynamsoft.core.intermediate_results

```java
public class ContoursUnit extends IntermediateResultUnit
```

## Methods

| Method                    | Description |
|---------------------------|---------------------------------------------|
| [`getContours`](#getcontours) | Gets the contours.  |
| [`getHierarchies`](#gethierarchies) | Gets the hierarchies.  |
| [`setContours`](#setcontours) | Sets the contours.  |

### getContours

Gets the contours.

```java
Contour[] getContours() throws CoreException
```

**Return value**

Returns the contours in the unit.

**See Also**

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

**Exception**

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

### getHierarchies

Gets the hierarchies.

```java
Vector4[] getHierarchies() throws CoreException
```

**Return value**

Returns the hierarchies of the contours in the unit.

**See Also**

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

**Exception**

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

### setContours

Sets the contours and hierarchies in the unit.

```java
void setContours(Contour[] contours, Vector4[] hierarchies) throws CoreException
void setContours(Contour[] contours, Vector4[] hierarchies, double[] matrixToOriginalImage) throws CoreException
```

**Parameters**

`contours` The contours in the unit.

`hierarchies` The hierarchies in the unit.

`matrixToOriginalImage` The transform matrix to original image.

**Exception**

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

**See Also**

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

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