Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
TicTacToe-Robot
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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lukas Hoffleit
TicTacToe-Robot
Commits
f9a13668
Commit
f9a13668
authored
4 weeks ago
by
Lukas Hoffleit
Browse files
Options
Downloads
Patches
Plain Diff
Rot funktioniert jetzt
parent
8e107f55
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
detector.py
+13
-5
13 additions, 5 deletions
detector.py
with
13 additions
and
5 deletions
detector.py
+
13
−
5
View file @
f9a13668
...
@@ -2,7 +2,7 @@ import cv2
...
@@ -2,7 +2,7 @@ import cv2
import
numpy
as
np
import
numpy
as
np
class
MarkerDetector
:
class
MarkerDetector
:
def
__init__
(
self
,
camera_index
=
0
):
def
__init__
(
self
,
camera_index
=
4
):
"""
"""
Initialize the detector to find markers anywhere in the frame.
Initialize the detector to find markers anywhere in the frame.
"""
"""
...
@@ -52,8 +52,19 @@ class MarkerDetector:
...
@@ -52,8 +52,19 @@ class MarkerDetector:
for
contour
in
green_contours
:
for
contour
in
green_contours
:
self
.
_process_contour
(
contour
,
'
O
'
)
self
.
_process_contour
(
contour
,
'
O
'
)
# lower mask (0-10)
lower_red
=
np
.
array
([
0
,
30
,
30
])
upper_red
=
np
.
array
([
10
,
255
,
255
])
mask0
=
cv2
.
inRange
(
hsv
,
lower_red
,
upper_red
)
# upper mask (170-180)
lower_red
=
np
.
array
([
170
,
30
,
30
])
upper_red
=
np
.
array
([
180
,
255
,
255
])
mask1
=
cv2
.
inRange
(
hsv
,
lower_red
,
upper_red
)
red_mask
=
mask0
+
mask1
# Detect red (X) markers
# Detect red (X) markers
red_mask
=
cv2
.
inRange
(
hsv
,
self
.
red_lower
,
self
.
red_upper
)
#
red_mask = cv2.inRange(hsv, self.red_lower, self.red_upper)
red_contours
=
self
.
_find_valid_contours
(
red_mask
)
red_contours
=
self
.
_find_valid_contours
(
red_mask
)
for
contour
in
red_contours
:
for
contour
in
red_contours
:
self
.
_process_contour
(
contour
,
'
X
'
)
self
.
_process_contour
(
contour
,
'
X
'
)
...
@@ -85,9 +96,6 @@ class MarkerDetector:
...
@@ -85,9 +96,6 @@ class MarkerDetector:
if
__name__
==
"
__main__
"
:
if
__name__
==
"
__main__
"
:
detector
=
MarkerDetector
()
detector
=
MarkerDetector
()
print
(
"
Starting Marker Detection. Press
'
q
'
to quit.
"
)
while
True
:
while
True
:
success
=
detector
.
update
()
success
=
detector
.
update
()
if
success
:
if
success
:
...
...
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