Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
Bildverarbeitung
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
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Moh Kh
Bildverarbeitung
Commits
ed749563
Commit
ed749563
authored
2 years ago
by
Joel Steffens
Browse files
Options
Downloads
Patches
Plain Diff
Genauere Berechnung der Regressionsgeraden
parent
1e7e12b3
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
filter_pipeline.py
+2
-2
2 additions, 2 deletions
filter_pipeline.py
filters.py
+59
-6
59 additions, 6 deletions
filters.py
with
61 additions
and
8 deletions
filter_pipeline.py
+
2
−
2
View file @
ed749563
...
...
@@ -44,8 +44,8 @@ cv2.namedWindow(window, cv2.WINDOW_NORMAL)
cv2
.
createTrackbar
(
'
Canny_Min
'
,
window
,
90
,
255
,
nothing_cb
)
cv2
.
createTrackbar
(
'
Canny_Max
'
,
window
,
150
,
255
,
nothing_cb
)
cv2
.
createTrackbar
(
'
Diff_Mix
'
,
window
,
40
,
100
,
nothing_cb
)
cv2
.
createTrackbar
(
'
HSV_Min
'
,
window
,
4
0
,
255
,
nothing_cb
)
cv2
.
createTrackbar
(
'
HSV_Max
'
,
window
,
100
,
255
,
nothing_cb
)
cv2
.
createTrackbar
(
'
HSV_Min
'
,
window
,
5
0
,
180
,
nothing_cb
)
cv2
.
createTrackbar
(
'
HSV_Max
'
,
window
,
100
,
180
,
nothing_cb
)
pipeline
=
[
...
...
This diff is collapsed.
Click to expand it.
filters.py
+
59
−
6
View file @
ed749563
...
...
@@ -31,9 +31,9 @@ def gitter(info, image, state):
ax
.
set_ylim
([
720
,
0
])
ax
.
grid
(
True
,
which
=
'
major
'
)
diff_x
=
5
0
diff_y
=
5
0
treshold
=
5
0
diff_x
=
4
0
diff_y
=
4
0
treshold
=
3
0
ax
.
set_xticks
(
range
(
0
,
1280
,
diff_x
))
ax
.
set_yticks
(
range
(
0
,
720
,
diff_y
))
...
...
@@ -47,17 +47,21 @@ def gitter(info, image, state):
y_so
=
indices
[
0
]
+
y
list_xy
=
np
.
column_stack
((
x_so
,
y_so
)).
astype
(
np
.
int32
)
poly_xy
=
polyfit2
(
list_xy
,
x
,
x
+
diff_x
,
y
,
y
+
diff_y
)
complete
,
poly_xy
=
trendline
(
list_xy
,
x
,
x
+
diff_x
,
y
,
y
+
diff_y
)
list_of_lines
.
append
(
poly_xy
)
ax
.
scatter
(
x_so
,
y_so
,
c
=
'
r
'
)
#ax.plot(complete[:,0], complete[:,1], 'g')
ax
.
plot
(
poly_xy
[:,
0
],
poly_xy
[:,
1
],
'
b
'
)
#fig.show()
#print(complete)
if
complete
is
None
or
poly_xy
is
None
:
print
(
'
Poly xy none
'
)
#plot_points(poly_xy[:,0], poly_xy[:,1], x_so, y_so)
plt
.
show
()
return
image
,
False
# Cut green kanal
...
...
@@ -174,6 +178,55 @@ def polyfit2(n_list, xs, xe, ys, ye):
return
None
def
trendline
(
n_list
,
x1
,
x2
,
y1
,
y2
):
if
n_list
is
not
None
and
len
(
n_list
)
>=
2
:
m
,
b
=
np
.
polyfit
(
n_list
[:,
0
],
n_list
[:,
1
],
1
)
# f_n(x) = m*x+b
# f_i(y) = (y-b)/m
# x1 < x2 and y1 < y2
# Ersten beide Punkte (links x1 und rechts x2)
y_f1
=
m
*
x1
+
b
# (x1, y_f1)
y_f2
=
m
*
x2
+
b
# (x2, y_f2)
# Letzten beide Punkte (oben y1 und unten y2)
if
m
!=
0
:
x_f1
=
(
y1
-
b
)
/
m
# (x_f1, y1)
x_f2
=
(
y2
-
b
)
/
m
# (x_f2, y2)
else
:
x_f1
=
x1
x_f2
=
x2
# Schnittpunkt mit vertikaler Grenze (links)
if
y_f1
>=
y1
and
y_f1
<=
y2
:
p1
=
[
x1
,
y_f1
]
# Schnittpunkt mit horizontaler Grenze (oben)
elif
x_f1
>=
x1
and
x_f1
<=
x2
:
p1
=
[
x_f1
,
y1
]
# Schnittpunkt mit horizontaler Grenze (unten)
elif
x_f2
>=
x1
and
x_f2
<=
x2
:
p1
=
[
x_f2
,
y2
]
else
:
raise
ValueError
(
'
Not possible
'
)
# Schnittpunkt mit vertikaler Grenze (rechts)
if
y_f2
>=
y1
and
y_f2
<=
y2
:
p2
=
[
x2
,
y_f2
]
# Schnittpunkt mit horizontaler Grenze (oben)
elif
x_f1
>=
x1
and
x_f1
<=
x2
:
p2
=
[
x_f1
,
y1
]
# Schnittpunkt mit horizontaler Grenze (unten)
elif
x_f2
>=
x1
and
x_f2
<=
x2
:
p2
=
[
x_f2
,
y2
]
else
:
raise
ValueError
(
'
Not possible
'
)
return
[
np
.
array
([[
x1
,
y_f1
],
[
x2
,
y_f2
],
[
x_f1
,
y1
],
[
x_f2
,
y2
]]),
np
.
array
([
p1
,
p2
])]
return
None
def
polyfit
(
n_list
,
n
=
4
):
if
n_list
is
not
None
:
p
=
np
.
polyfit
(
n_list
[:,
0
],
n_list
[:,
1
],
n
)
...
...
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