Go to the documentation of this file.00001
00002
00003
00004
00005 import rospy
00006 from docomo_perception.srv import ImageRecognition, ImageRecognitionRequest
00007 from sensor_msgs.msg import Image
00008
00009 import sys
00010
00011 global callbackReceived
00012
00013 def cb(msg):
00014 global callbackReceived
00015
00016 res = image_recognition(type=ImageRecognitionRequest.ALL,
00017 image=msg,
00018 numOfCandidates=10)
00019 for c in res.candidates:
00020 rospy.loginfo("- - - - - -")
00021 rospy.loginfo("itemname: %s", c.itemName)
00022 rospy.loginfo("category: %s", c.category)
00023 rospy.loginfo("score: %f", c.score)
00024 rospy.loginfo("imageUrl: %s", c.imageUrl)
00025
00026 callbackReceived = True
00027
00028 if __name__ == '__main__':
00029 rospy.init_node("image_recognition_publisher")
00030
00031 callbackReceived = False
00032
00033 rospy.wait_for_service("image_recognition")
00034 image_recognition = rospy.ServiceProxy("image_recognition", ImageRecognition)
00035
00036 sub = rospy.Subscriber("image", Image, cb)
00037
00038 while not rospy.is_shutdown() and not callbackReceived:
00039 rospy.sleep(1)