Setup your IDE for use with OpenCV, or follow this tutorial here.
Run git clone https://github.com/birinders/AsciiVideoCPP.git
to get started.
Take what you see, and show it on the terminal. The project uses OpenCV library in order to convert anything your webcam captures from a series of colourful dots to a series of black and white letters. The program uses the cv2 module to capture data from any camera connected to your device, and then converts it into a b&w image. This allows us to index every pixel in this image array, and convert it into suitable ascii characters according to their brightness.
Eg- A pixel with high brightness value is converted to a character with a larger area, like $ or #, whereas darker characters might get converted to dots("."), commas(",") or even blank spaces (" ") if the pixel is too dim.
- Note- The default behaviour is to choose the external camera before the built in camera. You can change this behaviour in the Source.cpp file.
Ratio correction is an extremely important step for this project to work correctly. Since we know that characters are not square, but are taller than they are wide, like a vertical rectangle, we need to account for this differnce factor in order to produce the outputs in the correct ratio.
The above can be calculated using the following formula-
The script will automatically check the aspect ratio of the incoming video stream, and readjust the output to match the input aspect ratio. The terminal is NOT automatically resized upon startup in the CPP port.
Meet Birinder: The person trying to convice you that AsciiVideo works better in Python
(trust me this works better in python)
- Notes-
- If text appears out of place, try shrinking the terminal letter size by holding ctrl + mousewheel down.
- Make sure to set the terminal font to a monospace font. This is the default behaviour for most terminals, and is the core requirement for the output to be aligned.
- Try manually adjusting the letter_height and letter_width variables if the image appears too tall or too wide.