# Cast

Cast Node is used to convert NNData messages to ImgFrame. This is useful in cases where applications need to use outputs from a
NeuralNetwork node to be fed into nodes that only accept ImgFrame.

## Node properties

 * outputFrameType - The type of the output frame. The type should be the same as the NN output frame type.

 * offset - The offset to be applied to the output frame. Default is 0.

 * scale - The scale factor to be applied to the output frame. Default is 1.

Offset and scale are used to define a linear transformation of the pixel values. The formula is output = input * scale + offset.

## How to place it

#### Python

```python
pipeline = dai.Pipeline()
cast = pipeline.create(dai.node.Cast)
```

#### C++

```cpp
dai::Pipeline pipeline;
auto cast = pipeline.create<dai::node::Cast>();
```

## Inputs and Outputs

## Usage

#### Python

```python
pipeline = dai.Pipeline()

nn = pipeline.create(dai.node.NeuralNetwork)
# Load a custom blob
nn.setBlobPath("path_to_blob")

cast = pipeline.create(dai.node.Cast)
cast.setOutputFrameType(dai.ImgFrame.Type.BGR888p)
cast.setScale(1)

# Link the output of NN to the input of Cast
nn.out.link(cast.input)

# Send the casted output to a host via XLink
xout = pipeline.create(dai.node.XLinkOut)
xout.setStreamName("castOut")
cast.output.link(xout.input)
```

#### C++

```cpp
dai::Pipeline pipeline;

auto nn = pipeline.create<dai::node::NeuralNetwork>();
// Load a custom blob
nn->setBlobPath("path_to_blob");

auto cast = pipeline.create<dai::node::Cast>();
cast->setOutputFrameType(dai::ImgFrame::Type::BGR888p);
cast->setScale(1);

// Link the output of NN to the input of Cast
nn->out.link(cast->input);

// Send the casted output to a host via XLink
auto xout = pipeline.create<dai::node::XLinkOut>();
xout->setStreamName("castOut");
cast->output.link(xout->input);
```

## Examples of functionality

 * [NN Blur Cast](https://docs.luxonis.com/software/depthai/examples/cast_blur.md)
 * [NN Concat Cast](https://docs.luxonis.com/software/depthai/examples/cast_concat.md)
 * [NN Subtract Cast](https://docs.luxonis.com/software/depthai/examples/cast_diff.md)

## Reference

### depthai.node.Cast(depthai.Node)

Kind: Class

Cast node.

#### setNumFramesPool(self, arg0: typing.SupportsInt) -> Cast: Cast

Kind: Method

Set number of frames in pool

Parameter ``numFramesPool``:
Number of frames in pool

#### setOffset(self, arg0: typing.SupportsFloat) -> Cast: Cast

Kind: Method

Set offset

Parameter ``offset``:
Offset

#### setOutputFrameType(self, arg0: depthai.RawImgFrame.Type) -> Cast: Cast

Kind: Method

Set output frame type

Parameter ``outputType``:
Output frame type

#### setScale(self, arg0: typing.SupportsFloat) -> Cast: Cast

Kind: Method

Set scale

Parameter ``scale``:
Scale

#### input

Kind: Property

Input NNData or ImgFrame message.

#### output

Kind: Property

Output ImgFrame message.

#### passthroughInput

Kind: Property

Passthrough input message.

### Need assistance?

Head over to [Discussion Forum](https://discuss.luxonis.com/) for technical support or any other questions you might have.
