openni_imgrect_to_shm.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 import rospy
4 import os
5 from sensor_msgs.msg import Image
6 
7 '''
8 rostopic info /camera/depth/image_rect
9 Type: sensor_msgs/Image
10 
11 rosmsg show sensor_msgs/Image
12 std_msgs/Header header
13  uint32 seq
14  time stamp
15  string frame_id
16 uint32 height
17 uint32 width
18 string encoding
19 uint8 is_bigendian
20 uint32 step
21 uint8[] data
22 '''
23 
24 def imgrect_callBack(data):
25  lockfilepath = "/run/shm/xtion.raw.lock"
26  framefilepath ="/run/shm/xtion.raw"
27 
28  if os.path.exists(lockfilepath):
29  return
30 
31  open(lockfilepath, 'w') # creates lockfile
32 
33  framefile = open(framefilepath, 'w')
34  framefile.write(data.data)
35  framefile.close()
36 
37  if os.path.exists(lockfilepath):
38  os.remove(lockfilepath)
39 
40  # print data.width # yeilds 640 default
41  # print data.is_bigendian # yeilds 0 default
42  # print data.encoding # yeilds 32FC1
43  # rospy.signal_shutdown("shutdown")
44 
45 
46 rospy.init_node('openni_imgrect_to_shm', anonymous=False)
47 rospy.Subscriber("camera/depth/image_raw", Image, imgrect_callBack)
48 
49 rospy.spin()


oculusprime
Author(s): Colin Adamson
autogenerated on Wed Mar 10 2021 03:14:59