コード例 #1
0
ファイル: eyetrack.py プロジェクト: thomasdeneux/EyeTrack
    def select_roi(self, roi=None):
        if roi is None:
            roi = tracking.select_roi(self.frame)
        self.roi = roi

        # ROI for saving must be at least 65x65 otherwise buffer might be to small
        roisave = self.roi.copy()
        nx, ny = roisave['x2'] - roisave['x1'], roisave['y2'] - roisave['y1']
        if nx < 64:
            roisave['x1'] -= floor((64 - nx) / 2)
            nx = 64
            roisave['x2'] = roisave['x1'] + nx
        if ny < 64:
            roisave['y1'] -= floor((64 - ny) / 2)
            ny = 64
            roisave['y2'] = roisave['y1'] + ny

        self.roisave = roisave
        self.nxsave, self.nysave = nx, ny
        self.roi_selected = True

        # Re-init tracker if necessary
        if self.dotrack:
            self.eye = tracking.resize_roi(self.frame, self.roi)
            self.tracker = tracking.Tracker(self.eye)
コード例 #2
0
ファイル: eyetrack.py プロジェクト: thomasdeneux/EyeTrack
    def select_roi(self, roi=None):
        if roi is None:
            roi = tracking.select_roi(self.frame)
        self.roi = roi

        # ROI for saving must be at least 65x65 otherwise buffer might be to small
        roisave = self.roi.copy()
        nx, ny = roisave['x2'] - roisave['x1'], roisave['y2'] - roisave['y1']
        if nx < 64:
            roisave['x1'] -= floor((64 - nx) / 2)
            nx = 64
            roisave['x2'] = roisave['x1'] + nx
        if ny < 64:
            roisave['y1'] -= floor((64 - ny) / 2)
            ny = 64
            roisave['y2'] = roisave['y1'] + ny

        self.roisave = roisave
        self.nxsave, self.nysave = nx, ny
        self.roi_selected = True

        # Re-init tracker if necessary
        if self.dotrack:
            self.eye = tracking.resize_roi(self.frame, self.roi)
            self.tracker = tracking.Tracker(self.eye)
コード例 #3
0
        nprocessed += 1
        idle = False
        if t>t0+1:
            print 'processing frames at',nprocessed/(t-t0),'Hz'
            t0 = t
            nprocessed = 0

        if frame.ndim == 3:
            frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

        cv2.imshow('image2',frame)
        if cv2.waitKey(1) & 0xFF == ord('q'):
            break

    # user select ROI
    roi = tracking.select_roi(frame)
else:
    # fixed ROI
    roi = {'x1': 222, 'y1': 163, 'x2': 268, 'y2': 210}

eye = tracking.resize_roi(frame, roi)

# OUTPUT MOVIE
if dosave:
    # ROI for saving must be at least 65x65 otherwise buffer might be to small
    roisave = roi.copy()
    nxsave, nysave = roi['x2']-roi['x1'], roi['y2']-roi['y1']
    if nxsave<65:
        roisave['x1'] = roi['x1'] - floor((65-nxsave)/2)
        nxsave = 65
        roisave['x2'] = roisave['x1'] + nxsave