Esempio n. 1
0
    def __init__(self, node_name):
        ROS2OpenCV2.__init__(self, node_name)
        
        self.match_threshold = rospy.get_param("~match_threshold", 0.7)
        self.find_multiple_targets = rospy.get_param("~find_multiple_targets", False)
        self.n_pyr = rospy.get_param("~n_pyr", 2)
        self.min_template_size = rospy.get_param("~min_template_size", 25)

        self.scale_factor = rospy.get_param("~scale_factor", 1.2)
        self.scale_and_rotate = rospy.get_param("~scale_and_rotate", False)
        
        self.use_depth_for_detection = rospy.get_param("~use_depth_for_detection", False)
        self.fov_width = rospy.get_param("~fov_width", 1.094)
        self.fov_height = rospy.get_param("~fov_height", 1.094)
        self.max_object_size = rospy.get_param("~max_object_size", 0.28)

        # Intialize the detection box
        self.detect_box = None
        
        self.detector_loaded = False
        
        rospy.loginfo("Waiting for video topics to become available...")

        # Wait until the image topics are ready before starting
        rospy.wait_for_message("input_rgb_image", Image)
        
        if self.use_depth_for_detection:
            rospy.wait_for_message("input_depth_image", Image)
            
        rospy.loginfo("Ready.")
    def __init__(self, node_name):
        ROS2OpenCV2.__init__(self, node_name)

        self.node_name = node_name

        self.use_depth_for_detection = rospy.get_param("~use_depth_for_detection", False)
        self.fov_width = rospy.get_param("~fov_width", 1.094)
        self.fov_height = rospy.get_param("~fov_height", 1.094)
        self.max_object_size = rospy.get_param("~max_object_size", 0.28)

        # Intialize the detection box
        self.detect_box = None

        # Initialize a couple of intermediate image variables
        self.grey = None
        self.small_image = None

        # What kind of detector do we want to load
        self.detector_type = "template"
        self.detector_loaded = False

        rospy.loginfo("Waiting for video topics to become available...")

        # Wait until the image topics are ready before starting
        rospy.wait_for_message("input_rgb_image", Image)

        if self.use_depth_for_detection:
            rospy.wait_for_message("input_depth_image", Image)

        rospy.loginfo("Ready.")
Esempio n. 3
0
    def __init__(self, node_name):
        ROS2OpenCV2.__init__(self, node_name)

        self.node_name = node_name
        
        # The minimum saturation of the tracked color in HSV space,
        # as well as the min and max value (the V in HSV) and a 
        # threshold on the backprojection probability image.
        self.smin = rospy.get_param("~smin", 85)
        self.vmin = rospy.get_param("~vmin", 50)
        self.vmax = rospy.get_param("~vmax", 254)
        self.threshold = rospy.get_param("~threshold", 50)
                       
        # Create a number of windows for displaying the histogram,
        # parameters controls, and backprojection image
        cv.NamedWindow("Histogram", cv.CV_WINDOW_NORMAL)
        cv.MoveWindow("Histogram", 700, 50)
        cv.NamedWindow("Parameters", 0)
        cv.MoveWindow("Parameters", 700, 325)
        cv.NamedWindow("Backproject", 0)
        cv.MoveWindow("Backproject", 700, 600)
        
        # Create the slider controls for saturation, value and threshold
        cv.CreateTrackbar("Saturation", "Parameters", self.smin, 255, self.set_smin)
        cv.CreateTrackbar("Min Value", "Parameters", self.vmin, 255, self.set_vmin)
        cv.CreateTrackbar("Max Value", "Parameters", self.vmax, 255, self.set_vmax)
        cv.CreateTrackbar("Threshold", "Parameters", self.threshold, 255, self.set_threshold)
        
        # Initialize a number of variables
        self.hist = None
        self.track_window = None
        self.show_backproj = False
    def __init__(self, node_name):
        ROS2OpenCV2.__init__(self, node_name)

        self.node_name = node_name

        self.use_depth_for_detection = rospy.get_param(
            "~use_depth_for_detection", False)
        self.fov_width = rospy.get_param("~fov_width", 1.094)
        self.fov_height = rospy.get_param("~fov_height", 1.094)
        self.max_object_size = rospy.get_param("~max_object_size", 0.28)

        # Intialize the detection box
        self.detect_box = None

        # Initialize a couple of intermediate image variables
        self.grey = None
        self.small_image = None

        # What kind of detector do we want to load
        self.detector_type = "template"
        self.detector_loaded = False

        rospy.loginfo("Waiting for video topics to become available...")

        # Wait until the image topics are ready before starting
        rospy.wait_for_message("input_rgb_image", Image)

        if self.use_depth_for_detection:
            rospy.wait_for_message("input_depth_image", Image)

        rospy.loginfo("Ready.")
Esempio n. 5
0
    def __init__(self, node_name):
        ROS2OpenCV2.__init__(self, node_name)

        self.node_name = node_name
        """ Read in the template image """
        template_file = rospy.get_param("~template_file", "")

        self.template = cv2.imread(template_file, cv.CV_LOAD_IMAGE_COLOR)

        cv2.imshow("Template", self.template)

        self.template = cv2.cvtColor(self.template, cv2.COLOR_RGB2GRAY)
        self.surf = cv2.SURF(1000)
        self.kp1, self.desc1 = self.surf.detect(self.template, None, False)

        self.frame_index = 0
 def __init__(self, node_name):
     ROS2OpenCV2.__init__(self, node_name)
     
     self.node_name = node_name
     
     """ Read in the template image """              
     template_file = rospy.get_param("~template_file", "")
     
     self.template = cv2.imread(template_file, cv.CV_LOAD_IMAGE_COLOR)
     
     cv2.imshow("Template", self.template)
     
     self.template = cv2.cvtColor(self.template, cv2.COLOR_RGB2GRAY)
     self.surf = cv2.SURF(1000)
     self.kp1, self.desc1 = self.surf.detect(self.template, None, False)
     
     self.frame_index = 0
Esempio n. 7
0
    def __init__(self, node_name):
        ROS2OpenCV2.__init__(self, node_name)

        self.node_name = node_name
        self.color_under_detect = rospy.get_param("~color_under_detect", "red")
        # call masking alglorthm to get the color mask
        self.mymask = Masking(color=self.color_under_detect,
                              shape="triangle",
                              masker=None,
                              detector=None,
                              matcher=None,
                              matching_method=None)

        # The minimum saturation of the tracked color in HSV space,
        # as well as the min and max value (the V in HSV) and a
        # threshold on the backprojection probability image.
        self.smin = rospy.get_param("~smin", 85)
        self.vmin = rospy.get_param("~vmin", 50)
        self.vmax = rospy.get_param("~vmax", 254)
        self.threshold = rospy.get_param("~threshold", 50)

        # Create a number of windows for displaying the histogram,
        # parameters controls, and backprojection image
        cv.NamedWindow("Histogram", cv.CV_WINDOW_NORMAL)
        cv.MoveWindow("Histogram", 700, 50)
        cv.NamedWindow("Parameters", 0)
        cv.MoveWindow("Parameters", 700, 325)
        cv.NamedWindow("Backproject", 0)
        cv.MoveWindow("Backproject", 700, 600)
        cv.NamedWindow("Tracked_obj", 0)
        cv.MoveWindow("Tracked_obj", 1000, 50)

        # Create the slider controls for saturation, value and threshold
        cv.CreateTrackbar("Saturation", "Parameters", self.smin, 255,
                          self.set_smin)
        cv.CreateTrackbar("Min Value", "Parameters", self.vmin, 255,
                          self.set_vmin)
        cv.CreateTrackbar("Max Value", "Parameters", self.vmax, 255,
                          self.set_vmax)
        cv.CreateTrackbar("Threshold", "Parameters", self.threshold, 255,
                          self.set_threshold)

        # Initialize a number of variables
        self.hist = None
        self.track_window = None
        self.show_backproj = False
    def __init__(self, node_name):
        ROS2OpenCV2.__init__(self, node_name)

        self.node_name = node_name
        

        self.match_threshold = rospy.get_param("~match_threshold", 0.7)
        self.find_multiple_targets = rospy.get_param("~find_multiple_targets", False)
        self.n_pyr = rospy.get_param("~n_pyr", 2)
        self.min_template_size = rospy.get_param("~min_template_size", 25)

        self.scale_factor = rospy.get_param("~scale_factor", 1.2)
        self.scale_and_rotate = rospy.get_param("~scale_and_rotate", False)
        
        self.use_depth_for_detection = rospy.get_param("~use_depth_for_detection", False)
        self.fov_width = rospy.get_param("~fov_width", 1.094)
        self.fov_height = rospy.get_param("~fov_height", 1.094)
        self.max_object_size = rospy.get_param("~max_object_size", 0.28)
        topicname1 = rospy.get_param("~topicname1", "/roi")

        # The minimum saturation of the tracked color in HSV space,
        # as well as the min and max value (the V in HSV) and a 
        # threshold on the backprojection probability image.
        self.smin = rospy.get_param("~smin", 85)
        self.vmin = rospy.get_param("~vmin", 50)
        self.vmax = rospy.get_param("~vmax", 254)
        self.threshold = rospy.get_param("~threshold", 50)
                       
        # Create a number of windows 
        cv.NamedWindow("Backproject_Fire_Window", 0)
        cv.MoveWindow("Backproject_Fire_Window", 300, 400)
        
    
        # Initialize a number of variables
        self.hist = None
        self.track_window = None
        self.show_backproj = False



        self.detector_loaded = False
 def __init__(self, node_name="Parking"):
     ROS2OpenCV2.__init__(self, node_name)
     
     self.debug_mode = rospy.get_param("~debug_mode",True)         
     self.a_maxval = rospy.get_param("~a_maxval",255)        
     self.a_method = rospy.get_param("~a_method",1)        
     self.a_threshtype = rospy.get_param("~a_threshtype",1)
     self.a_block_size = rospy.get_param("~a_blocksize",15)        
     self.a_constant = rospy.get_param("~a_constant", 5)        
                          
     self.h_rho = rospy.get_param("~h_rho",2)
     self.h_theta = rospy.get_param("~h_theta",90)
     self.h_thresh = rospy.get_param("~h_thresh",100)        
     self.h_minlinelength = rospy.get_param("~h_minlinelength",120)
     
     self.smin = rospy.get_param("~smin", 0)
     self.vmin = rospy.get_param("~vmin", 0)
     self.vmax = rospy.get_param("~vmax", 254)
     self.threshold = rospy.get_param("~threshold", 0)                
      
     print "image processing "
Esempio n. 10
0
    def __init__(self, node_name):

        ROS2OpenCV2.__init__(self, node_name)

        self.matchPercentage = rospy.get_param("~matchPercentage", 70)
        self.findMultipleTargets = rospy.get_param("~findMultipleTargets",
                                                   False)
        self.numMaxima = rospy.get_param("~numMaxima", 1)
        self.numDownPyrs = rospy.get_param("~numDownPyrs", 2)
        self.searchExpansion = rospy.get_param("~searchExpansion", 15)

        self.use_depth_for_detection = rospy.get_param(
            "~use_depth_for_detection", False)
        self.fov_width = rospy.get_param("~fov_width", 1.094)
        self.fov_height = rospy.get_param("~fov_height", 1.094)
        self.max_object_size = rospy.get_param("~max_object_size", 0.28)

        self.foundPointsList = list()
        self.confidencesList = list()

        # Intialize the detection box
        self.detect_box = None

        # Initialize a couple of intermediate image variables
        self.grey = None
        self.small_image = None

        # What kind of detector do we want to load
        self.detector_type = "template"
        self.detector_loaded = False

        rospy.loginfo("Waiting for video topics to become available...")

        # Wait until the image topics are ready before starting
        rospy.wait_for_message("input_rgb_image", Image)

        if self.use_depth_for_detection:
            rospy.wait_for_message("input_depth_image", Image)

        rospy.loginfo("Ready.")
Esempio n. 11
0
    def __init__(self, node_name):
        ROS2OpenCV2.__init__(self, node_name)

        self.node_name = node_name
        

        self.match_threshold = rospy.get_param("~match_threshold", 0.7)
        self.find_multiple_targets = rospy.get_param("~find_multiple_targets", False)
        self.n_pyr = rospy.get_param("~n_pyr", 2)
        self.min_template_size = rospy.get_param("~min_template_size", 25)

        self.scale_factor = rospy.get_param("~scale_factor", 1.2)
        self.scale_and_rotate = rospy.get_param("~scale_and_rotate", False)
        
        self.use_depth_for_detection = rospy.get_param("~use_depth_for_detection", False)
        self.fov_width = rospy.get_param("~fov_width", 1.094)
        self.fov_height = rospy.get_param("~fov_height", 1.094)
        self.max_object_size = rospy.get_param("~max_object_size", 0.28)


        # The minimum saturation of the tracked color in HSV space,
        # as well as the min and max value (the V in HSV) and a 
        # threshold on the backprojection probability image.
        self.smin = rospy.get_param("~smin", 85)
        self.vmin = rospy.get_param("~vmin", 50)
        self.vmax = rospy.get_param("~vmax", 254)
        self.threshold = rospy.get_param("~threshold", 50)
                       
        # Create a number of windows 
        cv.NamedWindow("Backproject", 0)
        cv.MoveWindow("Backproject", 700, 600)
        
        # Initialize a number of variables
        self.hist = None
        self.track_window = None
        self.show_backproj = False



        self.detector_loaded = False
Esempio n. 12
0
    def __init__(self, node_name):
        ROS2OpenCV2.__init__(self, node_name)
        
        self.node_name = node_name
        
        # Get the paths to the cascade XML files for the Haar detectors.
        # These are set in the launch file.
        cascade_1 = rospy.get_param("~cascade_frontal_alt", "")
        cascade_2 = rospy.get_param("~cascade_frontal_alt2", "")
        cascade_3 = rospy.get_param("~cascade_profile", "")
        
        # Initialize the Haar detectors using the cascade files
        self.cascade_1 = cv2.CascadeClassifier(cascade_1)
        self.cascade_2 = cv2.CascadeClassifier(cascade_2)
        self.cascade_3 = cv2.CascadeClassifier(cascade_3)

        # Set cascade classification parameters that tend to work well for faces
        self.haar_params = dict(minSize = (20, 20),
                                maxSize = (150, 150),
                                scaleFactor = 2.0,
                                minNeighbors = 1,
                                flags = cv.CV_HAAR_DO_CANNY_PRUNING)
        
        # Intialize the detection box
        self.detect_box = None
        
        # Initialize a couple of intermediate image variables
        self.grey = None
        self.small_image = None  
        
        # Track the number of hits and misses
        self.hits = 0
        self.misses = 0
        self.hit_rate = 0
        
        # Wait until the image topics are ready before starting
        rospy.wait_for_message("input_rgb_image", Image)
            
        rospy.loginfo("Ready.")
Esempio n. 13
0
    def __init__(self, node_name):
        
        ROS2OpenCV2.__init__(self, node_name)
        
        self.matchPercentage = rospy.get_param("~matchPercentage", 70)
        self.findMultipleTargets = rospy.get_param("~findMultipleTargets", False)
        self.numMaxima = rospy.get_param("~numMaxima", 1)
        self.numDownPyrs = rospy.get_param("~numDownPyrs", 2)
        self.searchExpansion = rospy.get_param("~searchExpansion", 15)
        
        self.use_depth_for_detection = rospy.get_param("~use_depth_for_detection", False)
        self.fov_width = rospy.get_param("~fov_width", 1.094)
        self.fov_height = rospy.get_param("~fov_height", 1.094)
        self.max_object_size = rospy.get_param("~max_object_size", 0.28)

        self.foundPointsList = list()
        self.confidencesList = list()
        
        # Intialize the detection box
        self.detect_box = None
        
        # Initialize a couple of intermediate image variables
        self.grey = None
        self.small_image = None  
        
        # What kind of detector do we want to load
        self.detector_type = "template"
        self.detector_loaded = False
        
        rospy.loginfo("Waiting for video topics to become available...")

        # Wait until the image topics are ready before starting
        rospy.wait_for_message("input_rgb_image", Image)
        
        if self.use_depth_for_detection:
            rospy.wait_for_message("input_depth_image", Image)
            
        rospy.loginfo("Ready.")
Esempio n. 14
0
    def __init__(self, node_name):

        self.node_name = node_name
        
        # The minimum saturation of the tracked color in HSV space,
        # as well as the min and max value (the V in HSV) and a 
        # threshold on the backprojection probability image.
        self.smin = rospy.get_param("~smin", 85)
        self.vmin = rospy.get_param("~vmin", 50)
        self.vmax = rospy.get_param("~vmax", 254)
        self.threshold = rospy.get_param("~threshold", 50)
                       
        #self.bin_count = 16
        #self.bin_w     = 24
        self.bin_count = 180
        self.bin_w     = 2

        # Initialize a number of variables
        self.hist = None
        self.track_window = None
        self.show_backproj = False
        ROS2OpenCV2.__init__(self, node_name)
	self.hsv_history_sub = rospy.Subscriber("adaptive_hsv_thresholds", HSV_history, self.hsv_history_callback)
	print("Init done...")
Esempio n. 15
0
    def __init__(self, node_name):
        ROS2OpenCV2.__init__(self, node_name)

        self.node_name = node_name

        self.match_threshold = rospy.get_param("~match_threshold", 0.7)
        self.find_multiple_targets = rospy.get_param("~find_multiple_targets",
                                                     False)
        self.n_pyr = rospy.get_param("~n_pyr", 2)
        self.min_template_size = rospy.get_param("~min_template_size", 25)

        self.scale_factor = rospy.get_param("~scale_factor", 1.2)
        self.scale_and_rotate = rospy.get_param("~scale_and_rotate", False)

        self.use_depth_for_detection = rospy.get_param(
            "~use_depth_for_detection", False)
        self.fov_width = rospy.get_param("~fov_width", 1.094)
        self.fov_height = rospy.get_param("~fov_height", 1.094)
        self.max_object_size = rospy.get_param("~max_object_size", 0.28)

        # The minimum saturation of the tracked color in HSV space,
        # as well as the min and max value (the V in HSV) and a
        # threshold on the backprojection probability image.
        self.smin = rospy.get_param("~smin", 85)
        self.vmin = rospy.get_param("~vmin", 50)
        self.vmax = rospy.get_param("~vmax", 254)
        self.threshold = rospy.get_param("~threshold", 100)

        cv.NamedWindow("Backproject", 0)
        cv.MoveWindow("Backproject", 700, 600)

        # Initialize a number of variables
        self.hist = None
        self.track_window = None
        self.show_backproj = False

        # Get the paths to the cascade XML files for the Haar detectors.
        # These are set in the launch file.
        cascade_1 = rospy.get_param("~cascade_1", "")
        cascade_2 = rospy.get_param("~cascade_2", "")
        #cascade_3 = rospy.get_param("~cascade_3", "")

        # Initialize the Haar detectors using the cascade files
        self.cascade_1 = cv2.CascadeClassifier(cascade_1)
        self.cascade_2 = cv2.CascadeClassifier(cascade_2)
        #self.cascade_3 = cv2.CascadeClassifier(cascade_3)

        # Set cascade parameters that tend to work well for objects.
        # Can be overridden in launch file
        self.LBP_scaleFactor = rospy.get_param("~LBP_scaleFactor", 1.3)
        self.LBP_minNeighbors = rospy.get_param("~LBP_minNeighbors", 50)
        self.LBP_minSize = rospy.get_param("~LBP_minSize", 30)
        self.LBP_maxSize = rospy.get_param("~LBP_maxSize", 100)

        # Store all parameters together for passing to the detector
        self.LBP_params = dict(
            scaleFactor=self.LBP_scaleFactor,
            minNeighbors=self.LBP_minNeighbors,
            # flags = cv.CV_HAAR_DO_CANNY_PRUNING,
            minSize=(self.LBP_minSize, self.LBP_minSize),
            maxSize=(self.LBP_maxSize, self.LBP_maxSize))

        # Do we should text on the display?
        self.show_text = rospy.get_param("~show_text", True)

        # Intialize the detection box
        self.detect_box = None

        self.detector_loaded = False
        self.thrsh = 3000
        self.x, self.y, self.w, self.h = 10, 10, 400, 400

        self.roi_pub1 = rospy.Publisher("/ObjectDetected",
                                        String,
                                        queue_size=10)
        self.ObjectStr = "aborted"
        self.Object1 = False
        self.Object2 = False
Esempio n. 16
0
    def __init__(self, node_name):
        ROS2OpenCV2.__init__(self, node_name)

        self.node_name = node_name
        

        self.match_threshold = rospy.get_param("~match_threshold", 0.7)
        self.find_multiple_targets = rospy.get_param("~find_multiple_targets", False)
        self.n_pyr = rospy.get_param("~n_pyr", 2)
        self.min_template_size = rospy.get_param("~min_template_size", 25)

        self.scale_factor = rospy.get_param("~scale_factor", 1.2)
        self.scale_and_rotate = rospy.get_param("~scale_and_rotate", False)
        
        self.use_depth_for_detection = rospy.get_param("~use_depth_for_detection", False)
        self.fov_width = rospy.get_param("~fov_width", 1.094)
        self.fov_height = rospy.get_param("~fov_height", 1.094)
        self.max_object_size = rospy.get_param("~max_object_size", 0.28)


        # The minimum saturation of the tracked color in HSV space,
        # as well as the min and max value (the V in HSV) and a 
        # threshold on the backprojection probability image.
        self.smin = rospy.get_param("~smin", 85)
        self.vmin = rospy.get_param("~vmin", 50)
        self.vmax = rospy.get_param("~vmax", 254)
        self.threshold = rospy.get_param("~threshold", 100)


        cv.NamedWindow("Backproject", 0)
        cv.MoveWindow("Backproject", 700, 600)

        
        # Initialize a number of variables
        self.hist = None
        self.track_window = None
        self.show_backproj = False

        # Get the paths to the cascade XML files for the Haar detectors.
        # These are set in the launch file.
        cascade_1 = rospy.get_param("~cascade_1", "")
        cascade_2 = rospy.get_param("~cascade_2", "")
        #cascade_3 = rospy.get_param("~cascade_3", "")
        
        # Initialize the Haar detectors using the cascade files
        self.cascade_1 = cv2.CascadeClassifier(cascade_1)
        self.cascade_2 = cv2.CascadeClassifier(cascade_2)
        #self.cascade_3 = cv2.CascadeClassifier(cascade_3)
        
        # Set cascade parameters that tend to work well for objects.
        # Can be overridden in launch file
        self.LBP_scaleFactor = rospy.get_param("~LBP_scaleFactor", 1.3)
        self.LBP_minNeighbors = rospy.get_param("~LBP_minNeighbors", 50)
        self.LBP_minSize = rospy.get_param("~LBP_minSize", 30)
        self.LBP_maxSize = rospy.get_param("~LBP_maxSize", 100)
        
        # Store all parameters together for passing to the detector
        self.LBP_params = dict(scaleFactor = self.LBP_scaleFactor,
                                minNeighbors = self.LBP_minNeighbors,
                               # flags = cv.CV_HAAR_DO_CANNY_PRUNING,
                                minSize = (self.LBP_minSize, self.LBP_minSize),
                                maxSize = (self.LBP_maxSize, self.LBP_maxSize)
                                )
                        
        # Do we should text on the display?
        self.show_text = rospy.get_param("~show_text", True)
        
        # Intialize the detection box
        self.detect_box = None



        self.detector_loaded = False
        self.thrsh =3000
        self.x, self.y, self.w, self.h=10 ,10,400,400

        self.roi_pub1 = rospy.Publisher("/ObjectDetected", String, queue_size=10)
        self.ObjectStr = "aborted"
        self.Object1=False
        self.Object2=False