ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Unable to save image captued from Baxter

asked 2017-02-23 15:20:11 -0600

Joy16 gravatar image

Hi all!

I am getting two images. One from Baxter's camera and another from Sofkinectic 3D senz camera. I am able to save the 3D senz's camera otuput(topic is: /softkinetic_camera/depth/image_raw) but not the Baxer's(topic is: /cameras/right_hand__camera/image)

Can you please tell me what is going wrong here?

3 import sys
  4 import cv2
  5 import rospy
  6 from std_msgs.msg import String
  7 from sensor_msgs.msg import Image
  8 from sensor_msgs.msg import PointCloud2
  9 from cv_bridge import CvBridge, CvBridgeError
 10 import numpy as np
 11 
 12 #import pcl
 13 
 14 class ImgCapture:
 15     def __init__(self):
 16         self.CvImg = CvBridge()
 17         #/softkinetic_camera/rgb/image_color
 18         skImg = rospy.Subscriber("/cameras/right_hand__camera/image",Image, self.callback)  #BAXTER
 19         skDep = rospy.Subscriber("/softkinetic_camera/depth/image_raw",Image, self.callbackDepth) #3D SENZ
 24         ''' '''
 25     def callback(self, data):
 26         print "Processing RGB"
 27         try:
 28               NewImg = self.CvImg.imgmsg_to_cv2(data,"bgr8")
 29               print data.encoding
 30               print
 31               cv2.imwrite("hand.png", NewImg)
 32         except CvBridgeError as e:
 33               print(e)
 34 
 35     def callbackDepth(self, data):
 36         print "Processin depth data from 3D senz"
 37         try:
 38           NewImg = self.CvImg.imgmsg_to_cv2(data,"passthrough")
 39           depth_array = np.array(NewImg, dtype=np.float32)
 40           cv2.normalize(depth_array, depth_array, 0, 1, cv2.NORM_MINMAX)
 41           print data.encoding
 42           print
 43           cv2.imwrite("depth_cam.png", depth_array*255)
 44         except CvBridgeError as e:
 45           print(e)
 46 
 47 def main(args):
 48     ic = ImgCapture()
 49     rospy.init_node("capture_images", anonymous=True)
 50 
 51     try:
 52         rospy.spin()
 53     except KeyboardInterrupt:
 54         print("Wooahh,..error")
 55     cv2.destroyAllWindows()
 56 
 57 
 58 if __name__ == '__main__':
 59     main(sys.argv)
 60

Output is:

Processin depth data from 3D senz
32FC1

Processin depth data from 3D senz
32FC1

Processin depth data from 3D senz
32FC1
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2017-03-09 12:19:42 -0600

imcmahon gravatar image

On line 18, "/cameras/right_hand__camera/image" has one too many underscores. The topic name for images from the right hand camera should be /cameras/right_hand_camera/image.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-02-23 15:20:11 -0600

Seen: 422 times

Last updated: Mar 09 '17