Skip to content

Commit

Permalink
Merge pull request #2800 from tkmtnt7000/PR-support-compressed-vil
Browse files Browse the repository at this point in the history
[jsk_perception] Support compressed type image in vil_inference_client.py
  • Loading branch information
k-okada authored Nov 7, 2023
2 parents 03052c7 + 3d51fa8 commit 7937653
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
2 changes: 2 additions & 0 deletions jsk_perception/launch/classification.launch
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<arg name="gui" default="false" />
<arg name="run_api" default="false" />
<arg name="CLASSIFICATION_INPUT_IMAGE" default="image" />
<arg name="image_transport" default="raw" />

<node name="classification_api" pkg="jsk_perception" type="run_jsk_vil_api" output="log"
args="clip -p $(arg port)" if="$(arg run_api)" />
Expand All @@ -14,6 +15,7 @@
<rosparam subst_value="true">
host: $(arg host)
port: $(arg port)
image_transport: $(arg image_transport)
</rosparam>
</node>

Expand Down
2 changes: 2 additions & 0 deletions jsk_perception/launch/vqa.launch
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<arg name="gui" default="false" />
<arg name="run_api" default="false" />
<arg name="VQA_INPUT_IMAGE" default="vqa_image" />
<arg name="image_transport" default="raw" />

<node name="ofa_api" pkg="jsk_perception" type="run_jsk_vil_api" output="log"
args="ofa -p $(arg port)" if="$(arg run_api)" />
Expand All @@ -14,6 +15,7 @@
<rosparam subst_value="true">
host: $(arg host)
port: $(arg port)
image_transport: $(arg image_transport)
</rosparam>
</node>

Expand Down
24 changes: 19 additions & 5 deletions jsk_perception/src/jsk_perception/vil_inference_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,27 @@ def __init__(self, action,
# default inference image
self.default_img = None
# ROS
self.image_sub = rospy.Subscriber("~image", Image,
callback=self.topic_cb,
queue_size=1,
buff_size=2**26)
self.transport_hint = rospy.get_param('~image_transport', 'raw')
if self.transport_hint == 'compressed':
self.image_sub = rospy.Subscriber(
"{}/compressed".format(rospy.resolve_name('~image')),
CompressedImage,
callback=self.topic_cb,
queue_size=1,
buff_size=2**26
)

else:
self.image_sub = rospy.Subscriber("~image", Image,
callback=self.topic_cb,
queue_size=1,
buff_size=2**26)
self.result_topic_type = result_topic
self.result_pub = rospy.Publisher("~result", result_topic, queue_size=1)
self.image_pub = rospy.Publisher("~result/image", Image, queue_size=1)
if self.transport_hint == 'compressed':
self.image_pub = rospy.Publisher("~result/image/compressed", CompressedImage, queue_size=1)
else:
self.image_pub = rospy.Publisher("~result/image", Image, queue_size=1)
self.vis_pub = rospy.Publisher("~visualize", String, queue_size=1)
self.action_server = actionlib.SimpleActionServer("~inference_server",
action,
Expand Down

0 comments on commit 7937653

Please sign in to comment.