GithubHelp home page GithubHelp logo

manhinnn0509 / img2colorized-ascii.py Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 22.44 MB

Play video in colorized ASCII

License: GNU General Public License v3.0

Python 100.00%
ascii-art ascii-graphics ascii-video ascii-color python python3 opencv-python opencv

img2colorized-ascii.py's Introduction

img2colorized-ascii.py

Play video in colorized ASCII art in console

The file asciify.py in this project is from this repository, credits to them. (I only added a little bit changes to it for this project)

I added example images & videos which are clips and screenshots from Watch_Dogs & Cyberpunk 2077. I don't own them

Run this program

Real-time render & play

Windows: cls && python img2colorized_ascii.py
Linux: clear && python img2colorized_ascii.py

Pre-render

First, run python prerender.py to pre-render frames. It will save them as json file. (The json file size might be a bit large!)

Then run python prerender_play.py to play the "video"

Requirements / Dependencies

See requirements.txt

How does it works?

Steps:

  1. Opens the video from given path
  2. Read frame
  3. Convert the image (cv2) to PIL image
  4. Resize the PIL image
  5. Mark down each pixel's color
  6. Turn the image to ASCII art
  7. Colorized the characters with color
  8. Print out the colorized ASCII image
  9. Clears previous output
  10. Read next frame
  11. Back to Step 3

Why resizing the frame?

This is because the amount of charater per line in console is somehow limited (If I understand correctly)
In my case it's 100 characters per line

I resize the frame's width and height in ratio.
For example, a 1920x1080 image will be resized to 100x56

Notice

  • The height of each output frame is 56
  • The speed might be slower since it does all the steps above in real time (If it's not pre-rendered)
  • There should be some blinking between each frame

Planned

I might do these someday but not sure when :P

img2colorized-ascii.py's People

Contributors

manhinnn0509 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.