跳到正文
网页珍奇柜Web Curio

字符摄像头

ASCII Camera,Andrei Gheorghe,2013 年

正在布展…

原作直展:这是 Andrei Gheorghe 的原始作品,按 MIT 许可证收录(版本 ecafefb)。原作原样展出;本柜的兼容层把它用的旧摄像头接口接到新接口上。浏览器会先询问是否允许使用摄像头,画面只在你的浏览器里处理,不会上传。 许可证全文 · 收录说明

它是怎么做的

  1. 第 1 步getUserMedia 获取视频流,绘制到小尺寸隐藏 canvas
  2. 第 2 步逐像素读取亮度并做对比度增强
  3. 第 3 步按亮度映射到一串由稀到密的字符
  4. 第 4 步把字符行拼成文本写入 pre 元素

复刻配方

一段技术配方,可以直接交给 AI 编程助手,也可以自己照着写。想指定技术栈、位置和性能预算,就把它加入实现方案。

Request the webcam with getUserMedia and draw each video frame into a small offscreen canvas, for example 160 by 120. Read the pixels with getImageData, compute luminance per pixel and apply a contrast curve. Map each value to a character ramp ordered from dense to sparse and join rows into a string written to a pre element in a monospace font, adjusting the horizontal sampling to compensate for character aspect ratio.

档案

能不能拿来用

原作以 MIT 许可开源:可以阅读源码学习,按许可证条款使用;在自己的项目里引用时保留原作者署名。

性能开销

视觉强度

实现难度

尺度为策展判断(1 到 5),用于比较和推荐。

核实记录:Opened https://andrei.codes/ascii-camera/ (200, title 'ascii camera'); repo idevelop/ascii-camera exists, licence MIT via GitHub API.