基本思路:使用订阅机制,开启手势识别节点,不断监听人脸识别节点传来的结果。当接受到人脸节点的传来的寻找到数据库内驾驶员人脸的信息后,则运行手势识别节点,完成手势识别。
关键代码:
talker:
def talker(a):
pub = rospy.Publisher('chatter', String, queue_size=10)
rospy.init_node('face', anonymous=True)
hello_str = "%s" % a
while 1:
rospy.loginfo(hello_str)
pub.publish(hello_str)
listener
def listener():
global flag
rospy.init_node('hand', anonymous=True)
rospy.sleep(2)
data = None
while data is None:
try:
data = rospy.wait_for_message('chatter', String, timeout=5)
except:
pass
if data.data == '1':
print("进入主函数")
cv2.destroyAllWindows()
flag = 1
最终视频戳这里