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)
asus.py 文件源码
python
阅读 26
收藏 0
点赞 0
评论 0
评论列表
文章目录