Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
ftl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Nicolas Pope
ftl
Commits
1ff17081
Commit
1ff17081
authored
5 years ago
by
Sebastian
Browse files
Options
Downloads
Patches
Plain Diff
OpenCV color conversion
parent
2ff8c152
No related branches found
No related tags found
2 merge requests
!155
Feature/python
,
!141
Python module for reading .ftl files
Pipeline
#15873
passed
5 years ago
Stage: all
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
python/ftl/ftlstream.py
+20
-11
20 additions, 11 deletions
python/ftl/ftlstream.py
with
20 additions
and
11 deletions
python/ftl/ftlstream.py
+
20
−
11
View file @
1ff17081
...
...
@@ -8,20 +8,29 @@ from . libde265 import Decoder
try
:
import
cv2
as
cv
def
ycbcr2rgb
(
img
):
raise
NotImplementedError
(
"
TODO
"
)
def
_ycrcb2rgb
(
img
):
return
cv
.
cvtColor
(
img
,
cv
.
COLOR_YCrCb2RGB
)
except
ImportError
:
import
skimage.color
def
ycbcr2rgb
(
img
):
res
=
skimage
.
color
.
ycbcr2rgb
(
img
.
astype
(
np
.
float
))
def
_ycrcb2rgb
(
img
):
'''
YCrCb to RGB, based on OpenCV documentation definition.
Note: It seems this implementation is not perfectly equivalent to OpenCV
'
s
'''
rgb
=
np
.
zeros
(
img
.
shape
,
np
.
float
)
Y
=
img
[:,:,
0
].
astype
(
np
.
float
)
Cr
=
img
[:,:,
1
].
astype
(
np
.
float
)
Cb
=
img
[:,:,
2
].
astype
(
np
.
float
)
delta
=
128.0
# clip
r
es
[
res
>
1.0
]
=
1.0
r
es
[
res
<
0.0
]
=
0.0
rgb
[:,:,
0
]
=
Y
+
1.403
*
(
Cr
-
delta
)
r
gb
[:,:,
1
]
=
Y
-
0.714
*
(
Cr
-
delta
)
-
0.344
*
(
Cb
-
delta
)
r
gb
[:,:,
2
]
=
Y
+
1.773
*
(
Cb
-
delta
)
# skimage ycbcr2rgb() returns dtype float64, convert to uint8
return
(
res
*
255
).
astype
(
np
.
uint8
)
return
rgb
.
round
().
astype
(
np
.
uint8
)
# FTL definitions
...
...
@@ -172,7 +181,7 @@ class FTLStream:
img
=
decoder
.
get_next_picture
()
if
img
is
not
None
:
self
.
_frames
[
k
]
=
ycbcr
2rgb
(
img
[:,:,(
0
,
2
,
1
)])
# note: channels BGR
self
.
_frames
[
k
]
=
_ycrcb
2rgb
(
img
)
def
_flush_decoders
(
self
):
for
decoder
in
self
.
_decoders
.
values
():
...
...
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