@@ -37,7 +37,14 @@ class OpenposeNode:
3737 self ._openpose_wrapper = OpenposeWrapper (model_folder , pose_model , net_input_size , net_output_size , num_scales ,
3838 scale_gap , num_gpu_start , overlay_alpha , python_path )
3939
40- # We need this q construction because openpose python is not thread safe
40+ # We need this q construction because openpose python is not thread safe and the rospy client side library
41+ # uses a thread per pub/sub and service. Since the openpose wrapper is created in the main thread, we have
42+ # to communicate our openpose requests (inputs) to the main thread where the request is processed by the
43+ # openpose wrapper (step 1).
44+ # We have a separate spin loop in the main thead that checks whether there are items in the input q and
45+ # processes these using the Openpose wrapper (step 2).
46+ # When the processing has finished, we add the result in the corresponding output queue (specified by the
47+ # request in the input queue) (step 3).
4148 self ._input_q = Queue () # image_msg, save_images, publish_images, is_service_request
4249 self ._service_output_q = Queue () # recognitions
4350 self ._subscriber_output_q = Queue () # recognitions
@@ -113,7 +120,7 @@ class OpenposeNode:
113120
114121 def spin (self ):
115122 """
116- We have to do this weird q construction since the openpose python API is not thread safe
123+ Empty input queues and fill output queues (see __init__ doc)
117124 """
118125 while not rospy .is_shutdown ():
119126 try :
0 commit comments