-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sourcery refactored master branch #1
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,10 +26,7 @@ | |
cam_calibrator = CameraCalibrator(img[:, :, 0].shape[::-1], cam_calibration) | ||
ld = LaneDetector(SRC, DST, n_frames=FRAME_MEMORY, cam_calibration=cam_calibrator, transform_offset=OFFSET) | ||
|
||
images = [] | ||
for i in range(1, 12): | ||
images.append(imread('../test_images/test%s.jpg' % i)) | ||
|
||
images = [imread('../test_images/test%s.jpg' % i) for i in range(1, 12)] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lines
|
||
rows = len(images) | ||
cols = 2 | ||
fig, axis = plt.subplots(rows, cols) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,9 +20,7 @@ def abs_sobel(img_ch, orient='x', sobel_kernel=3): | |
raise ValueError('orient has to be "x" or "y" not "%s"' % orient) | ||
|
||
sobel = cv2.Sobel(img_ch, -1, *axis, ksize=sobel_kernel) | ||
abs_s = np.absolute(sobel) | ||
|
||
return abs_s | ||
return np.absolute(sobel) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
||
|
||
def gradient_magnitude(sobel_x, sobel_y): | ||
|
@@ -68,9 +66,7 @@ def extract_yellow(img): | |
:return: Yellow 255 not yellow 0 | ||
""" | ||
hsv = cv2.cvtColor(img, cv2.COLOR_RGB2HSV) | ||
mask = cv2.inRange(hsv, (20, 50, 150), (40, 255, 255)) | ||
|
||
return mask | ||
return cv2.inRange(hsv, (20, 50, 150), (40, 255, 255)) | ||
Comment on lines
-71
to
+69
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
||
|
||
def extract_dark(img): | ||
|
@@ -80,8 +76,7 @@ def extract_dark(img): | |
:return: Dark 255 not dark 0 | ||
""" | ||
hsv = cv2.cvtColor(img, cv2.COLOR_RGB2HSV) | ||
mask = cv2.inRange(hsv, (0, 0, 0.), (255, 153, 128)) | ||
return mask | ||
return cv2.inRange(hsv, (0, 0, 0.), (255, 153, 128)) | ||
Comment on lines
-83
to
+79
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
||
|
||
def extract_highlights(img, p=99.9): | ||
|
@@ -92,8 +87,7 @@ def extract_highlights(img, p=99.9): | |
:return: Highlight 255 not highlight 0 | ||
""" | ||
p = int(np.percentile(img, p) - 30) | ||
mask = cv2.inRange(img, p, 255) | ||
return mask | ||
return cv2.inRange(img, p, 255) | ||
Comment on lines
-95
to
+90
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
||
|
||
def binary_noise_reduction(img, thresh): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,10 +43,9 @@ def __line_plausible(self, left, right): | |
""" | ||
if len(left[0]) < 3 or len(right[0]) < 3: | ||
return False | ||
else: | ||
new_left = Line(y=left[0], x=left[1]) | ||
new_right = Line(y=right[0], x=right[1]) | ||
return are_lanes_plausible(new_left, new_right) | ||
new_left = Line(y=left[0], x=left[1]) | ||
new_right = Line(y=right[0], x=right[1]) | ||
return are_lanes_plausible(new_left, new_right) | ||
Comment on lines
-46
to
+48
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
||
def __check_lines(self, left_x, left_y, right_x, right_y): | ||
""" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,9 +81,7 @@ def is_current_fit_parallel(self, other_line, threshold=(0, 0)): | |
first_coefi_dif = np.abs(self.current_fit[0] - other_line.current_fit[0]) | ||
second_coefi_dif = np.abs(self.current_fit[1] - other_line.current_fit[1]) | ||
|
||
is_parallel = first_coefi_dif < threshold[0] and second_coefi_dif < threshold[1] | ||
|
||
return is_parallel | ||
return first_coefi_dif < threshold[0] and second_coefi_dif < threshold[1] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
||
def get_current_fit_distance(self, other_line): | ||
""" | ||
|
@@ -118,6 +116,6 @@ def calc_curvature(fit_cr): | |
y_eval = np.max(y) | ||
|
||
fit_cr = np.polyfit(y * ym_per_pix, x * xm_per_pix, 2) | ||
curverad = ((1 + (2 * fit_cr[0] * y_eval / 2. + fit_cr[1]) ** 2) ** 1.5) / np.absolute(2 * fit_cr[0]) | ||
|
||
return curverad | ||
return ( | ||
(1 + (2 * fit_cr[0] * y_eval / 2.0 + fit_cr[1]) ** 2) ** 1.5 | ||
) / np.absolute(2 * fit_cr[0]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function
calculate_camera_calibration
refactored with the following changes:inline-immediately-returned-variable
)