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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
kpp55
Autonomous_Vehicles_with_embedded_intelligence
Commits
b9463793
Commit
b9463793
authored
Feb 1, 2019
by
kpp55
Browse files
Options
Downloads
Patches
Plain Diff
First lane detection alg
parent
175b5fcb
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
laneDetection/detect.py
+87
-0
87 additions, 0 deletions
laneDetection/detect.py
laneDetection/lol_image.jpg
+0
-0
0 additions, 0 deletions
laneDetection/lol_image.jpg
laneDetection/test2.mp4
+0
-0
0 additions, 0 deletions
laneDetection/test2.mp4
with
87 additions
and
0 deletions
laneDetection/detect.py
0 → 100644
+
87
−
0
View file @
b9463793
import
numpy
as
np
import
cv2
# from time import sleep
# Converts picture to grayscale and applies filter to picture
# params
# pic : a numpy array of pixel values to represent a picture
def
formatImg
(
pic
):
# Convert picture to gray scale
gray
=
cv2
.
cvtColor
(
pic
,
cv2
.
COLOR_BGR2GRAY
)
# Apply filter to image
img_filter
=
cv2
.
GaussianBlur
(
gray
,
(
5
,
5
),
0
)
return
img_filter
# pre-processes and performs edge detection on an image
# params
# pic: a numpy array of pixel values for an image in gray scale
def
detect_edge
(
pic
):
# Perform canny edge detection
img_edge
=
cv2
.
Canny
(
pic
,
50
,
150
)
# return new edge image
return
img_edge
def
ROI
(
pic
):
return
0
def
applyLanes
(
original_pic
,
edge_pic
):
lines
=
cv2
.
HoughLinesP
(
edge_pic
,
1
,
np
.
pi
/
180
,
50
,
maxLineGap
=
70
,
minLineLength
=
10
)
for
line
in
lines
:
x1
,
y1
,
x2
,
y2
=
line
[
0
]
print
(
x1
)
cv2
.
line
(
original_pic
,
(
x1
,
y1
),
(
x2
,
y2
),
(
0
,
255
,
0
),
3
)
return
original_pic
video
=
cv2
.
VideoCapture
(
"
test_data.mp4
"
)
while
True
:
ret
,
frame
=
video
.
read
()
# gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
frame_edge
=
detect_edge
(
frame
)
if
not
ret
:
video
=
cv2
.
VideoCapture
(
"
test_data.mp4
"
)
continue
new_img
=
formatImg
(
frame
)
wEdges
=
detect_edge
(
new_img
)
lanes
=
applyLanes
(
frame
,
wEdges
)
cv2
.
imshow
(
"
frame
"
,
wEdges
)
key
=
cv2
.
waitKey
(
25
)
if
key
==
27
:
break
video
.
release
()
cv2
.
destroyAllWindows
()
'''
# Load image
img = cv2.imread(
'
lol_image.jpg
'
)
cv2.imshow(
"
original
"
, img)
new_img = formatImg(img)
wEdges = detect_edge(new_img)
lanes = applyLanes(img, wEdges)
cv2.imshow(
"
edges
"
, wEdges)
cv2.imshow(
"
with lines
"
, lanes)
cv2.waitKey(0)
cv2.destroyAllWindows()
'''
\ No newline at end of file
This diff is collapsed.
Click to expand it.
laneDetection/lol_image.jpg
0 → 100644
+
0
−
0
View file @
b9463793
758 KiB
This diff is collapsed.
Click to expand it.
laneDetection/test2.mp4
0 → 100644
+
0
−
0
View file @
b9463793
File added
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
sign in
to comment