当前位置: 首页>>代码示例>>Python>>正文


Python Line.intersection方法代码示例

本文整理汇总了Python中line.Line.intersection方法的典型用法代码示例。如果您正苦于以下问题:Python Line.intersection方法的具体用法?Python Line.intersection怎么用?Python Line.intersection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在line.Line的用法示例。


在下文中一共展示了Line.intersection方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_intersect_edge

# 需要导入模块: from line import Line [as 别名]
# 或者: from line.Line import intersection [as 别名]
    def test_intersect_edge(self):
        l1 = Line(Point([0,0]), Point([10, 0]))
        l2 = Line(Point([0, 0]), Point([5, 5]))

        p = l1.intersection(l2)

        self.assertEqual(p.vec, [0.0, 0.0, 1.0])
开发者ID:drewbanin,项目名称:computer-graphics,代码行数:9,代码来源:test_line.py

示例2: test_intersect_parallel

# 需要导入模块: from line import Line [as 别名]
# 或者: from line.Line import intersection [as 别名]
    def test_intersect_parallel(self):
        l1 = Line(Point([0,0]), Point([10, 0]))
        l2 = Line(Point([0, 5]), Point([5, 5]))

        p = l1.intersection(l2)

        self.assertEqual(p, False)
开发者ID:drewbanin,项目名称:computer-graphics,代码行数:9,代码来源:test_line.py

示例3: test_problems

# 需要导入模块: from line import Line [as 别名]
# 或者: from line.Line import intersection [as 别名]
    def test_problems(self):
        l1 = Line(Vector([4.046, 2.836]), 1.21)
        l2 = Line(Vector([10.115, 7.09]), 3.025)

        self.assertTrue(l1.__eq__(l2))
        self.assertEquals(None, l1.intersection(l2))


        l1 = Line(Vector([7.204, 3.182]), 8.68)
        l2 = Line(Vector([8.172, 4.114]), 9.883)

        self.assertEquals((dec('1.17277663546464155833736023125'), dec('0.0726955116633319428771277112348')),
                           l1.intersection(l2).coordinates)
        self.assertFalse(l1.__eq__(l2))

        l1 = Line(Vector([1.182, 5.562]), 6.744)
        l2 = Line(Vector([1.773, 8.343]), 9.525)

        self.assertEquals(None, l1.intersection(l2))
        self.assertFalse(l1.__eq__(l2))
开发者ID:calebpowell,项目名称:linear-algebra-py,代码行数:22,代码来源:test_line.py

示例4: generate_extremas

# 需要导入模块: from line import Line [as 别名]
# 或者: from line.Line import intersection [as 别名]
 def generate_extremas(self, polygon, y):
     extremas = []
     scan_line = Line(Point([self.canvas.xmin, y]), Point([self.canvas.xmax, y]))
     for edge in polygon.lines:
         if edge.horizontal():
             continue
         if y == edge.highest():
             continue
         if y >= edge.lowest() and y < edge.highest():
             p = scan_line.intersection(edge)
             if p == False:
                 continue  # lines are parallel
             extremas.append(p)
     return extremas
开发者ID:drewbanin,项目名称:computer-graphics,代码行数:16,代码来源:polygon_filler.py

示例5: detect_lanes

# 需要导入模块: from line import Line [as 别名]
# 或者: from line.Line import intersection [as 别名]
def detect_lanes(cv_image, left_search_strips, right_search_strips):
	'''
	Detects lanes in the specified image based on the specified search strips. The first
	argument is a OpenCV image. The second and third arguments are the left and right
	lane search strip sets respectively. The function returns a 4-tuple. The first item
	in the tuple is a Boolean that is True if the lanes were found and False otherwise.
	If the found flag is False, the rest of the tuple items are undefined. The second
	and third items in the return tuple are Line objects representing the image line of
	the left and right lanes respectively. The last item in the return tuple is a
	column vector of NumPy matrix type of length 2 that represents the location of the
	vanishing point.
	'''
	# turn canny detector knobs
	low_threshold = 100
	ratio = 3

	# apply the canny edge detector
	canny_image = cv2.Canny(cv_image, low_threshold, low_threshold*ratio)

	# find the intersections between the search strips and the edges from the canny
	# detector
	left_lane_points = find_lane_points(canny_image, left_search_strips, 'left')
	right_lane_points = find_lane_points(canny_image, right_search_strips, 'right')

	# fit line models to the intersections found
	left_lane_line = ransac_line2d(left_lane_points)
	right_lane_line = ransac_line2d(right_lane_points)

	# if either of the lane lines cannot be found, return failure
	if left_lane_line == None or right_lane_line == None:
		return False, left_lane_line, right_lane_line, None

	# find the vanishing point
	vanishing_point = Line.intersection(left_lane_line, right_lane_line)

	return True, left_lane_line, right_lane_line, vanishing_point
开发者ID:nfespindolar,项目名称:ucla-fall12-cs268-hw4,代码行数:38,代码来源:lane_detection.py

示例6: hw4_lane_pose_estimation

# 需要导入模块: from line import Line [as 别名]
# 或者: from line.Line import intersection [as 别名]
def hw4_lane_pose_estimation():
	'''
	TODO DOCUMENTATION
	'''

	image_paths = ['LDWS_test/LDWS_test_data {0:03}.bmp'.format(x) for x in range(1, 609)]

	intrinsic_matrix, distortion_coefficients = intrinsic_calibration.hw4_calibration(False)

	left_search_strips, right_search_strips = lane_detection.define_hw4_search_strips()

	cv2.namedWindow('display')

	for image_path in image_paths:
		cv_image = cv2.imread(image_path)

		lanes_found, left_lane_line, right_lane_line, vanishing_point = \
			lane_detection.detect_lanes(
				cv_image,
				left_search_strips,
				right_search_strips,
			)

		display_image = cv_image

		if lanes_found:
			vanishing_point_pixels = tuple2inttuple(colvec2tuple(vanishing_point))
			cv2.circle(display_image, vanishing_point_pixels, 10, (255, 255, 255))

			bottom_image_line = Line(np.matrix([[0],[480]]), np.matrix([[1],[0]]))
			bottom_left = Line.intersection(left_lane_line, bottom_image_line)
			bottom_right = Line.intersection(right_lane_line, bottom_image_line)
			bottom_left_pixels = tuple2inttuple(colvec2tuple(bottom_left))
			bottom_right_pixels = tuple2inttuple(colvec2tuple(bottom_right))
			cv2.circle(display_image, bottom_left_pixels, 10, (0, 0, 255))
			cv2.circle(display_image, bottom_right_pixels, 10, (255, 0, 0))

			almost_bottom_image_line = Line(np.matrix([[0],[480-150]]), np.matrix([[1],[0]]))
			almost_bottom_left = Line.intersection(left_lane_line, almost_bottom_image_line)
			almost_bottom_right = Line.intersection(right_lane_line, almost_bottom_image_line)
			almost_bottom_left_pixels = tuple2inttuple(colvec2tuple(almost_bottom_left))
			almost_bottom_right_pixels = tuple2inttuple(colvec2tuple(almost_bottom_right))
			cv2.circle(display_image, almost_bottom_left_pixels, 10, (0, 0, 255))
			cv2.circle(display_image, almost_bottom_right_pixels, 10, (255, 0, 0))

			cv2.line(display_image, vanishing_point_pixels, bottom_left_pixels, (255, 0, 255), 1, cv2.CV_AA)
			cv2.line(display_image, vanishing_point_pixels, bottom_right_pixels, (255, 0, 255), 1, cv2.CV_AA)

			object_points = np.array([
				[-1.6, 0, 0],
				[1.6, 0, 0],
				[-1.6, 4.0, 0],
				[1.6, 4.0, 0],
			])

			image_points = np.array([
				bottom_left.T.A[0],
				bottom_right.T.A[0],
				almost_bottom_left.T.A[0],
				almost_bottom_right.T.A[0],
			])
			
			solve_pnp_results = cv2.solvePnP(
				object_points,
				image_points,
				intrinsic_matrix,
				distortion_coefficients,
			)

			pnp_success, rotation_omega, translate = solve_pnp_results
			horizontal_drift = -translate[0][0]
			print(horizontal_drift)
			
			cv2.line(display_image, (320-80, 10), (320+80, 10), (0, 0, 0), 1, cv2.CV_AA)
			cv2.line(display_image, (320-80, 10), (320-80, 50), (0, 0, 0), 1, cv2.CV_AA)
			cv2.line(display_image, (320+80, 10), (320+80, 50), (0, 0, 0), 1, cv2.CV_AA)
			cv2.line(display_image, (320-80, 50), (320+80, 50), (0, 0, 0), 1, cv2.CV_AA)
			cv2.line(display_image, (320+int(40*horizontal_drift/0.4), 30), (320+int(40*horizontal_drift/0.4), 50), (0, 0, 0), 1, cv2.CV_AA)

		cv2.imshow('display', display_image)
		cv2.waitKey(1)
开发者ID:nfespindolar,项目名称:ucla-fall12-cs268-hw4,代码行数:83,代码来源:lane_pose_estimation.py

示例7: test_intersection

# 需要导入模块: from line import Line [as 别名]
# 或者: from line.Line import intersection [as 别名]
 def test_intersection(self):
     l1 = Line(Vector([1, 2]), 3)
     l2 = Line(Vector([1, -1]), 2)
     self.assertEquals(((dec(7)/dec(3)), (dec(1)/dec(3))), l1.intersection(l2).coordinates)
     self.assertEquals(((dec(7)/dec(3)), (dec(1)/dec(3))), l2.intersection(l1).coordinates)
开发者ID:calebpowell,项目名称:linear-algebra-py,代码行数:7,代码来源:test_line.py


注:本文中的line.Line.intersection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。