Skip to content

bluevisor/terminal-cam

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

terminal-cam

Live webcam → ASCII art in your terminal. 95-char density ramp, truecolor output, painterly color styles, optional solid-block rendering, and a few fractal-driven psychedelic modes.

styles render rust license

Install

cargo install --git https://github.com/bluevisor/terminal-cam

or clone and run:

git clone https://github.com/bluevisor/terminal-cam
cd terminal-cam
cargo run --release

macOS will prompt for camera permission on first launch — grant it to your terminal application.

Controls

Key Action
Esc Open / close menu
Select menu item
Change value
Enter Apply / advance
q / Ctrl-C Quit

Options

  • Camera source — cycle detected cameras
  • StyleColor, B&W, Sepia, Van Gogh, Monet, Mushroom, LSD
    • Van Gogh — static palette snap. Source hue picks one of three ramps (cool / warm / green), source luma picks the anchor within it. Hand-curated from Starry Night, Irises, and the self-portrait.
    • Monet — pastelized HSV with a slow dappled-light mottle and atmospheric warm/cool shift.
    • Mushroom — radial mandala (concentric rings + 6-fold angular petals) plus a slow-drifting Julia-set iteration field.
    • LSD — Julia-set iteration count drives hue rotation; the c-parameter drifts slowly so the fractal morphs through related shapes.
  • Render modeASCII (density-ramp glyphs) or Blocks (solid in color styles so the color escape alone carries the image; ░▒▓█ shading ramp in B&W).
  • Color depthauto / truecolor / 256 / 16. Auto-detects from COLORTERM; falls back to 256-color for terminals that don't speak 24-bit.
  • Mirror — horizontal flip (on by default; webcams are usually mirrored).
  • Brightness-1.00 to +1.00, added to each RGB channel pre-style.
  • Contrast0.1 to 3.0. Applied to RGB upstream (not just to glyph density) so it affects the emitted color, Van Gogh palette-band selection, and Mushroom / LSD HSV value.

Terminal compatibility

Terminal Auto-detects as
iTerm2, Warp, Kitty, Alacritty, Ghostty, WezTerm, VS Code truecolor
Apple Terminal.app 256
anything with TERM=*-256color 256

If colors look wrong, the terminal probably doesn't support truecolor — open the menu and set Color depth to 256. The image will show some banding but the colors will be correct.

How it works

Per terminal cell, every frame:

  1. Average RGB over the source block.
  2. Add brightness offset, apply contrast stretch around mid-gray (128).
  3. Run the style transform. Palette / fractal styles produce new RGB from source luma + hue (Van Gogh), HSV rotation (Monet / Mushroom / LSD), or an affine matrix (Sepia).
  4. Recompute luminance from the stylized RGB.
  5. Pick a glyph:
    • ASCII: sigmoid-shaped luma indexes the 95-char density ramp.
    • Blocks (color): solid — color escape carries brightness.
    • Blocks (B&W): ░▒▓█ shading ramp, since there's no color channel.
  6. Quantize the fg color to the selected depth (truecolor / 256-palette / ANSI-16) and emit the escape + glyph.

Each frame is wrapped in DEC 2026 synchronized-update markers (\x1b[?2026h / \x1b[?2026l) so supporting terminals paint atomically. The options overlay is composed into the same byte buffer as the render and flushed in one write — no camera-flash-behind-menu flicker.

Aspect ratio is preserved via center-crop: the source is cropped to match the terminal grid's pixel canvas (cols : rows × CHAR_ASPECT) so faces don't squash or stretch as you resize the window.

Project structure

  • src/main.rs — input loop, terminal mode setup, frame pacing
  • src/camera.rsnokhwa capture thread + shared frame slot
  • src/render.rs — per-cell render pipeline, config, synchronized output
  • src/style.rs — style transforms (Sepia / Van Gogh / Monet / Mushroom / LSD) and the Julia-set iteration helper
  • src/color.rs — depth detection + truecolor / 256 / ANSI-16 quantization
  • src/ascii.rs — 95-char density ramp and 5-stop shading ramp
  • src/menu.rs — centered options overlay (half-block title, version footer, rendered into the render buffer so it composites atomically)

Tuning

The terminal cell aspect ratio (CHAR_ASPECT = 2.0 in src/render.rs) is the one font-dependent constant. If circles render as horizontal ovals, bump it; if vertical ovals, drop it. iTerm2 / Terminal.app / Kitty with default fonts are all close to 2.0.

Van Gogh's three palette ramps live at the top of src/style.rs as VG_COOL / VG_WARM / VG_GREEN. Each is a 5-anchor ramp (dark → light); swap in your own anchors for a different painter.

Mushroom and LSD's Julia c parameter drifts on a small loop — tune speed, amplitude, and center in mushroom() / lsd() in src/style.rs to explore different regions of the fractal parameter space.

Stack

License

MIT — see LICENSE.

About

ASCII-art webcam viewer for your terminal — Rust, 95-char density ramp, painterly color styles

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages