예제 #1
0
def face_from_eyes(eye1, eye2):
    '''
    Given eye coordinates estimate the face rectangle
    Assumes the face is reasonably horizontal.
    '''
    truth_rect = BoundingRect(eye1, eye2)
    truth_rect.w = 3.0 * truth_rect.w
    truth_rect.h = truth_rect.w
    truth_rect.x = truth_rect.x - 0.33 * truth_rect.w
    truth_rect.y = truth_rect.y - 0.4 * truth_rect.w
    return truth_rect
예제 #2
0
 def _readEyesFile(self):
     '''
     Private: Do not call directly. Reads the eye file.  
     '''
     if self.filename[-4:] == '.csv':
         f = open(self.filename,'r')
         for line in f:
             #print line
             line = line.split(',')
             if len(line) < 5:
                 continue
             for i in range(1,len(line),4):
                 fname = self._parseName(line[0])
                 if len(line) < i+4:
                     print "Warning in %s image %s: Count of numbers is not a multiple of four."%(self.filename,fname)
                     break
                 eye1 = Point(float(line[i+0]),float(line[i+1]))
                 eye2 = Point(float(line[i+2]),float(line[i+3]))
                 
                 truth_rect = BoundingRect(eye1,eye2)
                 truth_rect.w = 2.0 * truth_rect.w
                 truth_rect.h = truth_rect.w
                 truth_rect.x = truth_rect.x - 0.25*truth_rect.w
                 truth_rect.y = truth_rect.y - 0.3*truth_rect.w
     
                 #print fname,eye1,eye2,truth_rect
                 
                 if not self.images.has_key(fname):
                     self.images[fname] = []
                     
                 self.images[fname].append([fname,eye1,eye2,truth_rect])
         
     else:
         f = open(self.filename,'r')
         for line in f:
             #print line,
             line = line.split()
             fname = self._parseName(line[0])
             eye1 = Point(float(line[1]),float(line[2]))
             eye2 = Point(float(line[3]),float(line[4]))
             
             truth_rect = BoundingRect(eye1,eye2)
             truth_rect.w = 2.0 * truth_rect.w
             truth_rect.h = truth_rect.w
             truth_rect.x = truth_rect.x - 0.25*truth_rect.w
             truth_rect.y = truth_rect.y - 0.3*truth_rect.w
 
             #print fname,eye1,eye2,truth_rect
             
             if not self.images.has_key(fname):
                 self.images[fname] = []
                 
             self.images[fname].append([fname,eye1,eye2,truth_rect])
예제 #3
0
def face_from_eyes(eye1, eye2):
    '''
    Given eye coordinates estimate the face rectangle
    Assumes the face is reasonably horizontal.
    '''
    truth_rect = BoundingRect(eye1, eye2)
    truth_rect.w = 3.0 * truth_rect.w
    truth_rect.h = truth_rect.w
    truth_rect.x = truth_rect.x - 0.33 * truth_rect.w
    truth_rect.y = truth_rect.y - 0.4 * truth_rect.w
    return truth_rect
예제 #4
0
    def _readEyesFile(self):
        '''
        Private: Do not call directly. Reads the eye file.  
        '''
        if self.filename[-4:] == '.csv':
            f = open(self.filename, 'r')
            for line in f:
                #print line
                line = line.split(',')
                if len(line) < 5:
                    continue
                for i in range(1, len(line), 4):
                    fname = self._parseName(line[0])
                    if len(line) < i + 4:
                        print "Warning in %s image %s: Count of numbers is not a multiple of four." % (
                            self.filename, fname)
                        break
                    eye1 = Point(float(line[i + 0]), float(line[i + 1]))
                    eye2 = Point(float(line[i + 2]), float(line[i + 3]))

                    truth_rect = BoundingRect(eye1, eye2)
                    truth_rect.w = 2.0 * truth_rect.w
                    truth_rect.h = truth_rect.w
                    truth_rect.x = truth_rect.x - 0.25 * truth_rect.w
                    truth_rect.y = truth_rect.y - 0.3 * truth_rect.w

                    #print fname,eye1,eye2,truth_rect

                    if not self.images.has_key(fname):
                        self.images[fname] = []

                    self.images[fname].append([fname, eye1, eye2, truth_rect])

        else:
            f = open(self.filename, 'r')
            for line in f:
                #print line,
                line = line.split()
                fname = self._parseName(line[0])
                eye1 = Point(float(line[1]), float(line[2]))
                eye2 = Point(float(line[3]), float(line[4]))

                truth_rect = BoundingRect(eye1, eye2)
                truth_rect.w = 2.0 * truth_rect.w
                truth_rect.h = truth_rect.w
                truth_rect.x = truth_rect.x - 0.25 * truth_rect.w
                truth_rect.y = truth_rect.y - 0.3 * truth_rect.w

                #print fname,eye1,eye2,truth_rect

                if not self.images.has_key(fname):
                    self.images[fname] = []

                self.images[fname].append([fname, eye1, eye2, truth_rect])