Getting images from both cameras in sawyer

Homagni Saha

Recommended Posts

I was recently trying to follow along the code for displaying two camera images from the sawyer one-handed robot.

Now the camera interface in sawyer does not allow to have two cameras on, but I need it !, so I did :
(after installing sawyer gazebo from here :

    import argparse
    import numpy as np
    import cv2
    from cv_bridge import CvBridge, CvBridgeError
    import rospy
    import intera_interface
    from sensor_msgs.msg import Image
    import message_filters
    def img_callback(image_hand,image_head):
        bridge1 = CvBridge()
        bridge2 = CvBridge()
          cv_image1 = bridge1.imgmsg_to_cv2(image_hand, "mono8")
        except CvBridgeError as e:
        cv2.imshow("Hand Image window", cv_image1)
        cur_image_hand=cv2.resize(cv_image1, (80, 80))
          cv_image2 = bridge2.imgmsg_to_cv2(image_head, "bgr8")
        except CvBridgeError as e:
        cv2.imshow("Head Image window", cv_image2)
        gray_image = cv2.cvtColor(cv_image2, cv2.COLOR_BGR2GRAY)
        cur_image_head=cv2.resize(gray_image, (80, 80))
    def main():
        rospy.init_node('image_converter', anonymous=True)
        image_sub_hand = message_filters.Subscriber("/io/internal_camera/right_hand_camera/image_rect",Image) 
        image_sub_head = message_filters.Subscriber("/io/internal_camera/head_camera/image_rect_color",Image)
        #ts = message_filters.TimeSynchronizer([self.image_sub_hand, self.image_sub_head], 10)
        ts = message_filters.TimeSynchronizer([image_sub_hand, image_sub_head], 10)

    if __name__ == '__main__':

This code starts with both the images showing nicely together in two seperate windows for a few seconds, but after that both the cv windows blacken out and images are not updated anymore .
Please suggest what to do, and provide me the best solution that allows me to access these two topics at any time using python code.

Link to comment
Share on other sites

  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.