Beispiel #1
0
    def set_compressed_image(self, compressed_path, add=True):
        '''
        Loads an image as the target object in compressed form. The compressing
        robot arm is assumed to also be in the image, so areas with the same
        color as it will be ignored. Thus, the compressed object should have
        a different color from the arm.
        
        Args:
            compressed_path: file path to arm object image. 
            add: boolean denoting whether to add the compressed image to the
                 list of images, or to create a new list starting with the
                 current image.
            force: amount of force used to achieve the object compresssion
                   in the image (in Newtons).
        Returns:
            True if image was loaded and segmented successfully;
            false otherwise.
        '''

        if compressed_path is None:
            return False
        if os.path.isdir(compressed_path):
            for file in sorted(os.listdir(compressed_path)):
                if file.endswith(".png") or file.endswith(".jpg"):
                    self.set_compressed_image(compressed_path + file)
        new_obj = SegmentedObject(self.bg_path, compressed_path)
        if not self._color_low is None and not self._color_high is None:
            new_obj.set_ignore_color(self._color_low, self._color_high)
        if add:
            self.compress_obj.append(new_obj)
            #self.compress_force.append(force)
        else:
            self.compress_obj = [new_obj]
            #self.compress_force = [force]
        return True
Beispiel #2
0
 def set_compressed_image(self, compressed_path, add=True):
     '''
     Loads an image as the target object in compressed form. The compressing
     robot arm is assumed to also be in the image, so areas with the same
     color as it will be ignored. Thus, the compressed object should have
     a different color from the arm.
     
     Args:
         compressed_path: file path to arm object image. 
         add: boolean denoting whether to add the compressed image to the
              list of images, or to create a new list starting with the
              current image.
         force: amount of force used to achieve the object compresssion
                in the image (in Newtons).
     Returns:
         True if image was loaded and segmented successfully;
         false otherwise.
     '''
     
     if compressed_path is None:
         return False
     if os.path.isdir(compressed_path):
         for file in sorted(os.listdir(compressed_path)):
             if file.endswith(".png") or file.endswith(".jpg"):
                 self.set_compressed_image(compressed_path + file)
     new_obj = SegmentedObject(self.bg_path, compressed_path)
     if not self._color_low is None and not self._color_high is None:
         new_obj.set_ignore_color(self._color_low, self._color_high)
     if add:
         self.compress_obj.append(new_obj)
         #self.compress_force.append(force)
     else:
         self.compress_obj = [new_obj]
         #self.compress_force = [force]
     return True