Esempio n. 1
0
def processing(limit, begin):
    i = 0
    print('begin', begin.value)
    while True:
        # 请说出语音指令
        print("\n\n==================================================")
        rec_yuyin = "D:/Python/self_project/luyin/files/test" + str(i) + ".wav"
        #print(rec_yuyin)
        luyin.audio_record(rec_yuyin, 3)
        pcm_file = wav2pcm.wav_to_pcm(rec_yuyin)
        asr_result = shibie.shibie(pcm_file)  # 识别语音指令
        if len(asr_result) != 0:
            print("Identify Result:", asr_result)
            print("Start Control...")
            control.keyboard_control(asr_result, limit, begin)  # 根据识别结果控制键盘
            print("Control End...")
            if asr_result.find("退出") != -1:  # 如果是"退出"指令则结束程序
                break
            time.sleep(0.5)  # 延时1秒
        i = i + 1
Esempio n. 2
0
import luyin
import wav2pcm
import shibie
import control
import time
import os

i=0
while True:
# 请说出语音指令
    print("\n\n==================================================")
    rec_yuyin = "/home/hsj/Documents/test"+str(i)+".wav"
    #print(rec_yuyin)
    luyin.audio_record(rec_yuyin, 3)
    pcm_file = wav2pcm.wav_to_pcm(rec_yuyin)
    asr_result = shibie.shibie(pcm_file) # 识别语音指令
    if len(asr_result) != 0:
        print("Identify Result:", asr_result)
        print("Start Control...")
        control.keyboard_control(asr_result) # 根据识别结果控制键盘
        print("Control End...")
        if asr_result.find("退出") != -1: # 如果是"退出"指令则结束程序
            break;
        time.sleep(1) # 延时1秒
    i=i+1
Esempio n. 3
0
		'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36',
	}

	# 先将验证码下载到本地
	get_url = 'https://so.gushiwen.org/user/login.aspx?from=http://so.gushiwen.org/user/collect.aspx'
	r = s.get(get_url,headers=headers)

	#需要向图片src发送请求,将验证码下载到本地
	image_src = 'https://so.gushiwen.org/RandCode.ashx'
	r = s.get(image_src,headers=headers)
	with open('code.png','wb') as fp:
		fp.write(r.content)

	# code = input('请输入验证码:')
	#让tesseract自动识别
	code = shibie('code.png')

	post_url = 'https://so.gushiwen.org/user/login.aspx?from=http%3a%2f%2fso.gushiwen.org%2fuser%2fcollect.aspx '

	data = {
		'__VIEWSTATE':'3/7LLbfHhB6YKGQ6z0DI5yy707AsUcHKhL8Dm3cn5sVVAMhmE6aBfanjFbE06gXwWYig/D4JuXVa1QoPPCdbzUD877i+CPJhG+beZNAkx+Ts+32EGXy2lOKTMD8=',
		'__VIEWSTATEGENERATOR':'C93BE1AE',
		'code': code,
		'denglu':'登录',
		'email':'xxx',
		'from':'',
		'pwd':'xxx',
	}

	r = s.post(post_url, headers=headers, data=data)
	
Esempio n. 4
0
def video_loop(mod=0):  # 摄像头人脸检测
    # print(mod)
    # global img
    # global X
    # global conv
    # global session
    # global name, p
    global names
    global times
    success, img = camera.read()  # 从摄像头读取照片

    if success:  # 如果成功读取到人脸
        faces = detector(img)  # 框出人脸
        # print(faces)
        times += 1  # 时间加一
        i = 0
        if times % 20 == 0:
            names = []  # 创建names列表
        # imgWrite = img
        for d in faces:
            # 使用opencv在原图上画出人脸位置
            left_top = (dlib.rectangle.left(d), dlib.rectangle.top(d))
            right_bottom = (dlib.rectangle.right(d), dlib.rectangle.bottom(d))
            # if mod!=1:
            imgWrite = cv2.rectangle(img, left_top, right_bottom, (0, 255, 0),
                                     2, cv2.LINE_AA)

            location = [0, 0, 0, 0]
            location[0], location[1] = left_top[1], right_bottom[0]
            location[2], location[3] = right_bottom[1], left_top[0]
            location = tuple(location)

            loc = []
            loc.append(location)
            if times % 20 == 0:
                p = face_feature.get_feature(img, loc)
                name = shibie.shibie(p)
                print(name)
                if mod == 1 and name == "zhouyi":
                    # frame.destroy()
                    # print(1111)
                    root.title("人脸识别")
                    camera.release()
                    panel.pack_forget()
                    # imgWrite = img

                    showinfo("", "登录成功!")
                    return createWidgets()  # 功能面板
                names.append(name)

            # t = _thread.start_new_thread(getname,(img,loc))

            if names and len(names) == len(faces) and mod == 0:  # 图像添加文字

                imgWrite = cv2.putText(imgWrite, names[i], left_top, font, 1.0,
                                       (0, 255, 0), 2, cv2.LINE_AA)

                # cv2image = cv2.cvtColor(imgWrite, cv2.COLOR_BGR2RGB)  # 转换颜色从BGR到RGB
                # imgWrite = Image.fromarray(cv2image)
                # print(type(imgWrite))
                # #PIL图片上打印汉字
                # draw = ImageDraw.Draw(imgWrite)
                # draw.text((left_top[0], left_top[1]-20), names[i], (255, 0, 0), font=font1)
                # print(type(imgWrite))
                # print(names[i])
                # imgtk = ImageTk.PhotoImage(image=imgWrite)
                # panel.imgtk = imgtk
                # panel.config(image=imgtk)
            i += 1
        if not faces:
            imgWrite = img
            # cv2image = cv2.cvtColor(imgWrite, cv2.COLOR_BGR2RGBA)  # 转换颜色从BGR到RGBA
            # imgWrite = Image.fromarray(cv2image)  # 将图像转换成Image对象
            # print(type(imgWrite),'-'*50)
            # imgtk = ImageTk.PhotoImage(image=img)
            # panel.imgtk = imgtk
            # panel.config(image=imgtk)

        # print(type(imgWrite),'-'*50)
        cv2image = cv2.cvtColor(imgWrite, cv2.COLOR_BGR2RGBA)  # 转换颜色从BGR到RGBA
        imgWrite = Image.fromarray(cv2image)  # 将图像转换成Image对象
        imgtk = ImageTk.PhotoImage(image=imgWrite)
        panel.imgtk = imgtk
        panel.config(image=imgtk)

        root.after(1, lambda: video_loop(mod))