Ejemplo n.º 1
0
def recognition_captcha(data):
    ''' 识别验证码 '''

    file_id = str(uuid.uuid1())
    filename = 'captcha_' + file_id + '.gif'
    filename_png = 'captcha_' + file_id + '.png'

    if (data is None):
        return
    data = base64.b64decode(data.encode('utf-8'))
    with open(filename, 'wb') as fb:
        fb.write(data)

    appid = 'appid'  # 接入优图服务,注册账号获取
    secret_id = 'secret_id'
    secret_key = 'secret_key'
    userid = 'userid'
    end_point = TencentYoutuyun.conf.API_YOUTU_END_POINT

    youtu = TencentYoutuyun.YouTu(appid, secret_id, secret_key, userid,
                                  end_point)  # 初始化

    # 拿到的是gif格式,而优图只支持 JPG PNG BMP 其中之一,这时我们需要 pip install Pillow 来转换格式
    im = Image.open(filename)
    im.save(filename_png, "png")
    im.close()

    result = youtu.generalocr(filename_png, data_type=0,
                              seq='')  #  0代表本地路径,1代表url

    return result
Ejemplo n.º 2
0
 def __init__(self):
     appid = '10109383'
     userId = '875974254'
     secretId = 'AKIDd3D8rKrzCAsKXXKn8E5i6EAsLYVCuoiP'
     secretKey = 'ZtwjGYbP1PYT9anmV3MRGrCKDuPffOr4'
     endPoint = TencentYoutuyun.conf.API_YOUTU_END_POINT
     self.youtu = TencentYoutuyun.YouTu(appid, secretId, secretKey, userId, endPoint)
Ejemplo n.º 3
0
def getYoutuObject():
    appid = '1007301'
    secret_id = 'AKID54IH7KvVH3c0j6wBg4DZooihViATfbdd'
    secret_key = 'RzwA7LZliLaL37ex3OVuD3eulLEAXRR4'
    userid = 'sky1234'
    end_point = TencentYoutuyun.conf.API_YOUTU_END_POINT
    youtu = TencentYoutuyun.YouTu(appid, secret_id, secret_key, userid,
                                  end_point)
    return youtu
Ejemplo n.º 4
0
def youtu(image_path):
    appid = '10151047'
    secret_id = 'AKID59AA4pi1Sis5GIS2tdCe1b7W2T2asTjr'
    secret_key = 'N5mMxsiO6zjIk7Kj3DIPPLG4mOvOjvpk'
    userid = '924271966'
    end_point = TencentYoutuyun.conf.API_YOUTU_END_POINT  # 优图开放平台
    youtu = TencentYoutuyun.YouTu(appid, secret_id, secret_key, userid, end_point)

    req = youtu.DetectFace(image_path=image_path, mode=0, data_type=0)
    return req
Ejemplo n.º 5
0
def tencent_youtu_ocr(pic_path, mode='formula', type='latex'):
    youtu_appid = api_key['youtu_appid']
    youtu_secret_id = api_key['youtu_secret_id']
    youtu_secret_key = api_key['youtu_secret_key']
    youtu_userid = api_key['youtu_userid']

    end_point = TencentYoutuyun.conf.API_YOUTU_END_POINT
    youtu = TencentYoutuyun.YouTu(youtu_appid, youtu_secret_id,
                                  youtu_secret_key, youtu_userid, end_point)
    ret = youtu.formularocr(pic_path)
    output_formula('tencent_youtu_ocr', ret["items"], type)
Ejemplo n.º 6
0
    def __init__(self):
        '''
		以下为TencentYoutuyun的个人信息,请根据自己的id和key进行填充
		'''
        appid = 'XXXX'
        userId = 'XXXX'
        secretId = 'XXXX'
        secretKey = 'XXXX'
        endPoint = TencentYoutuyun.conf.API_YOUTU_END_POINT
        self.youtu = TencentYoutuyun.YouTu(appid, secretId, secretKey, userId,
                                           endPoint)
Ejemplo n.º 7
0
def findface(imgname):
    '''在图片中找出所有脸的位置'''
    appid = '********'  # 你的appid
    secret_id = '*************'  # 你的secret_id
    secret_key = '****************'  # 你的secret_key
    userid = 'rtx'  # 任意字符串
    # end_point = TencentYoutuyun.conf.API_TENCENTYUN_END_POINT  // 腾讯云
    # end_point = TencentYoutuyun.conf.API_YOUTU_VIP_END_POINT   // 人脸核身服务(需联系腾讯优图商务开通权限,否则无法使用)
    end_point = TencentYoutuyun.conf.API_YOUTU_END_POINT  # 优图开放平台
    youtu = TencentYoutuyun.YouTu(appid, secret_id, secret_key)
    ret = youtu.FaceShape(image_path='_'+imgname, mode=0, data_type=0)
    print(ret)
    return ret["face_shape"]
Ejemplo n.º 8
0
def xuanjianghui(datetype=1):
    #当天日期
    now = datetime.datetime.now()
    date = '-'.join([np.str(now.year), np.str(now.month), np.str(now.day)])

    #爬取当日宣讲会信息
    url = 'http://www.wutongguo.com/xuanjianghui/r4001/?datetype=%d' % datetype
    data = urllib.request.urlopen(url).read()
    data = data.decode('gb2312', 'ignore')

    #获取公司名称
    pattern1 = '<a class="rmTitle".*>(.*?)</a>'
    company = re.compile(pattern1).findall(data)

    #获取宣讲学校
    pattern2 = ' <a target="_blank".*>(.*?)</a>'
    university = re.compile(pattern2).findall(data)

    #获取宣讲地点
    pattern3 = '<b style="font-weight:normal;" title="(.*?)">'
    address = re.compile(pattern3, re.S).findall(data)

    #获取举办时间
    pattern4 = '<span style="font-family:微软雅黑;font-size:14px; ">\r\n\t\t  \\((.*?)\\) <img src="(.*?)"  style='
    hold_time = re.compile(pattern4, re.S).findall(data)
    weeks = []
    time_urls = []
    for week, time_url in hold_time:
        weeks.append(week)
        time_urls.append(time_url)

    #使用腾讯优图识别时间
    appid = '10119599'
    secret_id = 'AKIDyWAh7LTHzWr0xp99WWQ9g2GJTehaql9L'
    secret_key = '84oz1rX1Jk386tofKn3GLEKSQIyRhr39'
    end_point = TencentYoutuyun.conf.API_YOUTU_END_POINT
    youtu = TencentYoutuyun.YouTu(appid, secret_id, secret_key, end_point)
    hold_time = []
    for i in time_urls:
        time = youtu.generalocr(i, 1)
        hold_time.append(''.join(
            [i['character'] for i in time['items'][0]['words']]))

    #汇总数据
    data_all = pd.DataFrame()
    data_all['公司名称'] = company
    data_all['日期'] = np.repeat(date, len(company))
    data_all['时间'] = hold_time
    data_all['学校'] = university
    data_all['地点'] = address
    return data_all
Ejemplo n.º 9
0
class Config_YouTu:
    appid = '10131921'
    secret_id = 'AKIDX2NwSn076va4NV4EvRmvtgHhw1whFrBK'
    secret_key = '61mLjx0sZ5QbcT9ey9A0f8QPEtNhqocJ'
    userid = '1029580951'

    # 有图开放平台
    end_point = TencentYoutuyun.conf.API_YOUTU_END_POINT

    # 初始化
    youtu = TencentYoutuyun.YouTu(appid, secret_id, secret_key, userid,
                                  end_point)

    def get_you_tu(self):
        return self.youtu
Ejemplo n.º 10
0
    def __init__(self):
        appid = '10109383'
        userId = '875974254'
        secretId = 'AKIDd3D8rKrzCAsKXXKn8E5i6EAsLYVCuoiP'
        secretKey = 'ZtwjGYbP1PYT9anmV3MRGrCKDuPffOr4'
        endPoint = TencentYoutuyun.conf.API_YOUTU_END_POINT
        self.youtu = TencentYoutuyun.YouTu(appid, secretId, secretKey, userId,
                                           endPoint)

        self.root = '/Users/tung/Python/PersonalProject/NewsRecommend/'
        self.imgFile = self.root + 'On-line/user-profile/face.jpg'
        self.Nickname = '木冉'
        self.signature = "心向阳光 野蛮成长☀️"
        self.sex = 'Female'
        self.age = 26
        self.row = {'Occupation': '助理', 'Province': '北京', 'City': '北京'}
Ejemplo n.º 11
0
 def set_API(self):
     Param = self.env['ir.values'].sudo()
     appid = Param.get_default('loan.config.settings',
                               'yt_appid') or '10124678'
     secret_id = Param.get_default(
         'loan.config.settings',
         'yt_secret_id') or 'AKID1whKl2PCLOGxSmrtfQDtRp253saMpXrz'
     secret_key = Param.get_default(
         'loan.config.settings',
         'yt_secret_key') or '7d5NYdXIsHVXSHzWv9Fh0BD3jFYklbGj'
     userid = Param.get_default('loan.config.settings',
                                'yt_userid') or '1227400499'
     end_point = Param.get_default(
         'loan.config.settings',
         'yt_end_point') or TencentYoutuyun.conf.API_YOUTU_END_POINT
     self.youtu = TencentYoutuyun.YouTu(appid, secret_id, secret_key,
                                        userid, end_point)
def analyse_image():
    # 向腾讯优图平台申请的开发密钥
    appid = '***********'
    secret_id = '*********************************'
    secret_key = '*********************************'
    userid = '***********'

    end_point = TencentYoutuyun.conf.API_YOUTU_END_POINT  # 优图开放平台
    youtu = TencentYoutuyun.YouTu(appid, secret_id, secret_key, userid,
                                  end_point)

    use_face = 0
    not_use_face = 0

    base_path = 'headImages'
    for file_name in os.listdir(base_path):
        result = youtu.DetectFace(os.path.join(base_path,
                                               file_name))  # 人脸检测与分析
        # print(result)  # 参考 https://open.youtu.qq.com/legency/#/develop/api-face-analysis-detect
        # 判断是否使用人像
        if result['errorcode'] == 0:  # errorcode为0表示图片中存在人像
            use_face += 1
            gender = '男' if result['face'][0]['gender'] >= 50 else '女'
            age = result['face'][0]['age']
            beauty = result['face'][0]['beauty']  # 魅力值
            glasses = '不戴眼镜 ' if result['face'][0]['glasses'] == 0 else '戴眼镜'
            # print(file_name[:-4], gender, age, beauty, glasses, sep=',')
            with open('header.txt', mode='a', encoding='utf-8') as f:
                f.write('%s,%s,%d,%d,%s\n' %
                        (file_name[:-4], gender, age, beauty, glasses))
        else:
            not_use_face += 1

    attr = ['使用人脸头像', '未使用人脸头像']
    value = [use_face, not_use_face]
    pie = Pie('好友头像分析', '', title_pos='center')
    pie.add('',
            attr,
            value,
            radius=[30, 75],
            is_label_show=True,
            is_legend_show=True,
            legend_top='bottom')
    # pie.show_config()
    pie.render('好友头像分析.html')
Ejemplo n.º 13
0
def get_Tencent_res(image_path):
    appid = Tencent_config["appid"]
    secret_id = Tencent_config["secret_id"]
    secret_key = Tencent_config["secret_key"]
    userid = Tencent_config["userid"]

    end_point = TencentYoutuyun.conf.API_YOUTU_END_POINT
    youtu = TencentYoutuyun.YouTu(appid, secret_id, secret_key, userid,
                                  end_point)
    ret = youtu.generalocr(image_path, data_type=0, seq='')

    det_res = ""
    #print (ret)
    for item in ret["items"]:
        det_res += item['itemstring']
    det_res = det_res.encode('latin1').decode('utf-8')

    #print(det_res)
    return det_res
Ejemplo n.º 14
0
def get_content_byimg(img):
    # 这里使用的是腾讯的优图开放平台的图像识别SDK,该appid应该会有上弦,具体不知,如果不能使用了,请自行申请更换
    """ 以下为开放平台返回的识别文本,题目和答案根据此内容解析
    {
        "errorcode":0,
        "errormsg":"OK",
        "items":
                [
                    {
                        "itemstring":"手机",
                        "itemcoord":{"x" : 0, "y" : 1, "width" : 2, "height" : 3},
                        "words": [{"character": "手", "confidence": 98.99}, {"character": "机", "confidence": 87.99}]
                    },
                    {
                        "itemstring":"姓名",
                        "itemcoord":{"x" : 0, "y" : 1, "width" : 2, "height" : 3},
                        "words": [{"character": "姓", "confidence": 98.99}, {"character": "名", "confidence": 87.99}]
                    }
                ],
        "session_id":"xxxxxx"
    """
    appid = '10115709'
    secret_id = 'AKIDY0HNJ482FJI8mJcqpdIpCPQFwTs6d2kM'
    secret_key = 'fAVfdP1Rlur03vfifR0U5Y1Qwv2yiWHs'
    userid = 'myApp1'  # 自行命名,以上三个参数均在开放平台申请

    end_point = TencentYoutuyun.conf.API_YOUTU_END_POINT  # 优图开放平台

    youtu = TencentYoutuyun.YouTu(appid, secret_id, secret_key, userid,
                                  end_point)

    with open('screenshot.png', 'wb') as fileReader:
        fileReader.write(img.getvalue())
    # 在执行generalocr()方法时,由于request对象的问题,返回中文时乱码,需要手动再指定返回对象的编码格式:r.encoding='utf-8' 详见youtu,py脚本文件
    ocrinfo = youtu.generalocr('screenshot.png', 0)
    # print(ocrinfo['items'])
    return ocrinfo['items']
Ejemplo n.º 15
0
conf.read('config.ini')

APP_ID = conf.get('params', 'app_id')
SECRET_ID = conf.get('params', 'secret_id')
SECRET_KEY = conf.get('params', 'secret_key')
USER_ID = conf.get('params', 'user_id')

HOST = conf.get('server', 'host')
PORT = conf.getint('server', 'port')
DEBUG = conf.get('server', 'debug')

END_POINT = TencentYoutuyun.conf.API_YOUTU_END_POINT

app = Flask(__name__)

youtu = TencentYoutuyun.YouTu(APP_ID, SECRET_ID, SECRET_KEY, USER_ID,
                              END_POINT)


# 创建个体,此函数小程序暂不使用
@app.route('/face/api/newstu', methods=['POST'])
def NewStu():
    '''
    - student_id: 新建的个体id,用户指定,唯一,建议为学号或身份证
	- student_name: 个体对应的姓名
	- group_ids: 数组类型,用户指定(组默认创建)的个体存放的组id,可以指定多个组id,如班级,年级,校
	- image_path: 包含个体人脸的图片路径(暂时没想好怎么解决,先用模拟)
	- tag: 备注信息,用户自解释字段(没想好干啥用)
    - data_type: 用于表示image_path是图片还是url, 0代表图片,1代表url
    '''
    #if not request.json or not 'person_id' in request.json:
    #    abort(400)
Ejemplo n.º 16
0
def analyse_touxiang_data():
    # 导入腾讯优图,用来实现人脸检测等功能  https://open.youtu.qq.com
    import TencentYoutuyun
    from pyecharts import Pie
    # 导入jieba模块,用于中文分词
    import jieba
    # 导入matplotlib,用于生成2D图形
    import matplotlib.pyplot as plt
    # 导入wordcount,用于制作词云图
    from wordcloud import WordCloud, STOPWORDS
    # 向腾讯优图平台申请的开发密钥,此处需要替换为自己的密钥
    appid = "----"
    secret_id = "----"
    secret_key = "----"
    userid = "----" # 你的qq号

    end_point = TencentYoutuyun.conf.API_YOUTU_END_POINT  # 优图开放平台
    youtu = TencentYoutuyun.YouTu(appid, secret_id, secret_key, userid, end_point)

    use_face_man = 0
    use_face_woman = 0
    not_use_face = 0

    base_path = current_dir+'/headImages'
    tag_tpyes = [] # 分词
    for file_name in os.listdir(base_path):
        result = youtu.DetectFace(os.path.join(base_path, file_name))  # 人脸检测与分析
        # print(result)  # 参考 https://open.youtu.qq.com/legency/#/develop/api-face-analysis-detect
        # 判断是否使用人像
        gender=""
        age=0
        beauty=0
        glasses=""
        if result['errorcode'] == 0:  # errorcode为0表示图片中存在人像
            gender = '男' if result['face'][0]['gender'] >= 50 else '女'
            if gender=="男":
                use_face_man+=1
            else:
                use_face_woman+= 1

            age = result['face'][0]['age']
            beauty = result['face'][0]['beauty']  # 魅力值
            glasses = '不戴眼镜 ' if result['face'][0]['glasses'] == 0 else '戴眼镜'
        else:
            not_use_face += 1

        tag_name=""
        result_type = youtu.imagetag(os.path.join(base_path, file_name))  # 头像分类
        if result_type['errorcode'] == 0 and len(result_type["tags"])>0:
            tag_name=max(result_type["tags"], key=lambda item: item['tag_confidence']) ["tag_name"].encode('ISO-8859-1').decode("utf8")
            tag_tpyes.append(tag_name)

        with open(current_dir+'/header.txt', mode='a', encoding='utf-8') as f:
            f.write('%s,%s,%d,%d,%s,%s\n' % (file_name[:-4], gender, age, beauty, glasses,tag_name))

    attr = ['使用人脸头像-男','使用人脸头像-女', '未使用人脸头像']
    value = [use_face_man,use_face_woman, not_use_face]
    pie = Pie('好友头像分析', '', title_pos='center')
    pie.add('', attr, value, radius=[30, 75], is_label_show=True,
            is_legend_show=True, legend_top='bottom')
    # pie.show_config()
    pie.render(current_dir+'/好友头像分析.html')

    # 设置分词
    split = jieba.cut(str(tag_tpyes), cut_all=False)  # False精准模式分词、True全模式分词
    words = ' '.join(split)  # 以空格进行拼接

    # 导入背景图
    bg_image = plt.imread(current_dir+'/010-wechat-bg.jpg')

    # 设置词云参数,参数分别表示:画布宽高、背景颜色、背景图形状、字体、屏蔽词、最大词的字体大小
    wc = WordCloud(width=1024, height=768, background_color='white', mask=bg_image, font_path='STKAITI.TTF',
                max_font_size=400, random_state=50)
    # 将分词后数据传入云图
    wc.generate_from_text(words)
    plt.imshow(wc)  # 绘制图像
    plt.axis('off')  # 不显示坐标轴
    # 保存结果到本地
    wc.to_file(current_dir+'/头像类别.jpg')
Ejemplo n.º 17
0
import TencentYoutuyun

AppID = '10143555'

SecretID = 'AKIDXwGSSEd8G9pKej7R3QaVBcolV0GNtvLX'

SecretKey = '80d1A9rJYbOvDF3dzFKBnBKEtJUQ7aoo'

userid= '1090710046'

end_point = TencentYoutuyun.conf.API_YOUTU_END_POINT

youtu = TencentYoutuyun.YouTu(AppID,SecretID,SecretKey,userid,end_point)

result = youtu.fooddetect('/home/alexhowe/Pictures/hotdog.jpzg',data_type=0,seq= '')

print(result)
Ejemplo n.º 18
0
    def __init__(self, *argc, **argkw):
        config = ConfigParser.ConfigParser()
        config.readfp(open(AP + "config/config.ini"))
        COOKIE_SECRET = config.get("app", "COOKIE_SECRET")
        FACE_API_KEY = config.get("app", "FACE_API_KEY")
        FACE_API_SECRET = config.get("app","FACE_API_SECRET")
        ALIYUN_KEY = config.get("app","ALIYUN_KEY")
        ALIYUN_SECRET = config.get("app","ALIYUN_SECRET")
        template_path = os.path.join(AP + "templates")
        static_path = os.path.join(AP + "static")
        appid = config.get("YOUTU","APPID")
        secret_id = config.get("YOUTU","SECRET_ID")
        secret_key = config.get("YOUTU","SECRET_KEY")
        userid = config.get("YOUTU","USERID")
        logging.info("start server.")
        settings = dict(
            cookie_secret=COOKIE_SECRET,
            xsrf_cookies=False,
            template_path=template_path,
            static_path=static_path
        )

        handlers = [
            # test
            (r'/', IndexHandler),
            (r'/sleep',SleepHandler),
            (r'/user/register', RegisterHandler),
            (r'/user/login', LoginHandler),
            (r'/user/logout', LogoutHandler),
            (r'/user/confirm', ConfirmHandler),
            (r'/user/peronlistinfo',MyPersonListHandler),
            (r'/user/updatestatus', UpdateStatusHandler),
            (r'/find/searchperson', SearchPersonHandler),
            (r'/find/callhelp', CallHelpHandler),
            (r'/find/compare', ComparePersonHandler),
            (r'/get/updateperson',LastestUpdatePersonHandler),
            (r'/get/updatemessage',LastestUpdateMessageHandler),
            (r'/get/persondetail',GetMissingPersonDetailHandler),
            (r'/get/persondetail/web',GetMissingPersonDetailWebHandler),
            (r'/get/trackinfo/web',GetPersonTracksHandler),
            (r'/get/alltrack/web',GetAllTracksHandler),
            (r'/web/index',IndexPageHandler),
            (r'/web/details',DetailPageHandler),
            (r'/web/file',FilePageHandler),
            (r'/download',DownloadHandler),
            (r'/admin/import',ImportPersonHandler)
            
        ]

        tornado.web.Application.__init__(self, handlers, **settings)
        # use SQLachemy to connection to mysql.
        DB_CONNECT_STRING = 'mysql+mysqldb://%s:%s@%s/%s?charset=utf8'%(options.mysql_user, options.mysql_password, options.host, options.mysql_database)
        engine = create_engine(DB_CONNECT_STRING, echo=False,pool_size=1000)
        self.sqldb = sessionmaker(
                bind=engine,
                autocommit=False, 
                autoflush=True,
                expire_on_commit=False)
        base_model = declarative_base()
        # create all of model inherit from BaseModel 
        base_model.metadata.create_all(engine) 
        # use pymongo to connectino to mongodb
        logging.info("connect mongodb ..")
        client = pymongo.MongoClient(options.host,27017)
        client.cloudeye.authenticate(options.mongo_user,options.mongo_password)
        self.mongodb = client.cloudeye
        # bind face++ cloud service
        logging.info("connect mongodb successfully..")
        # self.facepp = API(FACE_API_KEY, FACE_API_SECRET)
        end_point = TencentYoutuyun.conf.API_YOUTU_END_POINT
        self.youtu = TencentYoutuyun.YouTu(appid, secret_id, secret_key, userid, end_point)
        # bind ali cloud service
        auth = oss2.Auth(ALIYUN_KEY,ALIYUN_SECRET)
        endpoint = r'http://oss-cn-shanghai.aliyuncs.com'
        bucket_name = 'cloudeye'
        self.ali_service = oss2.Service(auth, endpoint)
        self.ali_bucket = oss2.Bucket(auth, endpoint, bucket_name)
        # bind redis service
        logging.info("connect redis..")
        self.redis = redis.Redis(host='localhost',port=6379)
        logging.info("connect redis successfully..")
        if options.flush_redis==1:
            self.redis.flushall()
        logging.info("start completed..")
Ejemplo n.º 19
0
#!/usr/bin/python
import TencentYoutuyun
import json
import sys, os
import cv2
# -*- coding: utf-8 -*-
appid = '10130422'
secret_id = 'AKID7CD6rYXXoyyoU3fpEVcKyOjuBTuI8qzx'
secret_key = 'ymZI856HIXgfT9e1pcImBSYo0Uq482qU'
userid = '345393041'

end_point = TencentYoutuyun.conf.API_YOUTU_END_POINT

youtu = TencentYoutuyun.YouTu(appid, secret_id, secret_key, userid, end_point)
path = "../lp_dataset"

list_f = open('log_warning').readlines()

log_err = open('recheck_vr_log_err', 'wb+')
log_warning = open('recheck_vr_log_warning', 'wb+')

#for i in range(0,20):
for i in range(0, len(list_f)):
    list_f[i] = list_f[i].strip("\n")
    ret = youtu.carclassify(list_f[i], 0)
    print(list_f[i])
    filename_start = list_f[i].rfind("/") + 1
    filename = "./output_json/" + list_f[i][filename_start:] + ".json"
    #	filename="./output_json/"+str(i)+".json"
    #	print(filename)
    f = open(filename, 'wb+')
Ejemplo n.º 20
0
def analyse_head_image(friends):
    """
    分析好友头像,从两个方面来分析:
        第一,在这些好友头像中,使用人脸头像的好友比重有多大;
        第二,从这些好友头像中,可以提取出哪些有价值的关键字
    :param friends:
    :return:
    """
    # 初始路径
    path = os.path.abspath('.')
    folder = path + '\\HeadImages\\'
    if (os.path.exists(folder) == False):
        os.makedirs(folder)

    # 人脸检测
    """
    - 接口
        `DetectFace(self, image_path, mode = 0, data_type = 0)`
    - 参数
    	- `image_path` 待检测的图片路径
	    - `mode` 是否大脸模式,默认非大脸模式
        - `data_type` 用于表示image_path是图片还是url, 0代表图片,1代表url
    """
    use_face = 0
    not_use_face = 0
    img_tags = ''
    # 申请应用密钥
    appid = '10130514'  #平台添加应用后分配的AppId
    secret_id = 'AKIDVvAIyUd690gEbrhylNp7xbIsJYcVwnGZ'  #平台添加应用后分配的SecretId
    secret_key = 'HNJ4e5LPL9mEVbVEm9KLG1eAWgfT6Yqy'  #平台添加应用后分配的SecretKey
    end_point = TencentYoutuyun.conf.API_YOUTU_END_POINT
    youtu = TencentYoutuyun.YouTu(appid, secret_id, secret_key, end_point)
    # 保存头像
    for index in range(1, len(friends)):
        friend = friends[index]
        img_file = folder + '\\Image%s.jpg' % str(index)
        # print(friend['UserName'])
        # 从json文件中读取数据时,无需登录此处会报错,则先注释,第一次保存头像需要解开注释
        # img_data = itchat.get_head_img(userName=friend['UserName'])
        # if (os.path.exists(img_file) == False):
        #     print(img_file)
        #     with open(img_file, 'wb') as f:
        #         f.write(img_data)
        time.sleep(1)
        # 检测头像
        result1 = youtu.DetectFace(image_path=img_file, mode=0, data_type=0)
        if result1['face']:
            use_face += 1
        else:
            not_use_face += 1
        # 图像标签识别 imagetag(self, image_path, data_type = 0, seq = '')
        result2 = youtu.imagetag(image_path=img_file, data_type=0, seq='')
        print(index, '>>>>', result2)
        img_tags += ','.join(
            list(map(lambda x: x['tag_name'], result2['tags'])))

    lables = [u'人脸头像', u'非人脸头像']
    counts = [use_face, not_use_face]
    colors = ['skyblue', 'yellow']
    # 将某部分爆炸出来,使用括号,将第一块分割出来,数值的大小是分割出来的与其他两块的间隙
    explode = (0, 0.05)
    plt.figure(figsize=(9, 6), dpi=80)
    plt.axes(aspect=1)
    plt.pie(counts,
            explode=explode,
            labels=lables,
            colors=colors,
            labeldistance=1.1,
            autopct='%3.1f%%',
            shadow=False,
            startangle=90,
            pctdistance=0.6)
    # 头像统计结果,头像展示标签,饼图区域配色,标签距离圆点距离,饼图区域文本格式,饼图是否显示阴影,饼图起始角度,饼图区域文本距离圆点距离
    plt.legend()
    plt.title(u'%s的好友头像情况' % friends[0]['NickName'])
    plt.show()

    img_tags = img_tags.encode('iso8859-1').decode('utf-8')
    print(img_tags)
    # 读取背景图
    # 两种方式 img_back = np.array(Image.open("imagename.png"))
    img_back = imread('steve.jpg')
    wordcloud = WordCloud(
        background_color='white',  # 背景图片中不添加word的颜色
        max_words=2000,  # 最大词个数
        mask=img_back,
        font_path='E:\Web-Crawler\Wechat\SimHei.ttf',
        # 设置字体格式,如不设置显示不了中文,而且字体名不能是中文
        max_font_size=60,  # 设置字体大小的最大值
        random_state=100,
        scale=1.5,
    )
    wordcloud.generate(img_tags)
    plt.imshow(wordcloud)
    plt.axis("off")
    plt.show()
    wordcloud.to_file('img_tags.jpg')