ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

This is my image callback function. I use it to save subscribe image to jpg image. Hope this help!

import numpy as np
import cv2
      def Imgcallback(self, ros_data):
            np_arr = np.fromstring(ros_data.data, np.uint8)
            image_np = cv2.imdecode(np_arr, cv2.IMREAD_COLOR)
            outpath = "/home/user/folder/" + name
            #save the image
            cv2.imwrite(outpath, image_np)

This is my image callback function. I use it to save subscribe image to jpg image. Hope this help!

rospy.Subscriber("ServerRespImg",CompressedImage, self.Imgcallback,  queue_size = 10)

import numpy as np
import cv2
      def Imgcallback(self, ros_data):
            np_arr = np.fromstring(ros_data.data, np.uint8)
            image_np = cv2.imdecode(np_arr, cv2.IMREAD_COLOR)
            outpath = "/home/user/folder/" + name
            #save the image
            cv2.imwrite(outpath, image_np)