Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Autonomous_Vehicles_with_embedded_intelligence
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
kpp55
Autonomous_Vehicles_with_embedded_intelligence
Commits
4aca8a02
Commit
4aca8a02
authored
6 years ago
by
Leendert Hendricus Pruissen
Browse files
Options
Downloads
Patches
Plain Diff
New drift detection
parent
7b7835ab
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Detect/detect.py
+27
-77
27 additions, 77 deletions
Detect/detect.py
with
27 additions
and
77 deletions
Detect/detect.py
+
27
−
77
View file @
4aca8a02
...
...
@@ -41,7 +41,7 @@ def ROI(pic):
roi
=
cv2
.
bitwise_and
(
pic
,
mask
)
return
roi
# Define the region of in which the lanes will be in the cameras view
# Define the region of in which the lanes will be in the cameras view
for the robot
# params
# pic: original image to apply the pre-set region of interest too
def
ROI_real
(
pic
):
...
...
@@ -86,14 +86,15 @@ def find_middle(leftPoints, rightPoints):
middle_lines
=
[[],[]]
if
(
leftPoints
[
1
]
is
None
or
rightPoints
[
1
]
is
None
):
print
(
"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Caught the empty list~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"
)
if
rightPoints
[
1
]
is
None
:
print
(
"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Caught the empty right list~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"
)
return
0
elif
leftPoints
[
1
]
is
None
:
print
(
"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Caught the empty left list~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"
)
return
0
else
:
print
(
leftPoints
[
1
])
print
(
rightPoints
[
1
])
#
print(leftPoints[1])
#
print(rightPoints[1])
for
x
in
range
(
150
):
#print("Right x point: " + str(rightPoints[0][x]))
...
...
@@ -181,70 +182,6 @@ def find_poly_lane(pic, lines):
return
[
right_x_new
,
right_y_new
],
[
left_x_new
,
left_y_new
]
# Find the two average lines given the set of lines
# params
# pic: the original image
# lines: An array of lines in the form (x1, x2, y1, y2)
# Deprecated???
def
find_average_lane
(
pic
,
lines
):
# Collections for the negative and positive sloped lines
left_lines
=
[]
# Negative slope
left_lines_points
=
[[],[]]
# Negative slope
right_lines
=
[]
# Positive slope
right_lines_points
=
[[],[]]
# Positive slope
for
line
in
lines
:
x1
,
y1
,
x2
,
y2
=
line
[
0
]
parameters
=
np
.
polyfit
((
x1
,
x2
),
(
y1
,
y2
),
1
)
#print("Slope, intercept")
#print(parameters)
slope
=
parameters
[
0
]
intercept
=
parameters
[
1
]
if
(
slope
<
0
):
#print("Left insert")
left_lines
.
append
((
slope
,
intercept
))
left_lines_points
[
0
].
append
(
x1
)
left_lines_points
[
0
].
append
(
x2
)
left_lines_points
[
1
].
append
(
y1
)
left_lines_points
[
1
].
append
(
y2
)
else
:
#print("Right insert")
right_lines
.
append
((
slope
,
intercept
))
right_lines_points
[
0
].
append
(
x1
)
right_lines_points
[
0
].
append
(
x2
)
right_lines_points
[
1
].
append
(
y1
)
right_lines_points
[
1
].
append
(
y2
)
if
not
left_lines
:
#print("Left is empty")
left_line
=
[
0
,
0
,
0
,
0
]
else
:
left_average
=
np
.
average
(
left_lines
,
axis
=
0
)
left_line
=
make_coordinates
(
pic
,
left_average
)
#print("Left Line: ")
#print(left_line)
if
not
right_lines
:
#print("Right is emtpy")
right_line
=
[
0
,
0
,
0
,
0
]
else
:
right_average
=
np
.
average
(
right_lines
,
axis
=
0
)
right_line
=
make_coordinates
(
pic
,
right_average
)
#print("Right line : ")
#print(right_line)
#print("Left fit")
#print(left_line)
#print("\nRight fit")
#print(right_line)
return
np
.
array
([
left_line
,
right_line
])
def
make_coordinates
(
image
,
line_parameters
):
#print(line_parameters)
slope
,
intercept
=
line_parameters
...
...
@@ -283,14 +220,26 @@ def detectDeparture(left, car, right):
print
(
"
On course
"
)
print
(
"
On course
"
)
def
detectDepartureNew
(
midPoints
):
midx
=
300
midy
=
400
for
x
in
range
(
150
):
if
(
myround
(
midPoints
[
1
][
x
])
==
400
):
print
(
midPoints
[
0
][
x
]
-
midx
)
return
midPoints
[
0
][
x
]
-
midx
def
myround
(
x
):
return
int
(
5
*
round
(
float
(
x
)
/
5
))
video
=
cv2
.
VideoCapture
(
"
test2.mp4
"
)
video
=
cv2
.
VideoCapture
(
"
midTest.avi
"
)
#video = cv2.VideoCapture("highway.mp4")
#video = cv2.VideoCapture(
1
)
#video = cv2.VideoCapture(
0
)
plt
.
ion
()
while
True
:
...
...
@@ -307,8 +256,8 @@ while True:
wEdges
=
detect_edge
(
new_img
)
#
cropped = ROI_real(wEdges)
cropped
=
ROI
(
wEdges
)
cropped
=
ROI_real
(
wEdges
)
#
cropped = ROI(wEdges)
lines
=
getLines
(
cropped
)
...
...
@@ -329,11 +278,12 @@ while True:
plt
.
scatter
(
Lpoints
[
0
],
Lpoints
[
1
])
plt
.
scatter
(
Mpoints
[
0
],
Mpoints
[
1
])
#
plt.scatter(3
1
0,
3
00)
plt
.
scatter
(
3
0
0
,
4
00
)
plt
.
imshow
(
frame
,
zorder
=
0
)
detectDeparture
(
Lpoints
,
310
,
Rpoints
)
#detectDeparture(Lpoints, 310, Rpoints)
detectDepartureNew
(
Mpoints
)
plt
.
pause
(.
001
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment