Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
larm-astro
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Inès EL HADRI
larm-astro
Commits
164186b3
Commit
164186b3
authored
Jan 10, 2024
by
Inès EL HADRI
💤
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add HSV test
parent
5fc3fbea
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
0 deletions
+24
-0
test_hsv.py
tuto_vision/test_hsv.py
+24
-0
No files found.
tuto_vision/test_hsv.py
0 → 100644
View file @
164186b3
import
cv2
import
numpy
as
np
# connect to a sensor (0: webcam)
cap
=
cv2
.
VideoCapture
(
0
)
# capture an image
ret
,
frame
=
cap
.
read
()
# Select ROI
r
=
cv2
.
selectROI
(
frame
)
# Crop image
imCrop
=
frame
[
int
(
r
[
1
]):
int
(
r
[
1
]
+
r
[
3
]),
int
(
r
[
0
]):
int
(
r
[
0
]
+
r
[
2
])]
average_h
=
np
.
mean
(
imCrop
[:,:,
0
])
average_s
=
np
.
mean
(
imCrop
[:,:,
1
])
average_v
=
np
.
mean
(
imCrop
[:,:,
2
])
print
(
average_h
,
average_s
,
average_v
)
# Display cropped image
cv2
.
imshow
(
"Image"
,
imCrop
)
cv2
.
waitKey
(
0
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment