#!/usr/bin/env python
import roslib
#roslib.load_manifest('panorama_project')
import sys
import rospy
import cv2 as cv
from std_msgs.msg import String
from sensor_msgs.msg import Image
from cv_bridge import CvBridge, CvBridgeError
import message_filters
from cv_bridge import CvBridge, CvBridgeError
import rospy
from std_msgs.msg import String

def callback_color(cam1_color, cam2_color):
	# self.bridge = CvBridge()
	try:
		cv_image_cam1 = CvBridge().imgmsg_to_cv2(cam1_color, "bgr8")
	except CvBridgeError, e:
		print e	

	try:
		cv_image_cam2 = CvBridge().imgmsg_to_cv2(cam2_color, "bgr8")
	except CvBridgeError, e:
		print e	
	cv2.imshow('color1: ', cv_image_cam1)
	cv2.imshow('color2: ', cv_image_cam2)
	cv2.waitKey(3)	
    
def listener():
	rospy.init_node('color_pano', anonymous=True)
	# cam1_color_sub = message_filters.Subscriber("/R_007/cam_1/color/image_raw", Image)
	# cam2_color_sub = message_filters.Subscriber("/R_007/cam_2/color/image_raw", Image)
	cam1_color_sub = message_filters.Subscriber("/rs_cam_1/color/image_raw", Image)
	cam2_color_sub = message_filters.Subscriber("/rs_cam_2/color/image_raw", Image)
	ts = message_filters.TimeSynchronizer([cam1_color_sub, cam2_color_sub], 10)
	ts.registerCallback(callback_color)
    # spin() simply keeps python from exiting until this node is stopped
	rospy.spin()

if __name__ == '__main__':
	listener()
