

def calibrate_projector(self, webcam_image):
    bw = cv2.cvtColor(webcam_image, cv2.cv.CV_BGR2GRAY)
    (thresh, bw_image) = cv2.threshold(bw, self._threshold_slider.get(), 255, cv2.THRESH_BINARY)
    (contours, h) = cv2.findContours(bw_image, cv2.cv.CV_RETR_EXTERNAL, cv2.cv.CV_CHAIN_APPROX_SIMPLE)
    self._temp_top_x = 0
    self._temp_top_y = 0
    self._temp_bottom_x = 0
    self._temp_bottom_y = 0
    self._top_x = 0
    self._top_y = 0
    self._bottom_x = 0
    self._bottom_y = 0
    detected_triangle = False
    detected_rectangle = False
    for cnt in contours:
        approx = cv2.approxPolyDP(cnt, (0.01 * cv2.arcLength(cnt, True)), True)
        if (len(approx) == 3):
            detected_triangle = True
            (self._temp_top_x, self._temp_top_y) = self.far_left_coord(approx)
            cv2.drawContours(webcam_image, [approx], 0, (0, 255, 0), (- 1))
            cv2.circle(webcam_image, (self._top_x, self._top_y), 10, (0, 255, 0))
        elif (len(approx) == 4):
            detected_rectangle = True
            (self._temp_bottom_x, self._temp_bottom_y) = self.farthest_coord(approx)
            cv2.drawContours(webcam_image, [approx], 0, (255, 0, 0), (- 1))
            cv2.circle(webcam_image, (self._bottom_x, self._bottom_y), 10, (0, 255, 0))
    if (detected_triangle and detected_rectangle):
        self._top_x = self._temp_top_x
        self._top_y = self._temp_top_y
        self._bottom_x = self._temp_bottom_x
        self._bottom_y = self._temp_bottom_y
        cv2.rectangle(webcam_image, (self._top_x, self._top_y), (self._bottom_x, self._bottom_y), (255, 255, 0))
    return webcam_image

dataset/ETHPy150Open phrack/ShootOFF-legacy/projector_calibrator.py ProjectorCalibrator.calibrate_projector/original