A terminal ASCII art renderer that converts images, videos, and live camera feeds to ASCII art using OpenCV and ncurses.
- Three color modes: GRAYSCALE, COLOR_16, COLOR_256
- Three ASCII palettes: Standard (10), Balanced (20), Detailed (70)
- Three input types: static images, video files, live camera
- Two display modes: current terminal (interactive) or new terminal window (static)
- Frame-accurate video playback at original FPS
- Terminal resize handling via SIGWINCH (images in current terminal mode)
- Aspect ratio preservation for all media types
- Interactive ncurses menu with arrow key navigation
opencv2term/
βββ include/
β βββ AsciiPalette.h
β βββ AsciiRenderer.h
β βββ DisplayManager.h
β βββ MenuManager.h
β βββ ImageProcessor.h
β βββ VideoProcessor.h
β βββ CameraProcessor.h
βββ src/
β βββ main.cpp
β βββ AsciiPalette.cpp
β βββ AsciiRenderer.cpp
β βββ DisplayManager.cpp
β βββ MenuManager.cpp
β βββ ImageProcessor.cpp
β βββ VideoProcessor.cpp
β βββ CameraProcessor.cpp
βββ images/ # Input media directory (gitignored)
βββ build/ # Build artifacts (gitignored)
βββ CMakeLists.txt
βββ README.md
- CMake 3.10+
- C++17 compiler
- OpenCV 4.x
- ncurses
brew install cmake opencvmkdir -p build && cd build
cmake ..
makecd build
./OpenCVProjectMedia files must be placed in images/ relative to the project root (one level above the binary).
- Place image or video files in the
images/directory. - Run
./OpenCVProjectfrom thebuild/directory. - Follow the interactive menu:
- Select an ASCII palette
- Select a color mode
- Select media type (Image, Video, or Camera)
- Select a file (Image and Video only)
- Select a display mode
- UP/DOWN arrow keys to move
- ENTER to select
- Q to quit
| Mode | Input | Behavior |
|---|---|---|
| Current terminal | Image | Live resize on SIGWINCH, press Q or ENTER to exit |
| Current terminal | Video | Plays at original FPS, press Q or ENTER to stop |
| Current terminal | Camera | Real-time webcam feed, press Q or ENTER to stop |
| New window | Image | Opens separate terminal window, press any key to close |
| New window | Video | Opens separate terminal window, loops until Ctrl+C |
| New window | Camera | Falls back to current terminal mode |
| Name | Characters | Description |
|---|---|---|
| Standard | 10 | . : - = + * # % @ β fast, minimal |
| Balanced | 20 | Extended set with punctuation β good general purpose |
| Detailed | 70 | Full gradient β maximum shading and detail |
GRAYSCALE
- Monochrome output using brightness-mapped characters only.
- Fastest rendering, works on all terminals.
COLOR_16
- Maps each pixel's RGB values to the nearest of 16 ANSI terminal colors (colors 0-15).
- Requires a color-capable terminal.
COLOR_256
- Maps pixels to a 216-color RGB cube (colors 16-231) for finer color fidelity.
- Requires a 256-color terminal (most modern terminals qualify).
- Uses up to 256 ncurses color pairs.
All three modes use the same brightness-based character selection; color mode only affects the foreground color applied to each character.
.jpg, .png, .bmp, .gif, .tiff
.mp4, .avi, .mov, .mkv, .wmv, .flv, .webm
All formats are handled by OpenCV; actual support depends on the codecs available in your OpenCV build.
Default capture device (ID 0). Camera access requires appropriate OS permissions.
macOS: System Settings β Privacy & Security β Camera β enable Terminal.
- New palette: add to
AsciiPalette::getDefaultPalettes()insrc/AsciiPalette.cpp - New color mode: extend
AsciiRenderer::renderToMatrixWithColor()and add initialization inDisplayManager::initializeColors() - New display mode: add a method to
DisplayManager - New media type: create a new processor class following the
VideoProcessor/CameraProcessorpattern and wire it intosrc/main.cpp
- Class-based architecture with clear separation of concerns
- RAII for resource management (ncurses
endwin(), OpenCVcap.release()) - Functional callbacks (
frameProvider) passed toDisplayManager::displayVideoInTerminal() - Minimal global state
- ASCII gradient research: jp2a, aalib
- Image processing: OpenCV
- Terminal UI: ncurses