-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunit_test_find_lns.py
44 lines (31 loc) · 1.49 KB
/
unit_test_find_lns.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import numpy as np
import cv2
import scipy.misc
import matplotlib.pyplot as plt
import lanelines as ll
import unittest
class TestLaneFinder(unittest.TestCase):
def setUp(self):
self.test_img = scipy.misc.imread('output_images/test6_ppl_warped_bin.jpg')
def test_find_lane_lines(self):
llf = ll.LaneLineFinder()
ploty, left_fitx, right_fity = llf.find_lane_lines(self.test_img, True)
self.assertIsInstance(ploty, np.ndarray)
self.assertIsInstance(left_fitx, np.ndarray)
self.assertIsInstance(right_fity, np.ndarray)
self.assertTrue(llf.left_rad > 500, 'lane radius should be at least 500m')
self.assertTrue(llf.right_rad > 500, 'lane radius should be at least 500m')
self.assertIsInstance(llf.out_img, np.ndarray)
plt.imshow(llf.out_img)
# second time through
ploty, left_fitx, right_fity = llf.find_lane_lines(self.test_img, False)
self.assertIsInstance(ploty, np.ndarray)
self.assertIsInstance(left_fitx, np.ndarray)
self.assertIsInstance(right_fity, np.ndarray)
self.assertIsNone(llf.out_img)
self.assertTrue(llf.left_rad > 500, 'lane radius should be at least 500m')
self.assertTrue(llf.right_rad > 500, 'lane radius should be at least 500m')
print(llf.left_rad)
print(llf.right_rad)
print(llf.center_offset)
unittest.main()