当前位置:网站首页>On Valentine's day, I drew an object with characters!
On Valentine's day, I drew an object with characters!
2022-07-27 08:14:00 【51CTO】
Before, I often saw that kind of video composed of characters on the Internet , Very cool . I don't know how to do it , I've studied these two days , It's not hard to find .
Let's take a look at the final effect ( If vague , Click the link below to see the HD version ):
https://bytedance.feishu.cn/docx/doxcnCvvY051xFCBAmSqYZgiP7b
How to achieve ?
Simply speaking , To turn a color video into a black-and-white video drawn by characters , You can do it in the following steps :
- Frame the original video , Black and white every frame , And the pixels are represented by corresponding characters .
- Recombine the represented string into a character image .
- Combine all the character images into character video .
- Import the audio of the original video into the new character video .
Operation method
I put the complete code at the end of the article , Direct operation python3 video2char.py that will do . The program will ask you to enter the local path of the video and the definition after the transformation (0 Most blurred ,1 The clearest . Of course, the clearer , The slower the transition ).
To run the code, you need to use tqdm、opencv_python、moviepy Wait for a few libraries , First of all pip3 install Make sure they all have .
Principle analysis
The key step is how to convert a color image into a black-and-white character image , As shown in the figure below :

Extracted from the Frog Princess video

Drawn in characters
The principle of transformation is actually very simple . First of all, because a character will occupy a large pixel block in the image , So we must compress the color image first , Successive blocks of pixels can be merged , This compression process is opencv Of resize operation .
Then convert the compressed pixels into black-and-white pixels , And transform it into the corresponding character . Character, I use the following string here , From black to white , After my practice, this group is the best :
"#8XOHLTI)i=+;:,. "
Then you need to paint the transformed characters on the new canvas , It should be noted that the layout is uniform and compact , It's best not to have too much extra space around the canvas .
Finally, combine all the character images into a video , But there is no sound after the merger , Need to use moviepy The library imports the sound of the original video .
Complete code
边栏推荐
- [MRCTF2020]Ezpop 1
- 擎创科技加入龙蜥社区,共建智能运维平台新生态
- Record a PG master-slave setup and data synchronization performance test process
- Things come to conform, the future is not welcome, at that time is not miscellaneous, neither love
- End of year summary
- PHP realizes data interaction with MySQL
- An ordinary autumn recruitment experience
- Mqtt instruction send receive request subscription
- ERP生产作业控制 华夏
- Weekly learning summary
猜你喜欢
随机推荐
如何更新pip3?和Running pip as the ‘root‘ user can result in broken permissions and conflicting behaviour
DEMO:ST05 找文本ID 信息
QingChuang technology joined dragon lizard community to build a new ecosystem of intelligent operation and maintenance platform
"PHP Basics" PHP statements and statement blocks
2020 International Machine Translation Competition: Volcano translation won five championships
JS access cookie example
Digital transformation driven by enterprise architecture!
vCenter7.0管理Esxi7.0主机
ERP production operation control Huaxia
All in one 1251 - Fairy Island for medicine (breadth first search)
[target detection] yolov6 theoretical interpretation + practical test visdrone data set
一文速览EMNLP 2020中的Transformer量化论文
CommonTitleBar hide left right
Translation character '/b' in C #
Debug: generic related "unresolved external symbols"
On data security
Plato farm is expected to further expand its ecosystem through elephant swap
What are the software tuning methods? Let's see what Feiteng technology experts say about dragon lizard technology
ERP生产作业控制 华夏
End of year summary

![[ciscn2019 southeast China division]web11 1](/img/94/61ad4f6cbbd46ff66f361462983d7a.png)







