In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article is about how Python converts video to character painting. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
First read the video and convert it to characters. The video was downloaded from bilibili at the address of the famous pangolin scene in the south of the Yangtze River.
As the video downloaded directly by bilibili is in flv format, but imageio does not support it, although it can be read with opencv, by contrast, it is not complicated to transcode with ffmepg, so you can make maximum use of Huaqiang's code to buy melons.
In addition, the video material is too long for code demonstration, so intercept 15s from 2: 10.
Enter on the command line
> pip install ffmpeg > ffmpeg-I soup.flv-ss 00:02:10-t 15 seg.mp4-y
Soon got the seg.mp4, the next is to read the video and convert to characters, for the parsing of this part of the code, you can go out and turn left to Huaqiang to buy melons.
Import imageioimport numpy as npimport matplotlib.pyplot as pltvideo = imageio.get_reader ('seg.mp4') imgs = [np.mean (im,2) for im in video] plt.imshow (imgs [30]) plt.show ()
This video is too large for character painting, so you need to compress it before turning it into character painting. The simplest method is taken here-that is, to average the adjacent pixels.
# reduce the width of the image to widthfrom itertools import product # for circular nesting def resizeImg (img,w,h=None): Mrecine n = img.shape if n
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.