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)

        # We have temps because if we had a lock them lose it, we want to remember
        # the old lock until we get a new one (just in case the lock gets lots
        # right when "Stop Calibrating" is hit.
        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)

            # Detect green triangle in top left corner
            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))

            # Detect red rectangle in bottom right corner
            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))

        # Draw bounding box for projector arena
        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