# Vpp

The Virtual Projection Pattern (VPP) node adds a pattern to rectified stereo images using disparity or depth information. Its
`leftOut` and `rightOut` outputs can feed
[StereoDepth](https://docs.luxonis.com/software-v3/depthai/depthai-components/nodes/stereo_depth.md).

> **Note**
> Vpp can only run on RVC4 devices.

## Depth input on RVC4

On RVC4, VPP accepts aligned depth, for example from a
[ToF](https://docs.luxonis.com/software-v3/depthai/depthai-components/nodes/tof.md) sensor, instead of disparity. Link the depth
stream to `depth` to select depth mode.

 * Supply RAW16 depth in millimetres, aligned to the full rectified left image.
 * Preserve stereo intrinsics and extrinsics on the image frames.
 * Connect rectified images to `left` and `right`, and use either `depth` or `disparity`. Confidence input is optional.
 * Use RVC4 firmware with VPP depth-input support.

For example, with `rect` providing rectified stereo images and `align` providing ToF depth aligned to `rect.output1`:

```python
vpp = pipeline.create(dai.node.Vpp)
rect.output1.link(vpp.left)
rect.output2.link(vpp.right)
align.outputAligned.link(vpp.depth)

stereo = pipeline.create(dai.node.StereoDepth)
stereo.setRectification(False)
vpp.leftOut.link(stereo.left)
vpp.rightOut.link(stereo.right)
```

Configure the pattern using `initialConfig`, or send
[VppConfig](https://docs.luxonis.com/software-v3/depthai/depthai-components/messages/vpp_config.md) messages to `inputConfig` at
runtime.

## Examples

The ToF stereo VPP example aligns ToF depth to the rectified left image, applies VPP, and computes stereo depth from the resulting
images:

 * [Python example](https://github.com/luxonis/depthai-core/blob/main/examples/python/Vpp/tof_stereo_vpp.py)
 * [C++ example](https://github.com/luxonis/depthai-core/blob/main/examples/cpp/Vpp/tof_stereo_vpp.cpp)

## Reference

### dai::node::Vpp

Kind: class

Vpp node. Apply Virtual Projection Pattern algorithm to stereo images based on disparity or depth.

#### std::shared_ptr< VppConfig > initialConfig

Kind: variable

Initial config to use for VPP.

#### Subnode < node::Sync > sync

Kind: variable

#### Input syncedInputs

Kind: variable

Synchronised left and right images with either disparity or depth, and optional confidence.

#### const std::string leftInputName

Kind: variable

#### const std::string rightInputName

Kind: variable

#### const std::string disparityName

Kind: variable

#### const std::string depthName

Kind: variable

#### const std::string confidenceName

Kind: variable

#### Input & left

Kind: variable

Input for left rectified ImgFrame

#### Input & right

Kind: variable

Input for right rectified ImgFrame

#### Input & disparity

Kind: variable

Low resolution disparity in pixels (in integers - 16 times bigger)

#### Input & depth

Kind: variable

Depth input, used instead of disparity. Expects RAW16 millimetres aligned to the full rectified left image, with stereo intrinsics
and extrinsics on the image frames. Requires RVC4 firmware with VPP depth-input support.

#### Input & confidence

Kind: variable

Confidence of the dispatiry (in integers - 16 times bigger).

#### Input inputConfig

Kind: variable

#### Output leftOut

Kind: variable

Output ImgFrame message that carries the processed left image with virtual projection pattern applied.

#### Output rightOut

Kind: variable

Output ImgFrame message that carries the processed right image with virtual projection pattern applied.

#### Vpp()

Kind: function

#### Vpp(std::unique_ptr< Properties > props)

Kind: function

#### ~Vpp()

Kind: function

#### std::shared_ptr< Vpp > build(Output & leftInput, Output & rightInput, Output & disparityInput, Output & confidenceInput)

Kind: function

#### void buildInternal()

Kind: function

Function called from within the create function to build the node. This function is useful for initialization, setting up inputs
and outputs = stuff that cannot be perform in the constuctor.

#### void buildStage1()

Kind: function

Detect direct MessageGroup producers before pipeline transport bridges are inserted.

#### void postBuildStage()

Kind: function

#### DeviceNodeCRTP()

Kind: function

#### DeviceNodeCRTP(const std::shared_ptr< Device > & device)

Kind: function

#### DeviceNodeCRTP(std::unique_ptr< Properties > props)

Kind: function

#### DeviceNodeCRTP(std::unique_ptr< Properties > props, bool confMode)

Kind: function

#### DeviceNodeCRTP(const std::shared_ptr< Device > & device, std::unique_ptr< Properties > props, bool confMode)

Kind: function

### Need assistance?

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