예제 #1
0
 def read_image(self, imgfile, bgfile=None):
     """ imgfile and bgfile should be ('/path/to/folder','filename.tif') """
     self.imgfile, self.bgfile = imgfile, bgfile
     self.img = TIFF(os.path.join(imgfile))
     if bgfile:
         self.img.data -= TIFF(os.path.join(bgfile)).data
     self.minmax = self.img.minmax
     self.percentiles = self.img.percentiles([1,5,99,99.995])
     self.blobs = find_blobs(self.img.data)
예제 #2
0
파일: kinect.py 프로젝트: dlaw/maslab
def process_frame():
    # Get the raw frames
    raw_image = freenect.sync_get_video()[0]
    raw_depth = freenect.sync_get_depth()[0]

    # Downsample and convert the image frame
    cv.Resize(cv.fromarray(raw_image), cv.fromarray(image), cv.CV_INTER_AREA)
    cv.CvtColor(cv.fromarray(image), cv.fromarray(image), cv.CV_RGB2HSV)
    
    # Downsample the depth frame using nearest-neighbor to make sure 
    # invalid pixels are handled properly.
    cv.Resize(cv.fromarray(raw_depth), cv.fromarray(depth), cv.CV_INTER_NN)
    
    # Do the object recognition
    color.identify(image, constants, colors)
    global balls, yellow_walls, green_walls
    balls = blobs.find_blobs(colors, depth, color=0)
    yellow_walls = blobs.find_blobs(colors, depth, color=1, min_size=100)
    green_walls = blobs.find_blobs(colors, depth, color=2, min_size=10)
예제 #3
0
    def __find_landmarks(self, points):
        all_blobs = blobs.find_blobs(points)
        walls = filters.find_walls(all_blobs)
        # We could use spikes here, but that is unreliable in environments with people
        # in them.

        # Extract landmark points from wall landmarks.
        landmark_points = []
        for wall in walls:
            point = utilities.landmark_point((0, 0), wall[0], wall[1])
            landmark_points.append(point)

        return landmark_points
예제 #4
0
  def __find_landmarks(self, points):
    all_blobs = blobs.find_blobs(points)
    walls = filters.find_walls(all_blobs)
    # We could use spikes here, but that is unreliable in environments with people
    # in them.

    # Extract landmark points from wall landmarks.
    landmark_points = []
    for wall in walls:
      point = utilities.landmark_point((0, 0), wall[0], wall[1])
      landmark_points.append(point)

    return landmark_points
예제 #5
0
  def align_to_wall(self, scan):
    # Find walls in the scan.
    all_blobs = blobs.find_blobs(scan)
    walls = filters.find_walls(all_blobs)

    if not walls:
      log.error("Could not find any walls.")
      return

    # Line up with the best wall we have.
    best_quality = -sys.maxint
    best_wall = None
    for wall in walls:
      if wall[2] > best_quality:
        best_quality = wall[2]
        best_wall = wall

    # Find the angle of the wall.
    angle = math.degrees(math.atan(best_wall[0]))
    log.info("Got angle of %f degrees." % (angle))

    self.wheels.turn(angle)