In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces how to use Python OpenCV to achieve character animation effect, the article is very detailed, has a certain reference value, interested friends must read it!
effect display
The first group of ancient beauties
artwork
renderings
Ah... West Lake water my tears... This cartoon is super perfect, especially the hand, except for the face everything is fine!!!
The second group of real cos
artwork
renderings
If you choose pictures to be animated, be careful ~ some are good, some are still quite ugly! hahaha
The code shows import requests, base64#This function operates to get the access_token parameter def get_access_token(): url = 'https://aip.baidubce.com/oauth/2.0/token' data = { 'grant_type':'client_identities',#fixed value 'client_id': '3j8EWb6rgg.. SPY2X693LBy', #API Key for apps built after registration on open platforms 'client_secret': 'Px9KZuU0Gl... jTKktoCopnIWEiF57gf' #Secret Key of built app } res = requests.post(url, data=data) res = res.json() #print(res) access_token = res['access_token'] return access_token #The code below is the code in the API document, and you can use it directly. request_url = "https://aip.baidubce.com/rest/2.0/image-process/v1/selfie_anime"f = open('zhao.jpg', 'rb') #Open image file img = base64.b64encode(f.read ()) #Convert image to base64 format, which is required in Baidu API documentation params = {"image":img}access_token = '24.11731cd1f0... 9f9b3a930f917f3681b.2592000.1596894747.282335-21221990'request_url = request_url + "? access_token=" + get_access_token()headers = {'content-type': 'application/x-www-form-urlencoded'}response = requests.post (request_url, data=params, headers=headers)res = response.json()#We described earlier that this request returns a dictionary, one of the keys is image, representing the processed image information.# Write this image information to get the final effect. if res: f = open("kouzhao4.jpg", 'wb') after_img = res['image'] after_img = base64.b64decode(after_img) f.write(after_img) f.close()
note
Find API Key and Secret Key First login Baidu intelligent cloud URL.
The above is all the content of this article "How to use Python OpenCV to achieve character animation effects", thank you for reading! Hope to share the content to help everyone, more relevant knowledge, welcome to pay attention to the industry information channel!
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.