當前位置: 首頁>>代碼示例>>Python>>正文


Python msg.CameraInfo方法代碼示例

本文整理匯總了Python中sensor_msgs.msg.CameraInfo方法的典型用法代碼示例。如果您正苦於以下問題:Python msg.CameraInfo方法的具體用法?Python msg.CameraInfo怎麽用?Python msg.CameraInfo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在sensor_msgs.msg的用法示例。


在下文中一共展示了msg.CameraInfo方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from sensor_msgs import msg [as 別名]
# 或者: from sensor_msgs.msg import CameraInfo [as 別名]
def __init__(self, camera_name, base_frame, table_height):
        """
        Initialize the instance

        :param camera_name: The camera name. One of (head_camera, right_hand_camera)
        :param base_frame: The frame for the robot base
        :param table_height: The table height with respect to base_frame
        """
        self.camera_name = camera_name
        self.base_frame = base_frame
        self.table_height = table_height

        self.image_queue = Queue.Queue()
        self.pinhole_camera_model = PinholeCameraModel()
        self.tf_listener = tf.TransformListener()

        camera_info_topic = "/io/internal_camera/{}/camera_info".format(camera_name)
        camera_info = rospy.wait_for_message(camera_info_topic, CameraInfo)

        self.pinhole_camera_model.fromCameraInfo(camera_info)

        cameras = intera_interface.Cameras()
        cameras.set_callback(camera_name, self.__show_image_callback, rectify_image=True) 
開發者ID:microsoft,項目名稱:AI-Robot-Challenge-Lab,代碼行數:25,代碼來源:cv_detection_camera_helper.py

示例2: build_camera_info

# 需要導入模塊: from sensor_msgs import msg [as 別名]
# 或者: from sensor_msgs.msg import CameraInfo [as 別名]
def build_camera_info(self, attributes):  # pylint: disable=no-self-use
        """
        Private function to compute camera info

        camera info doesn't change over time
        """
        camera_info = CameraInfo()
        # store info without header
        camera_info.header = None
        camera_info.width = int(attributes['width'])
        camera_info.height = int(attributes['height'])
        camera_info.distortion_model = 'plumb_bob'
        cx = camera_info.width / 2.0
        cy = camera_info.height / 2.0
        fx = camera_info.width / (
            2.0 * math.tan(float(attributes['fov']) * math.pi / 360.0))
        fy = fx
        camera_info.K = [fx, 0, cx, 0, fy, cy, 0, 0, 1]
        camera_info.D = [0, 0, 0, 0, 0]
        camera_info.R = [1.0, 0, 0, 0, 1.0, 0, 0, 0, 1.0]
        camera_info.P = [fx, 0, cx, 0, 0, fy, cy, 0, 0, 0, 1.0, 0]
        return camera_info 
開發者ID:carla-simulator,項目名稱:scenario_runner,代碼行數:24,代碼來源:ros_agent.py

示例3: make_camera_msg

# 需要導入模塊: from sensor_msgs import msg [as 別名]
# 或者: from sensor_msgs.msg import CameraInfo [as 別名]
def make_camera_msg(cam):
    camera_info_msg = CameraInfo()
    width, height = cam[0], cam[1]
    fx, fy = cam[2], cam[3]
    cx, cy = cam[4], cam[5]
    camera_info_msg.width = width
    camera_info_msg.height = height
    camera_info_msg.K = [fx, 0, cx,
                         0, fy, cy,
                         0, 0, 1]
                         
    camera_info_msg.D = [0, 0, 0, 0]
    
    camera_info_msg.P = [fx, 0, cx, 0,
                         0, fy, cy, 0,
                         0, 0, 1, 0]
    return camera_info_msg 
開發者ID:uzh-rpg,項目名稱:rpg_davis_simulator,代碼行數:19,代碼來源:dvs_simulator.py

示例4: __init__

# 需要導入模塊: from sensor_msgs import msg [as 別名]
# 或者: from sensor_msgs.msg import CameraInfo [as 別名]
def __init__(self):
        # Get the camera parameters
        cam_info_topic = rospy.get_param('~camera/info_topic')
        camera_info_msg = rospy.wait_for_message(cam_info_topic, CameraInfo)
        self.cam_K = np.array(camera_info_msg.K).reshape((3, 3))

        self.img_pub = rospy.Publisher('~visualisation', Image, queue_size=1)
        rospy.Service('~predict', GraspPrediction, self.compute_service_handler)

        self.base_frame = rospy.get_param('~camera/robot_base_frame')
        self.camera_frame = rospy.get_param('~camera/camera_frame')
        self.img_crop_size = rospy.get_param('~camera/crop_size')
        self.img_crop_y_offset = rospy.get_param('~camera/crop_y_offset')
        self.cam_fov = rospy.get_param('~camera/fov')

        self.counter = 0
        self.curr_depth_img = None
        self.curr_img_time = 0
        self.last_image_pose = None
        rospy.Subscriber(rospy.get_param('~camera/depth_topic'), Image, self._depth_img_callback, queue_size=1)

        self.waiting = False
        self.received = False 
開發者ID:dougsm,項目名稱:mvp_grasp,代碼行數:25,代碼來源:ggcnn_service.py

示例5: __init__

# 需要導入模塊: from sensor_msgs import msg [as 別名]
# 或者: from sensor_msgs.msg import CameraInfo [as 別名]
def __init__(self, node_name='naoqi_camera'):
        NaoqiNode.__init__(self, node_name)

        self.camProxy = self.get_proxy("ALVideoDevice")
        if self.camProxy is None:
            exit(1)
        self.nameId = None
        self.camera_infos = {}
        def returnNone():
            return None
        self.config = defaultdict(returnNone)

        # ROS publishers
        self.pub_img_ = rospy.Publisher('~image_raw', Image, queue_size=5)
        self.pub_info_ = rospy.Publisher('~camera_info', CameraInfo, queue_size=5)

        # initialize the parameter server
        self.srv = Server(NaoqiCameraConfig, self.reconfigure)

        # initial load from param server
        self.init_config()

        # initially load configurations
        self.reconfigure(self.config, 0) 
開發者ID:ros-naoqi,項目名稱:naoqi_bridge,代碼行數:26,代碼來源:naoqi_camera.py

示例6: __init__

# 需要導入模塊: from sensor_msgs import msg [as 別名]
# 或者: from sensor_msgs.msg import CameraInfo [as 別名]
def __init__(self, camera_name):
        self.left_cam_info_org = 0
        self.right_cam_info_org = 0

        # yamlファイルを読み込んでCameraInfoを返す
        left_file_name  = rospy.get_param('~left_file_name',  rospack.get_path('ps4eye')+'/camera_info/left.yaml')
        right_file_name = rospy.get_param('~right_file_name', rospack.get_path('ps4eye')+'/camera_info/right.yaml')
        self.left_cam_info = parse_yaml(left_file_name)
        self.right_cam_info = parse_yaml(right_file_name)
        left_topic = "/" + camera_name + "/left/camera_info"
        right_topic = "/" + camera_name + "/right/camera_info"
        # Timestampを合わせるためにsubする必要あり
        rospy.Subscriber("/null/left/camera_info", CameraInfo, self.leftCallback)
        rospy.Subscriber("/null/right/camera_info", CameraInfo, self.rightCallback)

        self.left_pub = rospy.Publisher(left_topic,CameraInfo) 
        self.right_pub = rospy.Publisher(right_topic,CameraInfo) 
開發者ID:longjie,項目名稱:ps4eye,代碼行數:19,代碼來源:camera_info_publisher.py

示例7: parse_yaml

# 需要導入模塊: from sensor_msgs import msg [as 別名]
# 或者: from sensor_msgs.msg import CameraInfo [as 別名]
def parse_yaml(filename):
    stream = file(filename, 'r')
    calib_data = yaml.load(stream)
    cam_info = CameraInfo()
    cam_info.width = calib_data['image_width']
    cam_info.height = calib_data['image_height']
    cam_info.K = calib_data['camera_matrix']['data']
    cam_info.D = calib_data['distortion_coefficients']['data']
    cam_info.R = calib_data['rectification_matrix']['data']
    cam_info.P = calib_data['projection_matrix']['data']
    cam_info.distortion_model = calib_data['distortion_model']
    cam_info.binning_x = calib_data['binning_x']
    cam_info.binning_y = calib_data['binning_y']
    cam_info.roi.x_offset = calib_data['roi']['x_offset']
    cam_info.roi.y_offset = calib_data['roi']['y_offset']
    cam_info.roi.height = calib_data['roi']['height']
    cam_info.roi.width = calib_data['roi']['width']
    cam_info.roi.do_rectify = calib_data['roi']['do_rectify']
    
    return cam_info 
開發者ID:longjie,項目名稱:ps4eye,代碼行數:22,代碼來源:camera_info_publisher.py

示例8: __init__

# 需要導入模塊: from sensor_msgs import msg [as 別名]
# 或者: from sensor_msgs.msg import CameraInfo [as 別名]
def __init__(self, fovy=75, altitude=1.0, port=11311, env=None) :
		self.fovy = fovy
		self.altitude = altitude
		self.spawned = False
		self.port = port
		self.env = env
		if self.env is None :
			self.env = os.environ
		
		self.K = np.zeros((3,3))
		self.K[0][0] = self.fovy
		self.K[1][1] = self.fovy
		self.K[2][2] = 1.0
		self.K = np.matrix(self.K)
		self.P = np.matrix( np.concatenate( [self.K, np.zeros((3,1)) ], axis=1) )
		
		self.camerainfo = None
		self.listener_camera_info = rospy.Subscriber( '/CAMERA/camera_info', CameraInfo, self.callbackCAMERAINFO )
		self.image = None
		self.bridge = CvBridge()
		self.listener_image = rospy.Subscriber( '/CAMERA/image_raw', Image, self.callbackIMAGE ) 
開發者ID:Near32,項目名稱:GazeboDomainRandom,代碼行數:23,代碼來源:GazeboDomainRandom.py

示例9: _build_camera_info

# 需要導入模塊: from sensor_msgs import msg [as 別名]
# 或者: from sensor_msgs.msg import CameraInfo [as 別名]
def _build_camera_info(self):
        """
        Private function to compute camera info

        camera info doesn't change over time
        """
        camera_info = CameraInfo()
        # store info without header
        camera_info.header = None
        camera_info.width = int(self.carla_actor.attributes['image_size_x'])
        camera_info.height = int(self.carla_actor.attributes['image_size_y'])
        camera_info.distortion_model = 'plumb_bob'
        cx = camera_info.width / 2.0
        cy = camera_info.height / 2.0
        fx = camera_info.width / (
            2.0 * math.tan(float(self.carla_actor.attributes['fov']) * math.pi / 360.0))
        fy = fx
        camera_info.K = [fx, 0, cx, 0, fy, cy, 0, 0, 1]
        camera_info.D = [0, 0, 0, 0, 0]
        camera_info.R = [1.0, 0, 0, 0, 1.0, 0, 0, 0, 1.0]
        camera_info.P = [fx, 0, cx, 0, 0, fy, cy, 0, 0, 0, 1.0, 0]
        self._camera_info = camera_info

    # pylint: disable=arguments-differ 
開發者ID:carla-simulator,項目名稱:ros-bridge,代碼行數:26,代碼來源:camera.py

示例10: onStart

# 需要導入模塊: from sensor_msgs import msg [as 別名]
# 或者: from sensor_msgs.msg import CameraInfo [as 別名]
def onStart(self):
        """ starting = start listening to depth images """
        self.sub_depth = rospy.Subscriber("/camera/depth_registered/image_raw", ImageMSG, self.incomingDepthData)
        self.cameraInfo = rospy.wait_for_message('/camera/depth_registered/camera_info', CamInfoMSG)
        self.cameraModel.fromCameraInfo(self.cameraInfo)
        rospy.loginfo("Camera info received") 
開發者ID:omwdunkley,項目名稱:crazyflieROS,代碼行數:8,代碼來源:trackManager.py

示例11: __init__

# 需要導入模塊: from sensor_msgs import msg [as 別名]
# 或者: from sensor_msgs.msg import CameraInfo [as 別名]
def __init__(self):

      # initialize ROS node and transform publisher
      rospy.init_node('crazyflie_detector', anonymous=True)
      self.pub_tf = tf.TransformBroadcaster()

      self.rate = rospy.Rate(50.0)                      # publish transform at 50 Hz

      # initialize values for crazyflie location on Kinect v2 image
      self.cf_u = 0                        # u is pixels left(0) to right(+)
      self.cf_v = 0                        # v is pixels top(0) to bottom(+)
      self.cf_d = 0                        # d is distance camera(0) to crazyflie(+) from depth image
      self.last_d = 0                      # last non-zero depth measurement

      # crazyflie orientation to Kinect v2 image (Euler)
      self.r = -1.5708
      self.p = 0
      self.y = -3.1415

      # Convert image from a ROS image message to a CV image
      self.bridge = CvBridge()

      cv2.namedWindow("KinectV2", 1)

      # Wait for the camera_info topic to become available
      rospy.wait_for_message('/kinect2/qhd/camera_info', CameraInfo)

      # Subscribe to Kinect v2 sd camera_info to get image frame height and width
      rospy.Subscriber('/kinect2/qhd/camera_info', CameraInfo, self.camera_data, queue_size=1)

      # Subscribe to registered color and depth images
      rospy.Subscriber('/kinect2/qhd/image_color_rect', Image, self.image_callback, queue_size=1)
      rospy.Subscriber('/kinect2/qhd/image_depth_rect', Image, self.depth_callback, queue_size=1)

      self.rate.sleep()                        # suspend until next cycle

   # This callback function sets parameters regarding the camera. 
開發者ID:PacktPublishing,項目名稱:ROS-Robotics-By-Example,代碼行數:39,代碼來源:detect_crazyflie.py

示例12: __callback_get_calibration_object

# 需要導入模塊: from sensor_msgs import msg [as 別名]
# 或者: from sensor_msgs.msg import CameraInfo [as 別名]
def __callback_get_calibration_object(self, _):
        if not self.__calibration_object.is_set():
            return GetCalibrationCamResponse(False, CameraInfo())
        msg_camera_info = CameraInfo()
        mtx, dist = self.__calibration_object.get_camera_info()
        msg_camera_info.K = list(mtx.flatten())
        msg_camera_info.D = list(dist.flatten())
        return GetCalibrationCamResponse(True, msg_camera_info) 
開發者ID:NiryoRobotics,項目名稱:niryo_one_ros,代碼行數:10,代碼來源:camera_publisher_and_services.py

示例13: subscribe

# 需要導入模塊: from sensor_msgs import msg [as 別名]
# 或者: from sensor_msgs.msg import CameraInfo [as 別名]
def subscribe(self):
        topic = "object_tracker/blob_info"
        self.centroid_sub = rospy.Subscriber(topic, BlobInfoArray, self.centroid_callback)
        self.pc_sub = rospy.Subscriber("/camera/depth_registered/points", PointCloud2, self.pc_callback)
        self.info_sub = rospy.Subscriber("/camera/rgb/camera_info", CameraInfo, self.info_callback) 
開發者ID:osrf,項目名稱:baxter_demos,代碼行數:7,代碼來源:get_goal_poses.py

示例14: subscribe

# 需要導入模塊: from sensor_msgs import msg [as 別名]
# 或者: from sensor_msgs.msg import CameraInfo [as 別名]
def subscribe(self):
        topic = "/object_tracker/blob_info"
        self.centroid_sub = rospy.Subscriber(topic, BlobInfoArray, self.centroid_callback)
        topic = "/robot/range/"+self.limb+"_hand_range/state"
        self.ir_sub = rospy.Subscriber(topic, Range, self.ir_callback)
        topic = "/cameras/"+self.limb+"_hand_camera/camera_info"
        self.info_sub = rospy.Subscriber(topic, CameraInfo, self.info_callback) 
開發者ID:osrf,項目名稱:baxter_demos,代碼行數:9,代碼來源:estimate_depth.py

示例15: __init__

# 需要導入模塊: from sensor_msgs import msg [as 別名]
# 或者: from sensor_msgs.msg import CameraInfo [as 別名]
def __init__(self):
        self.cv_bridge = CvBridge()
        self.camera_info_lock = threading.RLock()
        self.ar_tag_lock = threading.RLock()

        # Setup to control camera.
        self.joint_cmd_srv = rospy.ServiceProxy(JOINT_COMMAND_TOPIC, JointCommand)

        # Subscribe to camera pose and instrinsic streams.
        rospy.Subscriber(JOINT_STATE_TOPIC, JointState, self._camera_pose_callback)
        rospy.Subscriber(
            ROSTOPIC_CAMERA_INFO_STREAM, CameraInfo, self.camera_info_callback
        )
        self.img = None
        rospy.Subscriber(
            ROSTOPIC_CAMERA_IMAGE_STREAM,
            Image,
            lambda x: self.img_callback(x, "img", "bgr8"),
        )
        self.depth = None
        rospy.Subscriber(
            ROSTOPIC_CAMERA_DEPTH_STREAM,
            Image,
            lambda x: self.img_callback(x, "depth", None),
        )
        self.depth_registered = None
        rospy.Subscriber(
            ROSTOPIC_ALIGNED_CAMERA_DEPTH_STREAM,
            Image,
            lambda x: self.img_callback(x, "depth_registered", None),
        )
        rospy.Subscriber(ROSTOPIC_AR_POSE_MARKER, AlvarMarkers, self.alvar_callback)
        self.img = None
        self.ar_tag_pose = None

        self._transform_listener = TransformListener()
        self._update_camera_extrinsic = True
        self.camera_extrinsic_mat = None
        self.set_pan_pub = rospy.Publisher(ROSTOPIC_SET_PAN, Float64, queue_size=1)
        self.set_tilt_pub = rospy.Publisher(ROSTOPIC_SET_TILT, Float64, queue_size=1) 
開發者ID:facebookresearch,項目名稱:pyrobot,代碼行數:42,代碼來源:active_camera.py


注:本文中的sensor_msgs.msg.CameraInfo方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。