# NonAI CSC Demo

## Overview

The NonAI CSC Demo integrates color-space conversion (CSC) with OSD (On-Screen Display) overlay. It demonstrates how to convert video frames through the `nonai_2d` module, dynamically overlay OSD graphics and borders before encoding, and run capture, encode, and display in a single media pipeline. The demo is suitable for embedded vision applications that require real-time video processing, graphical overlay, and encoded output.

## Functional Description

- **Color-space conversion (CSC)**: Converts input images (e.g. RGB888, YUV420) to different pixel formats (e.g. RGB565, NV12) for downstream processing or display.
- **OSD overlay**: Uses the 2D acceleration in the VENC module to insert ARGB8888 OSD layers into the H.265 stream, with configurable transparency, position, and background color.
- **Border drawing**: Draws colored borders in specified regions to highlight or mark areas of interest.
- **Multi-channel parallel processing**: Creates multiple `nonai_2d` channels for pipeline binding, RGB888 conversion, and RGB565 conversion, enabling flexible dataflow.
- **Integrated capture + encode + display**: Combines VICAP video capture, NONAI_2D processing, VENC encoding, and VO display into a complete media processing pipeline.

## Source Location

```bash
/src/rtsmart/examples/mpp/sample_csc
```

Assuming the demo has been built correctly, after booting the board navigate to `/sdcard/app/examples/mpp`. The executable is:

```bash
sample_csc.elf
```

## Usage

| Parameter | Description | Default |
|-----------|-------------|---------|
| `-o`      | Output H.265 encoded file path | — |
| `-vo`     | Display device type | — |

## Example

```bash
./sample_csc.elf -o /data/test.265 -vo 101
```

After running:

- The live camera feed is displayed on HDMI in real time.
- Starting at frame 90, the OSD and border positions are updated dynamically.
- The processed RGB888 and RGB565 frames are saved to `/data/out_2d_rgb888.rgb` and `/data/out_2d_rgb565.rgb`.
- Video is output to the specified display.
- Press `q` to quit the program.

## Viewing Results

- **Encoded stream**: Export the `.h265` file to a PC and open it with VLC or Elecard StreamEye to inspect the OSD icons and borders.
  ![265](https://www.kendryte.com/api/post/attachment?id=828)
- **Raw RGB output**: Use a raw RGB viewer (e.g. YUVPlayer with RGB mode) to load `out_2d_rgb888.rgb` (1280×720, RGB888) or `out_2d_rgb565.rgb` (1280×720, RGB565) and verify the color conversion result.
  ![RGB565](https://www.kendryte.com/api/post/attachment?id=826)
  ![RGB888](https://www.kendryte.com/api/post/attachment?id=827)

```{admonition} Note
For the specific interfaces of the `nonai_2d` module, refer to the [API Reference](../../api_reference/mpp/nonai_2d.md).
```
