ASCII Cam

ASCII Cam is an iOS application that turns a video feed into ASCII art. The ASCII generation code is based on my previous project, Ascii Generator.

How it works

The application reads a video feed from the default device camera. Each frame is split up into cells of pixels, each of which represents an ASCII letter in the final rendering. The app then computes the average color of each cell and stores it in a BlockGrid object. BlockGrid is an objective-C wrapper around a buffer of CGFloats.

The main ViewController passes the BlockGrid to a custom UIView subclass ASCIIView. For each cell in the grid, ASCIIView:

  1. Computes the darkness of the cell on a scale of 1.0 to 0.0
  2. Searches through a predefined binary tree of darkness/letter pairs. For example, this would match the darkness value 1.0 to a space and darkness 0.0 to an @.
  3. Draws the appropriate character in the cell, using the cell's color

All drawing is done with Quartz. The app averages around 10 FPS, which feels fairly smooth. In the future, it might be an interesting exercise to port it to OpenGL instead.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值