asus.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:Face-Recognition-for-Mobile-Robot 作者: gagolucasm 项目源码 文件源码
def callback(self,data):
        i=0
    rg=spr.Recognizer()
        try:
            frame = self.bridge.imgmsg_to_cv2(data, "bgr8")
            frame = libs.resize(frame, width=600)
            gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
            (rects, i, facess) = et.track(gray, i)
            for rect in rects:
                cv2.rectangle(frame, (rect[0], rect[1]), (rect[2], rect[3]), (0, 255, 0), 2)
            if facess != []:
                for face in facess:
                    pred, conf = recognizer.predict(face)
                    if conf < 120:
                        print "Reconozco a Lucas con una confianza de {}".format(conf)
            self.num=self.num+1
            if self.num==10:
                            self.engine.say('Hi ')
                self.engine.say( list(dictid.keys())[list(dictid.values()).index(pred)])
                self.engine.runAndWait()
                with spr.Microphone() as source:
                    rg.adjust_for_ambient_noise(source)
                    print 'Escuchando'
                    audio=rg.listen(source)
                    try:
                        respuesta= rg.recognize_sphinx(audio)
                        print respuesta
                        if respuesta!='no':
                            self.engine.say('OKEY ')
                            self.engine.say('Getting')
                            self.engine.say('new')
                            self.engine.say('data')
                            self.engine.runAndWait()
                    except spr.UnknownValueError:
                        print 'error'

                    else:
                        print "Desconocido"
            cv2.imshow("Tracking", frame)
            cv2.waitKey(1)
        except CvBridgeError as e:
            print(e)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号