-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscratch.txt
35 lines (29 loc) · 1.43 KB
/
scratch.txt
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
# Define a function that applies Sobel x or y,
# then takes an absolute value and applies a threshold.
# Note: calling your function with orient='x', thresh_min=5, thresh_max=100
# should produce output like the example image shown above this quiz.
def abs_sobel_thresh(img, orient='x', thresh_min=0, thresh_max=255):
# Apply the following steps to img
# 1) Convert to grayscale
# 2) Take the derivative in x or y given orient = 'x' or 'y'
# 3) Take the absolute value of the derivative or gradient
# 4) Scale to 8-bit (0 - 255) then convert to type = np.uint8
# 5) Create a mask of 1's where the scaled gradient magnitude
# is > thresh_min and < thresh_max
# 6) Return this mask as your binary_output image
# 1
gray_image = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY)
#
x, y = (1, 0) if orient == 'x' else (0, 1)
# 2
sobel = cv2.Sobel(gray_image, cv2.CV_64F, x, y)
# 3
abs_sobel = np.absolute(sobel)
# 4
scaled_sobel = np.uint8(255 * abs_sobel / np.max(abs_sobel))
# 5
min_threshold, max_threshold = 5, 100
binary_output = np.zeros_like(scaled_sobel)
binary_output[(scaled_sobel >= min_threshold) & (scaled_sobel <= max_threshold)] = 1
return binary_output
Now your model should work, however, not correctly you should add the number of the total images and their augmentationsfor example if you want your `fit_generator()` to take only the center camera images you