Exemplo n.º 1
0
    def calibrate_mask(self, window, timer=3000):
        mask = np.zeros(Kinect.SIZE, np.uint8)
        n = timer / Kinect.CALIBRATION_SLEEP
        while timer > 0:
            self.update_image()
            mask += self.thresh / n
            #self.display(window)
            cv2.waitKey(Kinect.CALIBRATION_SLEEP)
            timer -= Kinect.CALIBRATION_SLEEP

        self.mask_center = c = imageutils.centroid(mask)
        threshold = mask[c[1], c[0]] * MASK_THRESH_FACTOR
        mask = cv2.threshold(mask, threshold, 255, cv2.THRESH_BINARY_INV)[1]
        mask = cv2.erode(mask, Kinect.KERNEL, Kinect.ERODE_ITERATIONS)
        mask = cv2.dilate(mask, Kinect.KERNEL, Kinect.DILATE_ITERATIONS)
        self.mask = mask
        self.calibrated[0] = True
        self.calibrated[2] = False

        return True
Exemplo n.º 2
0
 def update_centroid(self):
     self.centroid = imageutils.centroid(self.masked, Kinect.CENTROID_STEP)