Exemplo n.º 1
0
    def test_fully_overlapped_lines(self):
        self.assertTrue(lines.intersect(1, 4, 2, 3))
        self.assertTrue(lines.intersect(1, 4, 3, 2))
        self.assertTrue(lines.intersect(4, 1, 2, 3))
        self.assertTrue(lines.intersect(4, 1, 3, 2))

        self.assertTrue(lines.intersect(2, 3, 1, 4))
        self.assertTrue(lines.intersect(2, 3, 4, 1))
        self.assertTrue(lines.intersect(3, 2, 1, 4))
        self.assertTrue(lines.intersect(3, 2, 4, 1))
Exemplo n.º 2
0
    def test_non_overlapped_lines(self):
        self.assertFalse(lines.intersect(1, 5, 8, 10))
        self.assertFalse(lines.intersect(1, 5, 10, 8))
        self.assertFalse(lines.intersect(5, 1, 8, 10))
        self.assertFalse(lines.intersect(5, 1, 10, 8))

        self.assertFalse(lines.intersect(8, 10, 1, 5))
        self.assertFalse(lines.intersect(8, 10, 5, 1))
        self.assertFalse(lines.intersect(10, 8, 1, 5))
        self.assertFalse(lines.intersect(10, 8, 5, 1))
Exemplo n.º 3
0
	def click(self, x, y):
		ll = self.input_lines
		if self.phase is 0:
			sides = [ln.findlineleftof(ll, x, y), ln.findlinetopof(ll, x, y)]
			self.in_corners = [ln.intersect(sides[0], sides[1])]
			self.phase = 1
			self.in_marked_lines = sides
		elif self.phase is 1:
			# lines: left, top, right, bottom
			sides = self.in_marked_lines
			sides += [ln.findlinerightof(ll, x, y), ln.findlinebottomof(ll, x, y)]
			# intersects: top-left, top-right, right-bottom, bottom-left
			self.in_corners += [ln.intersect(sides[1], sides[2]), ln.intersect(sides[2], sides[3]), ln.intersect(sides[0], sides[3])]
			self.phase = 0
			# find corresponding points
			pts1 = np.float32(self.in_corners)
			pts2 = np.float32([(self.BORDER, self.BORDER), (CHESS_SIZE+self.BORDER, self.BORDER), (CHESS_SIZE+self.BORDER, CHESS_SIZE+self.BORDER), (self.BORDER, CHESS_SIZE+self.BORDER)])
			self.board_M = cv2.getPerspectiveTransform(pts1, pts2)
		self.draw()
Exemplo n.º 4
0
 def test_equal_lines(self):
     self.assertTrue(lines.intersect(1, 5, 1, 5))
     self.assertTrue(lines.intersect(5, 1, 5, 1))
Exemplo n.º 5
0
 def test_dots(self):
     self.assertFalse(lines.intersect(1, 1, 1, 1))
     self.assertFalse(lines.intersect(1, 1, 2, 2))
     self.assertFalse(lines.intersect(2, 2, 1, 1))