@@ -7,12 +7,14 @@ from sensor_msgs.msg import Image
7
7
8
8
from image_recognition_msgs .srv import Recognize
9
9
10
- class ExtractColorClient ( object ) :
10
+ class ExtractColorClient :
11
11
def __init__ (self , image_topic , color_service ):
12
- self .image_sub = rospy .Subscriber (image_topic , Image , self .color_callback )
13
12
self .color_proxy = rospy .ServiceProxy (color_service , Recognize )
14
13
self .color_proxy .wait_for_service (timeout = 20 )
15
14
15
+ # Subscriber will start immediately
16
+ self .image_sub = rospy .Subscriber (image_topic , Image , self .color_callback )
17
+
16
18
def color_callback (self , msg ):
17
19
# Simply print out values in our custom message.
18
20
colors = self .color_proxy (msg )
@@ -22,10 +24,11 @@ if __name__ == '__main__':
22
24
23
25
parser = argparse .ArgumentParser (description = 'Get dominant colors from image' )
24
26
parser .add_argument ('--topic' , default = '/image' , type = str , help = 'Topic' )
27
+ parser .add_argument ('--service' , default = 'extract_color' , type = str , help = 'Service' )
25
28
args = parser .parse_args ()
26
29
27
30
rospy .init_node ('color_extractor_stream' )
28
31
29
- extract_color_client = ExtractColorClient (args .topic , 'extract_color' )
32
+ extract_color_client = ExtractColorClient (args .topic , args . service )
30
33
31
34
rospy .spin ()
0 commit comments