Skip to content

Commit

Permalink
Fixed paramers and slopes issues
Browse files Browse the repository at this point in the history
  • Loading branch information
lawga committed Dec 23, 2018
1 parent fe6ae04 commit f9cd7cf
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 113 deletions.
128 changes: 34 additions & 94 deletions Final - Fixed all.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@
"output_type": "stream",
"text": [
"(540, 960, 3)\n",
"Currently processing image: ./test_images/solidYellowCurve.jpg\n",
"(540, 960, 3)\n",
"Currently processing image: ./test_images/solidYellowCurve2.jpg\n",
"Currently processing image: ./test_images/challenge_Moment.jpg\n",
"(540, 960, 3)\n",
"Currently processing image: ./test_images/solidWhiteCurve.jpg\n",
"(540, 960, 3)\n",
"Currently processing image: ./test_images/solidWhiteRight.jpg\n",
"(540, 960, 3)\n",
"Currently processing image: ./test_images/solidYellowLeft.jpg\n",
"Currently processing image: ./test_images/solidYellowCurve.jpg\n",
"(540, 960, 3)\n",
"Currently processing image: ./test_images/challenge_Moment.jpg\n",
"Currently processing image: ./test_images/solidYellowCurve2.jpg\n",
"(540, 960, 3)\n",
"Currently processing image: ./test_images/solidYellowLeft.jpg\n",
"(540, 960, 3)\n",
"Currently processing image: ./test_images/whiteCarLaneSwitch.jpg\n"
]
Expand Down Expand Up @@ -109,7 +109,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"100%|█████████▉| 221/222 [00:15<00:00, 13.45it/s]\n"
"100%|█████████▉| 221/222 [00:08<00:00, 25.66it/s]\n"
]
},
{
Expand All @@ -119,8 +119,8 @@
"[MoviePy] Done.\n",
"[MoviePy] >>>> Video ready: test_videos_output/solidWhiteRight.mp4 \n",
"\n",
"CPU times: user 3.78 s, sys: 239 ms, total: 4.02 s\n",
"Wall time: 16.8 s\n"
"CPU times: user 3.22 s, sys: 540 ms, total: 3.76 s\n",
"Wall time: 9.8 s\n"
]
}
],
Expand All @@ -138,8 +138,10 @@
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"execution_count": 3,
"metadata": {
"scrolled": true
},
"outputs": [
{
"data": {
Expand All @@ -154,7 +156,7 @@
"<IPython.core.display.HTML object>"
]
},
"execution_count": 4,
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -169,7 +171,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -188,7 +190,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 5,
"metadata": {},
"outputs": [
{
Expand All @@ -203,91 +205,18 @@
"name": "stderr",
"output_type": "stream",
"text": [
"\n",
" 0%| | 0/251 [00:00<?, ?it/s]\u001b[A\n",
" 1%| | 2/251 [00:00<00:13, 18.51it/s]"
"100%|██████████| 251/251 [00:13<00:00, 18.22it/s]\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"0 0 0 0\n",
"312.666666667 373.111111111 440.666666667 398.0\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\u001b[A\n",
" 2%|▏ | 4/251 [00:00<00:13, 18.58it/s]\u001b[A\n",
" 3%|▎ | 7/251 [00:00<00:12, 19.44it/s]"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"0 0 0 0\n",
"283.4 352.8 459.6 411.1\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\u001b[A\n",
" 4%|▍ | 10/251 [00:00<00:12, 19.77it/s]\u001b[A\n",
" 5%|▌ | 13/251 [00:00<00:11, 20.24it/s]\u001b[A\n",
" 6%|▋ | 16/251 [00:00<00:11, 20.82it/s]\u001b[A\n",
" 8%|▊ | 19/251 [00:00<00:11, 21.07it/s]\u001b[A\n",
" 9%|▉ | 22/251 [00:01<00:10, 21.42it/s]\u001b[A\n",
" 10%|▉ | 25/251 [00:01<00:10, 21.48it/s]\u001b[A\n",
" 11%|█ | 28/251 [00:01<00:10, 21.56it/s]\u001b[A"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"0 0 0 0\n",
"311.875 397.25 440.5 378.0\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[MoviePy] Done.\n",
"[MoviePy] >>>> Video ready: test_videos_output/challenge.mp4 \n",
"\n",
" 12%|█▏ | 31/251 [00:01<00:10, 20.76it/s]\u001b[A\n",
" 14%|█▎ | 34/251 [00:01<00:10, 21.03it/s]\u001b[A\n",
" 15%|█▍ | 37/251 [00:01<00:10, 21.05it/s]\u001b[A\n",
" 16%|█▌ | 40/251 [00:01<00:09, 21.16it/s]\u001b[A\n",
" 17%|█▋ | 43/251 [00:02<00:13, 15.41it/s]\u001b[A\n",
" 18%|█▊ | 45/251 [00:02<00:14, 14.33it/s]\u001b[A\n",
" 19%|█▊ | 47/251 [00:02<00:15, 13.02it/s]\u001b[A\n",
" 20%|█▉ | 49/251 [00:02<00:16, 12.22it/s]\u001b[A\n",
" 20%|██ | 51/251 [00:02<00:16, 11.80it/s]\u001b[A\n",
" 21%|██ | 53/251 [00:03<00:17, 11.48it/s]\u001b[A\n",
" 22%|██▏ | 55/251 [00:03<00:17, 11.26it/s]\u001b[A\n",
" 23%|██▎ | 57/251 [00:03<00:17, 11.05it/s]\u001b[A\n",
" 24%|██▎ | 59/251 [00:03<00:17, 11.00it/s]\u001b[A\n",
" 24%|██▍ | 61/251 [00:03<00:17, 10.85it/s]\u001b[A\n",
" 25%|██▌ | 63/251 [00:04<00:17, 10.84it/s]\u001b[A\n",
" 26%|██▌ | 65/251 [00:04<00:17, 10.74it/s]\u001b[A\n",
" 27%|██▋ | 67/251 [00:04<00:17, 10.70it/s]\u001b[A\n",
" 27%|██▋ | 69/251 [00:04<00:17, 10.64it/s]\n",
" 28%|██▊ | 71/251 [00:04<00:17, 10.51it/s]\u001b[A\n",
" 29%|██▉ | 73/251 [00:05<00:16, 10.61it/s]\u001b[A\n",
" 30%|██▉ | 75/251 [00:05<00:19, 9.11it/s]\u001b[A\n",
" 31%|███ | 77/251 [00:05<00:18, 9.30it/s]\u001b[A\n",
" 31%|███▏ | 79/251 [00:05<00:17, 9.64it/s]\u001b[A\n",
" 32%|███▏ | 80/251 [00:05<00:17, 9.50it/s]\u001b[A\n",
" 32%|███▏ | 81/251 [00:05<00:18, 9.26it/s]\u001b[A\n",
" 33%|███▎ | 83/251 [00:06<00:17, 9.49it/s]\u001b[A\n",
" 34%|███▍ | 85/251 [00:06<00:17, 9.66it/s]\u001b[A\n",
" 35%|███▍ | 87/251 [00:06<00:16, 9.66it/s]"
"CPU times: user 6.57 s, sys: 600 ms, total: 7.17 s\n",
"Wall time: 15.3 s\n"
]
}
],
Expand All @@ -305,7 +234,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 6,
"metadata": {},
"outputs": [
{
Expand All @@ -320,7 +249,7 @@
"<IPython.core.display.HTML object>"
]
},
"execution_count": 7,
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -351,6 +280,13 @@
"\n",
"print('Currently processing image: {}'.format('challenge_Moment.jpg'))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -369,7 +305,11 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.3"
"version": "3.5.2"
},
"widgets": {
"state": {},
"version": "1.1.2"
}
},
"nbformat": 4,
Expand Down
Binary file modified __pycache__/lane_finding.cpython-35.pyc
Binary file not shown.
22 changes: 3 additions & 19 deletions lane_finding.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,26 +113,10 @@ def draw_lines(img, lines, color=[255, 0, 0], thickness=2):
#print((x2-x1)/(y2-y1))
nR += 1

if (y1AvgL== y2AvgL) or (y1AvgR==y2AvgR):
for x1,y1,x2,y2 in line:
gh +=1
if (x2-x1)/(y2-y1) > 0 :
x1AvgL = x1AvgL + (x1 - x1AvgL)/nL
x2AvgL = x2AvgL + (x2 - x2AvgL)/nL
y1AvgL = y1AvgL + (y1 - y1AvgL)/nL
y2AvgL = y2AvgL + (y2 - y2AvgL)/nL
nL += 1
elif (x2-x1)/(y2-y1) < 0 :
x1AvgR = x1AvgR + (x1 - x1AvgR)/nR
x2AvgR = x2AvgR + (x2 - x2AvgR)/nR
y1AvgR = y1AvgR + (y1 - y1AvgR)/nR
y2AvgR = y2AvgR + (y2 - y2AvgR)/nR
nR += 1


if (x1AvgL==0 and x2AvgL==0 and y1AvgL==0 and y2AvgL==0) or (x1AvgR==0 and x2AvgR==0 and y1AvgR==0 and y2AvgR):
print(x1AvgL, x2AvgL, y1AvgL, y2AvgL)
print(x1AvgR, x2AvgR, y1AvgR, y2AvgR)
else:
if (y1AvgL!=y2AvgL) and (y1AvgR!=y2AvgR):

[slopeL, interceptL] = np.polyfit([x1AvgL, x2AvgL], [y1AvgL, y2AvgL], 1)
[slopeR, interceptR] = np.polyfit([x1AvgR, x2AvgR], [y1AvgR, y2AvgR], 1)

Expand Down
Binary file modified test_images_output/challenge_Moment.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test_images_output/solidWhiteCurve.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test_images_output/solidWhiteRight.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test_images_output/solidYellowCurve.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test_images_output/solidYellowCurve2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test_images_output/solidYellowLeft.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test_images_output/whiteCarLaneSwitch.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test_videos_output/challenge.mp4
Binary file not shown.
Binary file modified test_videos_output/solidWhiteRight.mp4
Binary file not shown.

0 comments on commit f9cd7cf

Please sign in to comment.