This article is participating in Python Theme Month

Today, a friend in the group, sent this video to ask the committee, I opened a thief interesting!

How to convert video into color character animation with one click – Bilibilii

This is an interesting Python project that uses computer vision to convert streaming media/images into bitmaps in color.

(The cat on the right is automatically converted to the color bitmap on the left. Other pictures and videos are also available.)

Good guy, dare this machine vision high myopia!!

Although I saw this project for the first time, as a python veteran, it took less than an hour for me to touch this project, install and use it, and write this blog. (A little show, but it’s ok, after all, the problem of computer vision myopia has not been dealt with yet, haha)

But learn Python, you own the world, and you own a whole bunch of cool libraries! Stop obsessing about the goddess and come play Python into the pit!

Let’s start with three steps, but we’re going to solve each problem one by one.

The summary is a Python project in three easy steps

Then open the source code directly to do it.

Step 1: Take a quick look at the project structure, README, and get to the core from the code.

First, to get a Python open source project, we need to take a look at README, which is also the Github homepage ShellPlayer Github

It’s easy to find out. Based on opencV, an open source visual library, this project is just a shell (there are some contributions, too, not bad!). .

The whole project is to call FFMPEG (a streaming media processing tool that can be called from the command line) to load pictures/videos, and then use OpencV to identify images and generate color bitmaps. This is based on OpencV intelligent vision to recognize pictures/videos and then convert to generate color bitmaps!

Here is the code, novice do not tangle with details, because entanglement will make you more confused!!

Lei committee recommends: grasp two keys 1) read streaming media data and 2) OpencV read streaming media data into a frame bitmap output.

If you’re interested, check it out:Github.com/HypoX64/She…

Here is the link ffMPEG method to read the video stream:Github.com/HypoX64/She…

The third step, the project operation effect

Let’s first look at the effect, interested in the second step to see the installation of it.

The color bitmap generated by the program on the left does not quite resemble the cat on the right. But that’s the idea!

Therefore, lei Recommends readers to download some clear resolution, so that the generated bitmap outline will be more clear.



Ok, run the command is the following:

#play.py check out ShellPlayer directory in git clone
# Here is the play.py script executed by Python with the argument '-m' and the path to the video or image.
python play.py -m "/Users/mac/Desktop/hometown-cat2021.mp4"
Copy the code

Here’s step two, which I’m sure you’re interested in.

If you want to play something cool, you have to be patient.

According to Lei, if something is too simple, it is not fun at all, so it is valuable to play. What do you think?

The installation steps come in 3 steps.

Download ShellPlayer code

git clone git clone https://github.com/HypoX64/ShellPlayer.git
Copy the code

After downloading, the directory structure is roughly as follows:

Virtualenv: virtualEnv: virtualEnv: VirtualEnv: VirtualEnv: VirtualEnv

Install the dependent Python libraries

# this is not mentioned on the official website, but when I run player, I get an error. Good project documentation needs to be done!
pip install numpy -i http://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com 

pip install opencv-python -i http://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com
Copy the code

Install ffmpeg

This is as simple as it gets.

Ray uses a macbook, all installed on BREW.

Add the FFMpeg project repository by running the following command brew tap to facilitate the installation:

brew tap homebrew-ffmpeg/ffmpeg
Copy the code



Run the following command to install FFmpeg:

brew install ffmpeg
Copy the code

Below take a few installation screenshots, quite long, need to download a lot of dependencies and installation.





See the picture below, congratulations, it’s installed. See if FFMPEG is installed successfully.

Enter ‘ffmPEg-version’ to output the following version and some run options, indicating that the FFMPEG stream processing tool has been installed successfully!

Now that the installation is successful, go back to step 3 in the middle and run it.

There is no summary of this article, feel fun fun to try quickly.

Continuous learning and continuous development, I am Lei Xuewei! Programming is fun. The key is to get the technology right. Welcome to pay attention, and feel free to like the collection!

Learn Python, go to GitHub and find lots of other people sharing code/projects to play with, it’s fun.

Feel good friends please forward points like collection, thank you! Can also leave a message exchange!

By the way, the committee also has this can pay attention to long-term reading => Thunder committee interesting programming story compilation

Refer to the link

Opencv computer vision: opencv.org/ recommend this easy install ffmpeg: https://www.jingxialai.com/2796.html is likely to be useful, seen but complicated installation: the installation of ffmpeg MAC installation