当前位置: 首页>>代码示例>>Python>>正文


Python Image.header方法代码示例

本文整理汇总了Python中sensor_msgs.msg.Image.header方法的典型用法代码示例。如果您正苦于以下问题:Python Image.header方法的具体用法?Python Image.header怎么用?Python Image.header使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sensor_msgs.msg.Image的用法示例。


在下文中一共展示了Image.header方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: default

# 需要导入模块: from sensor_msgs.msg import Image [as 别名]
# 或者: from sensor_msgs.msg.Image import header [as 别名]
    def default(self, ci="unused"):
        if not self.component_instance.capturing:
            return  # press [Space] key to enable capturing

        image_local = self.data["image"]

        image = Image()
        image.header = self.get_ros_header()
        image.header.frame_id += "/base_image"
        image.height = self.component_instance.image_height
        image.width = self.component_instance.image_width
        image.encoding = "rgba8"
        image.step = image.width * 4

        # VideoTexture.ImageRender implements the buffer interface
        image.data = bytes(image_local)

        # fill this 3 parameters to get correcty image with stereo camera
        Tx = 0
        Ty = 0
        R = [1, 0, 0, 0, 1, 0, 0, 0, 1]

        intrinsic = self.data["intrinsic_matrix"]

        camera_info = CameraInfo()
        camera_info.header = image.header
        camera_info.height = image.height
        camera_info.width = image.width
        camera_info.distortion_model = "plumb_bob"
        camera_info.K = [
            intrinsic[0][0],
            intrinsic[0][1],
            intrinsic[0][2],
            intrinsic[1][0],
            intrinsic[1][1],
            intrinsic[1][2],
            intrinsic[2][0],
            intrinsic[2][1],
            intrinsic[2][2],
        ]
        camera_info.R = R
        camera_info.P = [
            intrinsic[0][0],
            intrinsic[0][1],
            intrinsic[0][2],
            Tx,
            intrinsic[1][0],
            intrinsic[1][1],
            intrinsic[1][2],
            Ty,
            intrinsic[2][0],
            intrinsic[2][1],
            intrinsic[2][2],
            0,
        ]

        self.publish(image)
        self.topic_camera_info.publish(camera_info)
开发者ID:davidhodo,项目名称:morse,代码行数:60,代码来源:video_camera.py

示例2: copy_Image_empty_data

# 需要导入模块: from sensor_msgs.msg import Image [as 别名]
# 或者: from sensor_msgs.msg.Image import header [as 别名]
def copy_Image_empty_data(image_old):
    image_new = Image()
    image_new.header = copy(image_old.header)
    image_new.height = copy(image_old.height)
    image_new.width = copy(image_old.width)
    image_new.encoding = copy(image_old.encoding)
    image_new.is_bigendian = copy(image_old.is_bigendian)
    image_new.step = copy(image_old.step)
    return image_new
开发者ID:MatthewRueben,项目名称:rgbd-range-privacy-filter,代码行数:11,代码来源:range_filter.py

示例3: OccupancyGridToNavImage

# 需要导入模块: from sensor_msgs.msg import Image [as 别名]
# 或者: from sensor_msgs.msg.Image import header [as 别名]
 def OccupancyGridToNavImage(self, grid_map):
     img = Image()
     img.header = grid_map.header
     img.height = grid_map.info.height
     img.width = grid_map.info.width
     img.is_bigendian = 1
     img.step = grid_map.info.width
     img.encoding = "mono8"
     maxindex = img.height*img.width
     numpy.uint
     for i in range(0, maxindex, 1):
         if int(grid_map.data[i]) < 20:
             #img.data[i] = "0"
             data.append(0)
         else:
             img.data[i] = "255"
     return imgding
开发者ID:ipa-fmw-ce,项目名称:cob_automated_planning,代码行数:19,代码来源:map_analyzer.py

示例4: default

# 需要导入模块: from sensor_msgs.msg import Image [as 别名]
# 或者: from sensor_msgs.msg.Image import header [as 别名]
    def default(self, ci='unused'):
        if not self.component_instance.capturing:
            return # press [Space] key to enable capturing

        image_local = self.data['image']

        image = Image()
        image.header = self.get_ros_header()
        image.height = self.component_instance.image_height
        image.width = self.component_instance.image_width
        image.encoding = self.encoding
        image.step = image.width * 4

        # VideoTexture.ImageRender implements the buffer interface
        image.data = bytes(image_local)

        # fill this 3 parameters to get correcty image with stereo camera
        Tx = 0
        Ty = 0
        R = [1, 0, 0, 0, 1, 0, 0, 0, 1]

        intrinsic = self.data['intrinsic_matrix']

        camera_info = CameraInfo()
        camera_info.header = image.header
        camera_info.height = image.height
        camera_info.width = image.width
        camera_info.distortion_model = 'plumb_bob'
        camera_info.D = [0]
        camera_info.K = [intrinsic[0][0], intrinsic[0][1], intrinsic[0][2],
                         intrinsic[1][0], intrinsic[1][1], intrinsic[1][2],
                         intrinsic[2][0], intrinsic[2][1], intrinsic[2][2]]
        camera_info.R = R
        camera_info.P = [intrinsic[0][0], intrinsic[0][1], intrinsic[0][2], Tx,
                         intrinsic[1][0], intrinsic[1][1], intrinsic[1][2], Ty,
                         intrinsic[2][0], intrinsic[2][1], intrinsic[2][2], 0]

        if self.pub_tf:
            self.publish_with_robot_transform(image)
        else:
            self.publish(image)
        self.topic_camera_info.publish(camera_info)
开发者ID:DAInamite,项目名称:morse,代码行数:44,代码来源:video_camera.py

示例5: default

# 需要导入模块: from sensor_msgs.msg import Image [as 别名]
# 或者: from sensor_msgs.msg.Image import header [as 别名]
    def default(self, ci='unused'):
        """ Publish the data of the Camera as a ROS Image message. """
        if not self.component_instance.capturing:
            return # press [Space] key to enable capturing

        image_local = self.data['image']

        image = Image()
        image.header = self.get_ros_header()
        image.header.frame_id += '/base_image'
        image.height = self.component_instance.image_height
        image.width = self.component_instance.image_width
        image.encoding = 'rgba8'
        image.step = image.width * 4

        # VideoTexture.ImageRender implements the buffer interface
        image.data = bytes(image_local)

        # sensor_msgs/CameraInfo [ http://ros.org/wiki/rviz/DisplayTypes/Camera ]
        # fill this 3 parameters to get correcty image with stereo camera
        Tx = 0
        Ty = 0
        R = [1, 0, 0, 0, 1, 0, 0, 0, 1]

        intrinsic = self.data['intrinsic_matrix']

        camera_info = CameraInfo()
        camera_info.header = image.header
        camera_info.height = image.height
        camera_info.width = image.width
        camera_info.distortion_model = 'plumb_bob'
        camera_info.K = [intrinsic[0][0], intrinsic[0][1], intrinsic[0][2],
                         intrinsic[1][0], intrinsic[1][1], intrinsic[1][2],
                         intrinsic[2][0], intrinsic[2][1], intrinsic[2][2]]
        camera_info.R = R
        camera_info.P = [intrinsic[0][0], intrinsic[0][1], intrinsic[0][2], Tx,
                         intrinsic[1][0], intrinsic[1][1], intrinsic[1][2], Ty,
                         intrinsic[2][0], intrinsic[2][1], intrinsic[2][2], 0]

        self.publish(image)
        self.topic_camera_info.publish(camera_info)
开发者ID:matrixchan,项目名称:morse,代码行数:43,代码来源:video_camera.py

示例6: find_object

# 需要导入模块: from sensor_msgs.msg import Image [as 别名]
# 或者: from sensor_msgs.msg.Image import header [as 别名]
    def find_object(self):
        with self.lock_depth:
            image_data = self.image_data
            depth_data = self.depth_data

        pub_data = rospy.Publisher('/racecar/image/data', Float64MultiArray, queue_size=1)
        arrayData = Float64MultiArray()
        #print "received image"
        if image_data:
            newImage = Image()
            newImage.encoding = image_data.encoding
            newImage.header = image_data.header
            newImage.is_bigendian = image_data.is_bigendian

            newData = bytearray()
            image = image_data.data
            clusters = []
            white = chr(255) *3
            black = chr(0) * 3
            red = chr(0) + chr(0) + chr(255)
            blue = chr(255) + chr(0) * 2

            #defining color search thresholds
            redThreshold = 230
            blueThreshold = 20
            greenLowerThreshold = 50
            greenUpperThreshold = 200
            
            height = 0
            starttime = time.time()

            for h in xrange(0, image_data.height, self.resolution):
                height += 1
                for w in xrange(0, image_data.width, self.resolution):
                    index = w * 3 + image_data.width * 3 * h
                    b = ord(image[index])
                    g = ord(image[index + 1])
                    r = ord(image[index + 2])
                    #filtering for the color
                    if r > redThreshold and b < blueThreshold and g <= greenUpperThreshold and g >= greenLowerThreshold:
                        for char in white:
                            newData.append(char)
                        inCluster = False
                        for cluster in clusters:
                            if self.checkAdjacency((w, h), cluster):
                                cluster.add((w, h))
                                inCluster = True
                        if not inCluster:
                            newCluster = set()
                            newCluster.add((w, h))
                            clusters.append(newCluster)
                    else:
                        for char in black:
                            newData.append(char)

                
            newImage.height = height
            newImage.width = len(newData)/height/3
            newImage.step = len(newData)/height
            newImage.data = str(newData)


            #print 'time taken: ', time.time() - starttime
            
            clusters = self.reduceClusters(clusters)
            #print len(clusters), float(len(candidates_x))/len(newData)
            #print [len(cluster) for cluster in clusters]
            if len(clusters) > 1:
                print "multiple objects found"
                print [len(cluster) for cluster in clusters]

            if len(clusters):
                publishableClusters = [max(clusters, key=lambda x:len(x))]
                data_to_publish = []
                for cluster in publishableClusters:
                    centerX = sum(x for (x, y) in cluster)/len(cluster)
                    centerY = sum(y for (x, y) in cluster)/len(cluster)
                    width = max(cluster, key=lambda (x, y):x)[0] - min(cluster, key=lambda (x, y):x)[0]
                    height = max(cluster, key=lambda (x, y):y)[1] - min(cluster, key=lambda (x, y):y)[1]
                    relativeLocation = float(centerX)/image_data.width - 0.5
                    relativeAngle = relativeLocation * 100 * math.pi / 180
                    data_to_publish += [centerX, centerY, width, height, relativeAngle]
                    #print 'center ', centerX, centerY, len(candidates_x)
                    #print 'distance ', depth1, depth2
                    #print 'dim ', height, width
                    '''depth_index = centerX * 2 + image_data.width * 2 * centerY
                    depth1 = ord(depth_data.data[depth_index])
                    depth2 = ord(depth_data.data[depth_index + 1])'''

                arrayData.data = data_to_publish
            else:

                arrayData.data = [-1, -1, -1, -1, -1]
                print 'no cone found'
            pub_data.publish(arrayData)
            #print "publishing"
            pub_img = rospy.Publisher('/racecar/image/newImage', Image, queue_size=1)
            pub_img.publish(newImage)
        else:
            arrayData.data = [-1, -1, -1, -1]
#.........这里部分代码省略.........
开发者ID:plancherb1,项目名称:6.141-All-Code,代码行数:103,代码来源:image_parser.py


注:本文中的sensor_msgs.msg.Image.header方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。