publish_mouse_event.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 
4 # copied from image_view2
5 # workaround until https://github.com/jsk-ros-pkg/jsk_common/pull/1774 is merged and released
6 #
7 
8 import cv2
9 import numpy as np
10 
11 import rospy
12 from sensor_msgs.msg import Image
13 import cv_bridge
14 from image_view2.msg import MouseEvent
15 
16 
17 def main():
18  pub_plus = rospy.Publisher('~plus_rect_event', MouseEvent, queue_size=1)
19  pub_minus = rospy.Publisher('~minus_rect_event', MouseEvent, queue_size=1)
20 
21  width = int(rospy.get_param('~image_width'))
22  height = int(rospy.get_param('~image_height'))
23  plus_events = [
24  MouseEvent(type=3, x=int(width/4), y=int(height/4), width=width, height=height),
25  MouseEvent(type=4, x=int(width/2), y=int(height/2), width=width, height=height),
26  MouseEvent(type=2, x=int(3*width/4), y=int(3*height/4), width=width, height=height),
27  ]
28  minus_events = [
29  MouseEvent(type=3, x=int(3*width/4), y=int(3*height/4), width=width, height=height),
30  MouseEvent(type=4, x=int(width/2), y=int(height/2), width=width, height=height),
31  MouseEvent(type=2, x=int(width/4), y=int(height/4), width=width, height=height),
32  ]
33  rate = rospy.Rate(10)
34  while not rospy.is_shutdown():
35  for e in plus_events:
36  e.header.stamp = rospy.get_rostime()
37  pub_plus.publish(e)
38  rate.sleep()
39  for e in minus_events:
40  e.header.stamp = rospy.get_rostime()
41  pub_minus.publish(e)
42  rate.sleep()
43 
44 
45 if __name__ == '__main__':
46  rospy.init_node('publish_mouse_event')
47  main()
ssd_train_dataset.int
int
Definition: ssd_train_dataset.py:175
publish_mouse_event.main
def main()
Definition: publish_mouse_event.py:17


jsk_perception
Author(s): Manabu Saito, Ryohei Ueda
autogenerated on Fri May 16 2025 03:11:17