Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to write the sample code for python character drawing video

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

Read video

In addition to pip install imageio, pip install imageio-ffmpeg is required to read video through imageio.

Because the images in the video are all color, you need to convert the rgb tricolor to a single intensity and put the converted image into a list.

Import imageioimport numpy as npimport matplotlib.pyplot as pltvideo = imageio.get_reader ('test.mp4') imgs = [] for img in video: imgs.append (np.mean (img,2)) plt.imshow (imgs [0]) plt.show ()

Convert to character

Although this video has been compressed, it is still too large for the character painting, so it needs to be further compressed before converting the 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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report