Skip to content

Commit

Permalink
add logic to save steering angles in dam cam image file names, so tha…
Browse files Browse the repository at this point in the history
…t we can read the image, and get steering angle directly from file name. last 3 characters
  • Loading branch information
dctian committed May 2, 2019
1 parent d0029bb commit df5d116
Show file tree
Hide file tree
Showing 222 changed files with 32 additions and 10 deletions.
42 changes: 32 additions & 10 deletions driver/code/hand_coded_lane_follower.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def detect_edges(frame):
# filter for blue lane lines
hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)
show_image("hsv", hsv)
lower_blue = np.array([35, 40, 50])
lower_blue = np.array([30, 40, 0])
upper_blue = np.array([150, 255, 255])
mask = cv2.inRange(hsv, lower_blue, upper_blue)
show_image("blue mask", mask)
Expand All @@ -78,6 +78,28 @@ def detect_edges(frame):

return edges

def detect_edges_old(frame):
# filter for blue lane lines
hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)
show_image("hsv", hsv)
for i in range(16):
lower_blue = np.array([30, 16 * i, 0])
upper_blue = np.array([150, 255, 255])
mask = cv2.inRange(hsv, lower_blue, upper_blue)
show_image("blue mask Sat=%s" % (16* i), mask)


#for i in range(16):
#lower_blue = np.array([16 * i, 40, 50])
#upper_blue = np.array([150, 255, 255])
#mask = cv2.inRange(hsv, lower_blue, upper_blue)
# show_image("blue mask hue=%s" % (16* i), mask)

# detect edges
edges = cv2.Canny(mask, 200, 400)

return edges


def region_of_interest(canny):
height, width = canny.shape
Expand Down Expand Up @@ -177,7 +199,7 @@ def compute_steering_angle(frame, lane_lines):
else:
_, _, left_x2, _ = lane_lines[0][0]
_, _, right_x2, _ = lane_lines[1][0]
camera_mid_offset_percent = 0.09 # 0.09 is 9% offset
camera_mid_offset_percent = 0.02 # 0.0 means car pointing to center, -0.03: car is centered to left, +0.03 means car pointing to right
mid = int(width / 2 * (1 + camera_mid_offset_percent))
x_offset = (left_x2 + right_x2) / 2 - mid

Expand Down Expand Up @@ -287,24 +309,24 @@ def test_photo(file):


def test_video(video_file):
land_follower = HandCodedLaneFollower()
lane_follower = HandCodedLaneFollower()
cap = cv2.VideoCapture(video_file + '.avi')

# skip first second of video.
for i in range(3):
_, frame = cap.read()

video_type = cv2.VideoWriter_fourcc(*'XVID')
date_str = datetime.datetime.now().strftime("%y%m%d_%H%M%S")
video_overlay = cv2.VideoWriter("%s_overlay_%s.avi" % (video_file, date_str), video_type, 20.0, (320, 240))
video_overlay = cv2.VideoWriter("%s_overlay.avi" % (video_file), video_type, 20.0, (320, 240))
try:
i = 0
while cap.isOpened():
_, frame = cap.read()
print('frame %s' % i )
cv2.imwrite("%s_%03d.png" % (video_file, i), frame)

combo_image = land_follower.follow_lane(frame)
combo_image= lane_follower.follow_lane(frame)

cv2.imwrite("%s_%03d_%03d.png" % (video_file, i, lane_follower.curr_steering_angle), frame)

cv2.imwrite("%s_overlay_%03d.png" % (video_file, i), combo_image)
video_overlay.write(combo_image)
cv2.imshow("Road with Lane line", combo_image)
Expand All @@ -321,7 +343,7 @@ def test_video(video_file):
if __name__ == '__main__':
logging.basicConfig(level=logging.INFO)

#test_video('/home/pi/DeepPiCar/driver/data/video/car_video_190427_013349')
test_photo('/home/pi/DeepPiCar/driver/data/video/car_video_190427_013349_028.png')
test_video('/home/pi/DeepPiCar/driver/data/tmp/video01')
#test_photo('/home/pi/DeepPiCar/driver/data/video/car_video_190427_110320_073.png')
#test_photo(sys.argv[1])
#test_video(sys.argv[1])
Binary file not shown.
Binary file added models/lane_navigation/data/video01.avi
Binary file not shown.
Binary file added models/lane_navigation/data/video01_000_085.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added models/lane_navigation/data/video01_001_080.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added models/lane_navigation/data/video01_002_077.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added models/lane_navigation/data/video01_003_075.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added models/lane_navigation/data/video01_004_072.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added models/lane_navigation/data/video01_005_073.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added models/lane_navigation/data/video01_006_069.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added models/lane_navigation/data/video01_007_067.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added models/lane_navigation/data/video01_008_070.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added models/lane_navigation/data/video01_009_065.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added models/lane_navigation/data/video01_010_063.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added models/lane_navigation/data/video01_011_062.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added models/lane_navigation/data/video01_012_060.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added models/lane_navigation/data/video01_013_057.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added models/lane_navigation/data/video01_014_055.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added models/lane_navigation/data/video01_015_056.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added models/lane_navigation/data/video01_016_056.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added models/lane_navigation/data/video01_017_061.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added models/lane_navigation/data/video01_018_056.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added models/lane_navigation/data/video01_019_051.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added models/lane_navigation/data/video01_020_056.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added models/lane_navigation/data/video01_021_051.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added models/lane_navigation/data/video01_022_056.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added models/lane_navigation/data/video01_023_055.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added models/lane_navigation/data/video01_024_050.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added models/lane_navigation/data/video01_025_049.png
Binary file added models/lane_navigation/data/video01_026_054.png
Binary file added models/lane_navigation/data/video01_027_059.png
Binary file added models/lane_navigation/data/video01_028_054.png
Binary file added models/lane_navigation/data/video01_029_049.png
Binary file added models/lane_navigation/data/video01_030_044.png
Binary file added models/lane_navigation/data/video01_031_049.png
Binary file added models/lane_navigation/data/video01_032_049.png
Binary file added models/lane_navigation/data/video01_033_052.png
Binary file added models/lane_navigation/data/video01_034_049.png
Binary file added models/lane_navigation/data/video01_035_048.png
Binary file added models/lane_navigation/data/video01_036_053.png
Binary file added models/lane_navigation/data/video01_037_057.png
Binary file added models/lane_navigation/data/video01_038_053.png
Binary file added models/lane_navigation/data/video01_039_052.png
Binary file added models/lane_navigation/data/video01_040_054.png
Binary file added models/lane_navigation/data/video01_041_056.png
Binary file added models/lane_navigation/data/video01_042_057.png
Binary file added models/lane_navigation/data/video01_043_060.png
Binary file added models/lane_navigation/data/video01_044_056.png
Binary file added models/lane_navigation/data/video01_045_057.png
Binary file added models/lane_navigation/data/video01_046_062.png
Binary file added models/lane_navigation/data/video01_047_061.png
Binary file added models/lane_navigation/data/video01_048_064.png
Binary file added models/lane_navigation/data/video01_049_065.png
Binary file added models/lane_navigation/data/video01_050_070.png
Binary file added models/lane_navigation/data/video01_051_071.png
Binary file added models/lane_navigation/data/video01_052_076.png
Binary file added models/lane_navigation/data/video01_053_077.png
Binary file added models/lane_navigation/data/video01_054_075.png
Binary file added models/lane_navigation/data/video01_055_078.png
Binary file added models/lane_navigation/data/video01_056_073.png
Binary file added models/lane_navigation/data/video01_057_077.png
Binary file added models/lane_navigation/data/video01_058_074.png
Binary file added models/lane_navigation/data/video01_059_076.png
Binary file added models/lane_navigation/data/video01_060_081.png
Binary file added models/lane_navigation/data/video01_061_082.png
Binary file added models/lane_navigation/data/video01_062_080.png
Binary file added models/lane_navigation/data/video01_063_080.png
Binary file added models/lane_navigation/data/video01_064_080.png
Binary file added models/lane_navigation/data/video01_065_081.png
Binary file added models/lane_navigation/data/video01_066_079.png
Binary file added models/lane_navigation/data/video01_067_084.png
Binary file added models/lane_navigation/data/video01_068_086.png
Binary file added models/lane_navigation/data/video01_069_081.png
Binary file added models/lane_navigation/data/video01_070_077.png
Binary file added models/lane_navigation/data/video01_071_082.png
Binary file added models/lane_navigation/data/video01_072_077.png
Binary file added models/lane_navigation/data/video01_073_079.png
Binary file added models/lane_navigation/data/video01_074_080.png
Binary file added models/lane_navigation/data/video01_075_080.png
Binary file added models/lane_navigation/data/video01_076_085.png
Binary file added models/lane_navigation/data/video01_077_080.png
Binary file added models/lane_navigation/data/video01_078_079.png
Binary file added models/lane_navigation/data/video01_079_080.png
Binary file added models/lane_navigation/data/video01_080_075.png
Binary file added models/lane_navigation/data/video01_081_070.png
Binary file added models/lane_navigation/data/video01_082_071.png
Binary file added models/lane_navigation/data/video01_083_076.png
Binary file added models/lane_navigation/data/video01_084_071.png
Binary file added models/lane_navigation/data/video01_085_072.png
Binary file added models/lane_navigation/data/video01_086_073.png
Binary file added models/lane_navigation/data/video01_087_070.png
Binary file added models/lane_navigation/data/video01_088_071.png
Binary file added models/lane_navigation/data/video01_089_072.png
Binary file added models/lane_navigation/data/video01_090_077.png
Binary file added models/lane_navigation/data/video01_091_073.png
Binary file added models/lane_navigation/data/video01_092_078.png
Binary file added models/lane_navigation/data/video01_093_077.png
Binary file added models/lane_navigation/data/video01_094_082.png
Binary file added models/lane_navigation/data/video01_095_077.png
Binary file added models/lane_navigation/data/video01_096_082.png
Binary file added models/lane_navigation/data/video01_097_086.png
Binary file added models/lane_navigation/data/video01_098_088.png
Binary file added models/lane_navigation/data/video01_099_089.png
Binary file added models/lane_navigation/data/video01_100_084.png
Binary file added models/lane_navigation/data/video01_101_081.png
Binary file added models/lane_navigation/data/video01_102_086.png
Binary file added models/lane_navigation/data/video01_103_081.png
Binary file added models/lane_navigation/data/video01_104_086.png
Binary file added models/lane_navigation/data/video01_105_090.png
Binary file added models/lane_navigation/data/video01_106_088.png
Binary file added models/lane_navigation/data/video01_107_084.png
Binary file added models/lane_navigation/data/video01_108_081.png
Binary file added models/lane_navigation/data/video01_109_086.png
Binary file added models/lane_navigation/data/video01_110_081.png
Binary file added models/lane_navigation/data/video01_111_086.png
Binary file added models/lane_navigation/data/video01_112_085.png
Binary file added models/lane_navigation/data/video01_113_089.png
Binary file added models/lane_navigation/data/video01_114_084.png
Binary file added models/lane_navigation/data/video01_115_079.png
Binary file added models/lane_navigation/data/video01_116_074.png
Binary file added models/lane_navigation/data/video01_117_073.png
Binary file added models/lane_navigation/data/video01_118_078.png
Binary file added models/lane_navigation/data/video01_119_073.png
Binary file added models/lane_navigation/data/video01_120_070.png
Binary file added models/lane_navigation/data/video01_121_072.png
Binary file added models/lane_navigation/data/video01_122_077.png
Binary file added models/lane_navigation/data/video01_123_079.png
Binary file added models/lane_navigation/data/video01_124_083.png
Binary file added models/lane_navigation/data/video01_125_078.png
Binary file added models/lane_navigation/data/video01_126_083.png
Binary file added models/lane_navigation/data/video01_127_079.png
Binary file added models/lane_navigation/data/video01_128_084.png
Binary file added models/lane_navigation/data/video01_129_080.png
Binary file added models/lane_navigation/data/video01_130_079.png
Binary file added models/lane_navigation/data/video01_131_084.png
Binary file added models/lane_navigation/data/video01_132_089.png
Binary file added models/lane_navigation/data/video01_133_094.png
Binary file added models/lane_navigation/data/video01_134_093.png
Binary file added models/lane_navigation/data/video01_135_098.png
Binary file added models/lane_navigation/data/video01_136_103.png
Binary file added models/lane_navigation/data/video01_137_102.png
Binary file added models/lane_navigation/data/video01_138_101.png
Binary file added models/lane_navigation/data/video01_139_100.png
Binary file added models/lane_navigation/data/video01_140_099.png
Binary file added models/lane_navigation/data/video01_141_098.png
Binary file added models/lane_navigation/data/video01_142_097.png
Binary file added models/lane_navigation/data/video01_143_092.png
Binary file added models/lane_navigation/data/video01_144_091.png
Binary file added models/lane_navigation/data/video01_145_086.png
Binary file added models/lane_navigation/data/video01_146_081.png
Binary file added models/lane_navigation/data/video01_147_076.png
Binary file added models/lane_navigation/data/video01_148_073.png
Binary file added models/lane_navigation/data/video01_149_068.png
Binary file added models/lane_navigation/data/video01_150_063.png
Binary file added models/lane_navigation/data/video01_151_068.png
Binary file added models/lane_navigation/data/video01_152_069.png
Binary file added models/lane_navigation/data/video01_153_068.png
Binary file added models/lane_navigation/data/video01_154_070.png
Binary file added models/lane_navigation/data/video01_155_065.png
Binary file added models/lane_navigation/data/video01_156_060.png
Binary file added models/lane_navigation/data/video01_157_063.png
Binary file added models/lane_navigation/data/video01_158_068.png
Binary file added models/lane_navigation/data/video01_159_064.png
Binary file added models/lane_navigation/data/video01_160_063.png
Binary file added models/lane_navigation/data/video01_161_063.png
Binary file added models/lane_navigation/data/video01_162_066.png
Binary file added models/lane_navigation/data/video01_163_065.png
Binary file added models/lane_navigation/data/video01_164_060.png
Binary file added models/lane_navigation/data/video01_165_065.png
Binary file added models/lane_navigation/data/video01_166_063.png
Binary file added models/lane_navigation/data/video01_167_062.png
Binary file added models/lane_navigation/data/video01_168_063.png
Binary file added models/lane_navigation/data/video01_169_062.png
Binary file added models/lane_navigation/data/video01_170_060.png
Binary file added models/lane_navigation/data/video01_171_063.png
Binary file added models/lane_navigation/data/video01_172_065.png
Binary file added models/lane_navigation/data/video01_173_065.png
Binary file added models/lane_navigation/data/video01_174_065.png
Binary file added models/lane_navigation/data/video01_175_065.png
Binary file added models/lane_navigation/data/video01_176_063.png
Binary file added models/lane_navigation/data/video01_177_068.png
Binary file added models/lane_navigation/data/video01_178_063.png
Binary file added models/lane_navigation/data/video01_179_064.png
Binary file added models/lane_navigation/data/video01_180_062.png
Binary file added models/lane_navigation/data/video01_181_065.png
Binary file added models/lane_navigation/data/video01_182_065.png
Binary file added models/lane_navigation/data/video01_183_065.png
Binary file added models/lane_navigation/data/video01_184_063.png
Binary file added models/lane_navigation/data/video01_185_068.png
Binary file added models/lane_navigation/data/video01_186_071.png
Binary file added models/lane_navigation/data/video01_187_075.png
Binary file added models/lane_navigation/data/video01_188_078.png
Binary file added models/lane_navigation/data/video01_189_073.png
Binary file added models/lane_navigation/data/video01_190_069.png
Binary file added models/lane_navigation/data/video01_191_073.png
Binary file added models/lane_navigation/data/video01_192_071.png
Binary file added models/lane_navigation/data/video01_193_072.png
Binary file added models/lane_navigation/data/video01_194_073.png
Binary file added models/lane_navigation/data/video01_195_071.png
Binary file added models/lane_navigation/data/video01_196_074.png
Binary file added models/lane_navigation/data/video01_197_075.png
Binary file added models/lane_navigation/data/video01_198_073.png
Binary file added models/lane_navigation/data/video01_199_074.png
Binary file added models/lane_navigation/data/video01_200_073.png
Binary file added models/lane_navigation/data/video01_201_074.png
Binary file added models/lane_navigation/data/video01_202_079.png
Binary file added models/lane_navigation/data/video01_203_078.png
Binary file added models/lane_navigation/data/video01_204_077.png
Binary file added models/lane_navigation/data/video01_205_076.png
Binary file added models/lane_navigation/data/video01_206_081.png
Binary file added models/lane_navigation/data/video01_207_080.png
Binary file added models/lane_navigation/data/video01_208_079.png
Binary file added models/lane_navigation/data/video01_209_081.png
Binary file added models/lane_navigation/data/video01_210_080.png
Binary file added models/lane_navigation/data/video01_211_077.png
Binary file added models/lane_navigation/data/video01_212_076.png
Binary file added models/lane_navigation/data/video01_213_072.png
Binary file added models/lane_navigation/data/video01_214_071.png
Binary file added models/lane_navigation/data/video01_215_074.png
Binary file added models/lane_navigation/data/video01_216_075.png
Binary file added models/lane_navigation/data/video01_217_070.png
Binary file added models/lane_navigation/data/video01_218_069.png

0 comments on commit df5d116

Please sign in to comment.