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


Python CompressedImage.format方法代码示例

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


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

示例1: callback_right_with_3D

# 需要导入模块: from sensor_msgs.msg import CompressedImage [as 别名]
# 或者: from sensor_msgs.msg.CompressedImage import format [as 别名]
    def callback_right_with_3D(self, ros_data):
	'''Callback function of subscribed topic. 
        Here images get converted and features detected'''
        self.right_header = ros_data.header.stamp.secs        
        
        #### direct conversion to CV2 ####
        np_arr = np.fromstring(ros_data.data, np.uint8)
        image_np = cv2.imdecode(np_arr, 1)

        # convert np image to grayscale
        gray_image = cv2.cvtColor(image_np, cv2.COLOR_BGR2GRAY)

        if self.right_header == self.left_header and self.group_4_recieved:
            s_t = time.clock()
            print self.right_header, self.left_header
            self.group_4_recieved = False

            left_gray = cv2.cvtColor(self.left_image, cv2.COLOR_BGR2GRAY)

            group_4_out = self.group_4
            
#            PointCloudPose()
#            group_4_out.header = self.group_4.header
#std_msgs/Int16 pose_id
#std_msgs/Int16 pose_id_max
#sensor_msgs/CompressedImage image_left
#sensor_msgs/CompressedImage image_right
#geometry_msgs/Pose spin_center_pose
#sensor_msgs/PointCloud2 carmine_pointcloud 
#geometry_msgs/Pose carmine_pose
#sensor_msgs/PointCloud2 bumblebee_pointcloud
#geometry_msgs/Pose bumblebee_pose_left
#geometry_msgs/Pose bumblebee_pose_right            
            
            

            msg = CompressedImage()
            msg.header.stamp = rospy.Time.now()
            msg.format = "jpeg"
            msg.data = np.array(cv2.imencode('.jpg', left_gray)[1]).tostring()
            # Publish new image
            group_4_out.image_left = msg
            
            msg = CompressedImage()
            msg.header.stamp = rospy.Time.now()
            msg.format = "jpeg"
            msg.data = np.array(cv2.imencode('.jpg', gray_image)[1]).tostring()
            # Publish new image
            group_4_out.image_right = msg
            
            #group_4_out.bumblebee_pointcloud = pcloud            
            self.pub_group.publish(group_4_out)

            print "save time", time.clock() - s_t       
开发者ID:RobTek8Grp,项目名称:RoVi,代码行数:56,代码来源:stereo_get_images.py

示例2: __init__

# 需要导入模块: from sensor_msgs.msg import CompressedImage [as 别名]
# 或者: from sensor_msgs.msg.CompressedImage import format [as 别名]
    def __init__(self):
        # Get the ~private namespace parameters from command line or launch file.
        self.UDP_IP = rospy.get_param('~UDP_IP', '192.168.50.37') #get_ip.get_local()
        #if self.UDP_IP != 'localhost':
        #    self.UDP_IP = int(self.UDP_IP)
        self.UDP_PORT = int(rospy.get_param('~UDP_PORT', '49155'))

        # Create a dynamic reconfigure server.
        #self.server = DynamicReconfigureServer(ConfigType, self.reconfigure)
        
        # create ros::Publisher to send Odometry messages
        cam_pub = rospy.Publisher('image_raw/compressed', CompressedImage)

        #crappy test
        t = True
        while not rospy.is_shutdown():
            #crappy test continued
            if t:
                print "Camera Running"
            t = False

            udp_string = self.receive_packet()
            jpg_string = self.parse_string(udp_string)

            cam_msg = CompressedImage()
            cam_msg.header.stamp = rospy.Time.now() #YOYOYOYO - should be from robot time
            cam_msg.format = "jpeg"
            cam_msg.data = jpg_string

            cam_pub.publish(cam_msg)
开发者ID:mattjrush,项目名称:tankbot,代码行数:32,代码来源:cam_pub.py

示例3: grabAndPublish

# 需要导入模块: from sensor_msgs.msg import CompressedImage [as 别名]
# 或者: from sensor_msgs.msg.CompressedImage import format [as 别名]
    def grabAndPublish(self,stream,publisher):
        # Grab image from stream
        stream.seek(0)
        img_data = stream.getvalue()

        if self.uncompress:
            # Publish raw image
            data = np.fromstring(img_data, dtype=np.uint8)
            image = cv2.imdecode(data, 1)
            image_msg = self.bridge.cv2_to_imgmsg(image)
        else:
            # Publish compressed image only
            image_msg = CompressedImage()
            image_msg.data = img_data
            image_msg.format = "jpeg"
            
        image_msg.header.stamp = rospy.Time.now()
        # Publish 
        publisher.publish(image_msg)
        # Clear stream
        stream.seek(0)
        stream.truncate()

        if not self.has_published:
            rospy.loginfo("[%s] Published the first image." %(self.node_name))
            self.has_published = True
开发者ID:71ananab,项目名称:Software,代码行数:28,代码来源:camera_node_continuous.py

示例4: ros_compressed_from_numpygray

# 需要导入模块: from sensor_msgs.msg import CompressedImage [as 别名]
# 或者: from sensor_msgs.msg.CompressedImage import format [as 别名]
def ros_compressed_from_numpygray(np_arr):
    msg = CompressedImage()
    msg.header.stamp = rospy.Time.now()
    msg.format = "jpeg"
    np_arr = 255*(1.0*np_arr/np.max(np_arr))
    msg.data = np.array(cv2.imencode('.jpg', np.array(np_arr, dtype = np.uint8))[1]).tostring()
    return msg
开发者ID:ChuangWang-Zoox,项目名称:Software,代码行数:9,代码来源:LEDDetector.py

示例5: publish

# 需要导入模块: from sensor_msgs.msg import CompressedImage [as 别名]
# 或者: from sensor_msgs.msg.CompressedImage import format [as 别名]
 def publish(self, raw_img):
     msg = CompressedImage()
     msg.header.stamp = rospy.Time.now()
     msg.format = "jpeg"
     msg.data = np.array(cv2.imencode(".jpg", raw_img)[1]).tostring()
     # TODO compile sensor_msg error , use String instead
     self.image_pub.publish(msg.data)
开发者ID:rli9,项目名称:slam,代码行数:9,代码来源:image_publisher.py

示例6: handle_pkt

# 需要导入模块: from sensor_msgs.msg import CompressedImage [as 别名]
# 或者: from sensor_msgs.msg.CompressedImage import format [as 别名]
def handle_pkt(pkt=None):
    ts_begin_loc = pkt.find(begin_timestamp_marker)
    ts_end_loc = pkt.find(end_timestamp_marker)

    if ts_begin_loc == -1 or ts_end_loc == -1:
        #something's fishy, discard jpeg
        print "JPEG discarded, malformed data"
        return 
        
    ts = float(pkt[ts_begin_loc+len(begin_timestamp_marker):ts_end_loc])
	
#    if ts > last_ts:
#	last_ts = ts
#    else:
#	return

    pkt = pkt[ts_end_loc+len(end_timestamp_marker):]

    print "{} bytes of JPEG recvd".format(len(pkt))
    msg = CompressedImage()
    msg.header.stamp  = rospy.Time(tango_clock_offset + float(ts))
    msg.header.frame_id = camera_name
    msg.data = pkt
    msg.format = 'jpeg'
    pub_camera.publish(msg)
开发者ID:DhashS,项目名称:tango_ros_bridge,代码行数:27,代码来源:image_server.py

示例7: stream

# 需要导入模块: from sensor_msgs.msg import CompressedImage [as 别名]
# 或者: from sensor_msgs.msg.CompressedImage import format [as 别名]
  def stream(self):
    url = 'http://%s:%[email protected]%s/mjpg/video.mjpg' % (self.axis.username, self.axis.password, self.axis.hostname)
    #url = url + "?resolution=%dx%d" % (self.axis.width, self.axis.height)
    fp = urllib.urlopen(url)

    while True:
      boundary = fp.readline()

      header = {}
      while 1:
        line = fp.readline()
        if line == "\r\n": break
        line = line.strip()

        parts = line.split(": ", 1)
        header[parts[0]] = parts[1]

      content_length = int(header['Content-Length'])

      img = fp.read(content_length)
      line = fp.readline()
      
      msg = CompressedImage()
      msg.header.stamp = rospy.Time.now()
      msg.header.frame_id = self.axis_frame_id
      msg.format = "jpeg"
      msg.data = img

      self.axis.pub.publish(msg)

      """
开发者ID:hkaraoguz,项目名称:axis_cameraHK,代码行数:33,代码来源:axis.py

示例8: callback

# 需要导入模块: from sensor_msgs.msg import CompressedImage [as 别名]
# 或者: from sensor_msgs.msg.CompressedImage import format [as 别名]
  def callback(self, ros_data):
    #### direct conversion to CV2 ####
    np_arr = np.fromstring(ros_data.data, np.uint8)
    image_np = cv2.imdecode(np_arr, cv2.CV_LOAD_IMAGE_COLOR)
    
    #(rows,cols,channels) = image_np.shape
    #image_np = image_np[0:64, 0:480] 

    #equ = cv2.equalizeHist(image_np)
    #res = np.hstack((image_np,equ))

    #### Feature detectors using CV2 #### 
    # "","Grid","Pyramid" + 
    # "FAST","GFTT","HARRIS","MSER","ORB","SIFT","STAR","SURF", "GridFAST"
    #method = "GridFAST"
    #feat_det = cv2.FeatureDetector_create(method)
    #time1 = time.time()

    # convert np image to grayscale
    #featPoints = feat_det.detect( cv2.cvtColor(image_np, cv2.COLOR_BGR2GRAY))
    #time2 = time.time()
    #if VERBOSE :
    #  print '%s detector found: %s points in: %s sec.'%(method, len(featPoints),time2-time1)

    #for featpoint in featPoints:
    #  x,y = featpoint.pt
    #  cv2.circle(image_np,(int(x),int(y)), 3, (0,0,255), -1)

    #### Create CompressedIamge ####
    msg = CompressedImage()
    msg.header.stamp = rospy.Time.now()
    msg.format = "jpeg"
    msg.data = np.array(cv2.imencode('.jpg', image_np)[1]).tostring()
    # Publish new image
    self.image_pub.publish(msg)
开发者ID:RoboticProjacLaser,项目名称:src,代码行数:37,代码来源:celuiQuiMarchePas.py

示例9: grabAndPublish

# 需要导入模块: from sensor_msgs.msg import CompressedImage [as 别名]
# 或者: from sensor_msgs.msg.CompressedImage import format [as 别名]
    def grabAndPublish(self,stream,publisher):
        while not self.update_framerate and not self.is_shutdown and not rospy.is_shutdown(): 
            yield stream
            # Construct image_msg
            # Grab image from stream
            stamp = rospy.Time.now()
            stream.seek(0)
            stream_data = stream.getvalue()
            # Generate compressed image
            image_msg = CompressedImage()
            image_msg.format = "jpeg"
            image_msg.data = stream_data

            image_msg.header.stamp = stamp
            image_msg.header.frame_id = self.frame_id
            publisher.publish(image_msg)
                        
            # Clear stream
            stream.seek(0)
            stream.truncate()
            
            if not self.has_published:
                rospy.loginfo("[%s] Published the first image." %(self.node_name))
                self.has_published = True

            rospy.sleep(rospy.Duration.from_sec(0.001))
开发者ID:Duckietown-NCTU,项目名称:Software,代码行数:28,代码来源:camera_node_sequence_kuo.py

示例10: grabFrame

# 需要导入模块: from sensor_msgs.msg import CompressedImage [as 别名]
# 或者: from sensor_msgs.msg.CompressedImage import format [as 别名]
def grabFrame(event):
   msg = CompressedImage()
   msg.header.frame_id = frame_id
   msg.format = "jpeg"
   resp, msg.data = http.request("http://" + host + request)
   msg.header.stamp = rospy.Time.now()
   pub.publish(msg)
开发者ID:MorS25,项目名称:mjpeg_network_camera,代码行数:9,代码来源:polled_camera.py

示例11: pubOriginal

# 需要导入模块: from sensor_msgs.msg import CompressedImage [as 别名]
# 或者: from sensor_msgs.msg.CompressedImage import format [as 别名]
    def pubOriginal(self, msg):
        compressed_img_msg = CompressedImage()
        compressed_img_msg.format = "png"
        compressed_img_msg.data = np.array(cv2.imencode(".png", self.testImageOrig)[1]).tostring()

        # compressed_img_msg.header.stamp = msg.header.stamp
        # compressed_img_msg.header.frame_id = msg.header.frame_id
        self.pub_raw.publish(compressed_img_msg)
开发者ID:hangzhaomit,项目名称:Software,代码行数:10,代码来源:virtual_mirror_tester_node.py

示例12: sendTestImage

# 需要导入模块: from sensor_msgs.msg import CompressedImage [as 别名]
# 或者: from sensor_msgs.msg.CompressedImage import format [as 别名]
 def sendTestImage(self):
     img_name = '0'+str(self.sent_image_count)+'_orig.'+self.test_image_format
     test_img = cv2.imread(self.test_image_path+img_name)
     msg = CompressedImage()
     msg.header.stamp = rospy.Time.now()
     msg.format = self.test_image_format
     msg.data = np.array(cv2.imencode('.'+self.test_image_format, test_img)[1]).tostring()
     self.pub_test_image.publish(msg)
开发者ID:71ananab,项目名称:Software,代码行数:10,代码来源:virtual_mirror_joewl_tester_node.py

示例13: publish_image

# 需要导入模块: from sensor_msgs.msg import CompressedImage [as 别名]
# 或者: from sensor_msgs.msg.CompressedImage import format [as 别名]
def publish_image(pub, image_handle):
    image = CompressedImage()
    image.data = image_handle.read()
    image.format = 'jpeg'
    image.header.seq = 0
    image.header.stamp.secs = math.floor(time.time())
    image.header.stamp.nsecs = 0
    image.header.frame_id = "0"
    pub.publish(image)
开发者ID:mdmoss,项目名称:dummy_image_source,代码行数:11,代码来源:dummy_image_source.py

示例14: pubImage

# 需要导入模块: from sensor_msgs.msg import CompressedImage [as 别名]
# 或者: from sensor_msgs.msg.CompressedImage import format [as 别名]
 def pubImage(self):
     filename = '0'+str(self.num_sent)+'_orig.png'
     image = cv2.imread(self.im_dir+filename)
     msg = CompressedImage()
     msg.header.stamp = rospy.Time.now()
     msg.format = 'png'
     msg.data = np.array(cv2.imencode('.png', image)[1]).tostring()
     self.pub_fake_images.publish(msg)
     rospy.loginfo("[%s] Image %s published" %(self.node_name,filename))
开发者ID:71ananab,项目名称:Software,代码行数:11,代码来源:virtual_mirror_catliu_tester_node.py

示例15: stream

# 需要导入模块: from sensor_msgs.msg import CompressedImage [as 别名]
# 或者: from sensor_msgs.msg.CompressedImage import format [as 别名]
	def stream(self):
		"""
			Reads and process the streams from the camera	
		"""		 
		try:
			#If flag self.enable_auth is 'True' then use the user/password to access the camera. Otherwise use only self.url
			if self.enable_auth:
				req = urllib2.Request(self.url, None, {"Authorization": self.auth })
			else:
				req = urllib2.Request(self.url)
				
			fp = urllib2.urlopen(req, timeout = self.timeout)
			#fp = urllib2.urlopen(req)

			while self.run_camera and not rospy.is_shutdown():
				
				boundary = fp.readline()
				
				header = {}
				
				while not rospy.is_shutdown():
					line = fp.readline()
					#print 'read line %s'%line
					if line == "\r\n": break
					line = line.strip()
					#print line
					parts = line.split(": ", 1)
					header[parts[0]] = parts[1]

				content_length = int(header['Content-Length'])
				#print 'Length = %d'%content_length
				img = fp.read(content_length)
				line = fp.readline()
				
				msg = CompressedImage()
				msg.header.stamp = rospy.Time.now()
				msg.header.frame_id = self.axis_frame_id
				msg.format = "jpeg"
				msg.data = img
				# publish image
				self.compressed_image_publisher.publish(msg)
				
				cimsg = self.cinfo.getCameraInfo()
				cimsg.header.stamp = msg.header.stamp
				cimsg.header.frame_id = self.axis_frame_id
				# publish camera info
				self.caminfo_publisher.publish(cimsg)
				
				#print self.real_fps
				self.last_update = datetime.datetime.now()
				self.error_reading = False
				self.image_pub_freq.tick()
						
		except urllib2.URLError,e:
			self.error_reading = True
			self.error_reading_msg = e
			rospy.logerr('Axis:stream: Camera %s (%s:%d). Error: %s'%(self.camera_id, self.hostname, self.camera_number, e))
开发者ID:RobotnikAutomation,项目名称:axis_camera,代码行数:59,代码来源:axis_node.py


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