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
da0bb451
Commit
da0bb451
authored
5 years ago
by
Sebastian
Browse files
Options
Downloads
Patches
Plain Diff
output libde265 warnings
parent
70249406
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!155
Feature/python
Pipeline
#15888
passed
5 years ago
Stage: all
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
python/ftl/__init__.py
+1
-1
1 addition, 1 deletion
python/ftl/__init__.py
python/ftl/ftlstream.py
+13
-5
13 additions, 5 deletions
python/ftl/ftlstream.py
python/ftl/libde265.py
+29
-9
29 additions, 9 deletions
python/ftl/libde265.py
with
43 additions
and
15 deletions
python/ftl/__init__.py
+
1
−
1
View file @
da0bb451
from
.
ftlstream
import
FTLStream
from
.
ftlstream
import
FTLStream
\ No newline at end of file
This diff is collapsed.
Click to expand it.
python/ftl/ftlstream.py
+
13
−
5
View file @
da0bb451
...
@@ -6,7 +6,7 @@ import struct
...
@@ -6,7 +6,7 @@ import struct
from
enum
import
IntEnum
from
enum
import
IntEnum
from
collections
import
namedtuple
from
collections
import
namedtuple
from
.
libde265
import
Decoder
from
.
import
libde265
try
:
try
:
import
cv2
as
cv
import
cv2
as
cv
...
@@ -191,7 +191,6 @@ class FTLStream:
...
@@ -191,7 +191,6 @@ class FTLStream:
todo: fix endianess
todo: fix endianess
'''
'''
calibration
=
struct
.
unpack
(
"
@ddddIIdddd
"
,
p
.
data
[:(
4
*
8
+
2
*
4
+
4
*
8
)])
calibration
=
struct
.
unpack
(
"
@ddddIIdddd
"
,
p
.
data
[:(
4
*
8
+
2
*
4
+
4
*
8
)])
self
.
_calibration
[
sp
.
streamID
]
=
_Camera
.
_make
(
calibration
)
self
.
_calibration
[
sp
.
streamID
]
=
_Camera
.
_make
(
calibration
)
...
@@ -216,16 +215,25 @@ class FTLStream:
...
@@ -216,16 +215,25 @@ class FTLStream:
k
=
(
sp
.
streamID
,
sp
.
channel
)
k
=
(
sp
.
streamID
,
sp
.
channel
)
if
k
not
in
self
.
_decoders
:
if
k
not
in
self
.
_decoders
:
self
.
_decoders
[
k
]
=
Decoder
(
_definition_t
[
p
.
definition
])
self
.
_decoders
[
k
]
=
libde265
.
Decoder
(
_definition_t
[
p
.
definition
])
decoder
=
self
.
_decoders
[
k
]
decoder
=
self
.
_decoders
[
k
]
decoder
.
push_data
(
p
.
data
)
decoder
.
push_data
(
p
.
data
)
try
:
decoder
.
decode
()
except
libde265
.
WaitingForInput
:
pass
def
_decode_hevc
(
self
):
def
_decode_hevc
(
self
):
for
stream
,
decoder
in
self
.
_decoders
.
items
():
for
stream
,
decoder
in
self
.
_decoders
.
items
():
decoder
.
decode
()
try
:
decoder
.
decode
()
except
libde265
.
WaitingForInput
:
pass
img
=
decoder
.
get_next_picture
()
img
=
decoder
.
get_next_picture
()
if
img
is
not
None
:
if
img
is
not
None
:
self
.
_frames
[
stream
]
=
_ycrcb2rgb
(
img
)
self
.
_frames
[
stream
]
=
_ycrcb2rgb
(
img
)
...
...
This diff is collapsed.
Click to expand it.
python/ftl/libde265.py
+
29
−
9
View file @
da0bb451
...
@@ -20,6 +20,8 @@ except ImportError:
...
@@ -20,6 +20,8 @@ except ImportError:
# order: 0 nn, 1 bilinear, 3 bicubic
# order: 0 nn, 1 bilinear, 3 bicubic
return
(
resize_skimage
(
img
,
size
,
order
=
3
,
mode
=
"
constant
"
,
cval
=
0
)
*
255
).
astype
(
np
.
uint8
)
return
(
resize_skimage
(
img
,
size
,
order
=
3
,
mode
=
"
constant
"
,
cval
=
0
)
*
255
).
astype
(
np
.
uint8
)
from
warnings
import
warn
import
ctypes
import
ctypes
from
enum
import
IntEnum
from
enum
import
IntEnum
...
@@ -35,7 +37,7 @@ if _threads is None:
...
@@ -35,7 +37,7 @@ if _threads is None:
# error codes copied from header (de265.h)
# error codes copied from header (de265.h)
class
libde265error
(
IntEnum
):
class
_
libde265error
(
IntEnum
):
DE265_OK
=
0
DE265_OK
=
0
DE265_ERROR_NO_SUCH_FILE
=
1
DE265_ERROR_NO_SUCH_FILE
=
1
DE265_ERROR_COEFFICIENT_OUT_OF_IMAGE_BOUNDS
=
4
DE265_ERROR_COEFFICIENT_OUT_OF_IMAGE_BOUNDS
=
4
...
@@ -86,6 +88,10 @@ libde265 = ctypes.cdll.LoadLibrary("libde265.so.0")
...
@@ -86,6 +88,10 @@ libde265 = ctypes.cdll.LoadLibrary("libde265.so.0")
libde265
.
de265_get_error_text
.
argtypes
=
[
ctypes
.
c_void_p
]
libde265
.
de265_get_error_text
.
argtypes
=
[
ctypes
.
c_void_p
]
libde265
.
de265_get_error_text
.
restype
=
ctypes
.
c_char_p
libde265
.
de265_get_error_text
.
restype
=
ctypes
.
c_char_p
libde265
.
de265_get_warning
.
argtypes
=
[
ctypes
.
c_void_p
]
libde265
.
de265_get_warning
.
restype
=
ctypes
.
c_int
libde265
.
de265_get_version_number_major
.
restype
=
ctypes
.
c_uint32
libde265
.
de265_get_version_number_major
.
restype
=
ctypes
.
c_uint32
libde265
.
de265_get_version_number_minor
.
restype
=
ctypes
.
c_uint32
libde265
.
de265_get_version_number_minor
.
restype
=
ctypes
.
c_uint32
...
@@ -136,8 +142,6 @@ libde265.de265_get_image_plane.restype = ctypes.POINTER(ctypes.c_char)
...
@@ -136,8 +142,6 @@ libde265.de265_get_image_plane.restype = ctypes.POINTER(ctypes.c_char)
libde265
.
de265_get_number_of_input_bytes_pending
.
argtypes
=
[
ctypes
.
c_void_p
]
libde265
.
de265_get_number_of_input_bytes_pending
.
argtypes
=
[
ctypes
.
c_void_p
]
libde265
.
de265_get_number_of_input_bytes_pending
.
restype
=
ctypes
.
c_int
libde265
.
de265_get_number_of_input_bytes_pending
.
restype
=
ctypes
.
c_int
import
time
class
libde265Error
(
Exception
):
class
libde265Error
(
Exception
):
def
__init__
(
self
,
code
):
def
__init__
(
self
,
code
):
super
(
libde265Error
,
self
).
__init__
(
super
(
libde265Error
,
self
).
__init__
(
...
@@ -152,7 +156,10 @@ class Decoder:
...
@@ -152,7 +156,10 @@ class Decoder:
self
.
_more
=
ctypes
.
c_int
()
self
.
_more
=
ctypes
.
c_int
()
self
.
_out_stride
=
ctypes
.
c_int
()
self
.
_out_stride
=
ctypes
.
c_int
()
self
.
_ctx
=
libde265
.
de265_new_decoder
()
self
.
_ctx
=
libde265
.
de265_new_decoder
()
self
.
_supress_warnings
=
False
err
=
libde265
.
de265_start_worker_threads
(
self
.
_ctx
,
threads
)
err
=
libde265
.
de265_start_worker_threads
(
self
.
_ctx
,
threads
)
if
err
:
if
err
:
raise
libde265Error
(
err
)
raise
libde265Error
(
err
)
...
@@ -180,16 +187,27 @@ class Decoder:
...
@@ -180,16 +187,27 @@ class Decoder:
return
res
return
res
def
_warning
(
self
):
if
self
.
_supress_warnings
:
return
code
=
libde265
.
de265_get_warning
(
self
.
_ctx
)
if
code
!=
_libde265error
.
DE265_OK
:
msg
=
libde265
.
de265_get_error_text
(
code
).
decode
(
"
ascii
"
)
warn
(
msg
)
def
decode
(
self
):
def
decode
(
self
):
err
=
libde265
.
de265_decode
(
self
.
_ctx
,
self
.
_more
)
err
=
libde265
.
de265_decode
(
self
.
_ctx
,
self
.
_more
)
# should use custom
if
err
:
if
err
:
if
err
==
libde265error
.
DE265_ERROR_WAITING_FOR_INPUT_DATA
:
if
err
==
_
libde265error
.
DE265_ERROR_WAITING_FOR_INPUT_DATA
:
raise
WaitingForInput
(
err
)
raise
WaitingForInput
(
err
)
raise
libde265Error
(
err
)
raise
libde265Error
(
err
)
self
.
_warning
()
return
self
.
_more
.
value
!=
0
return
self
.
_more
.
value
!=
0
def
flush_data
(
self
):
def
flush_data
(
self
):
...
@@ -197,7 +215,7 @@ class Decoder:
...
@@ -197,7 +215,7 @@ class Decoder:
if
err
:
if
err
:
raise
libde265Error
(
err
)
raise
libde265Error
(
err
)
def
push_data
(
self
,
data
):
def
push_data
(
self
,
data
):
if
not
isinstance
(
data
,
bytes
):
if
not
isinstance
(
data
,
bytes
):
raise
ValueError
(
"
expected bytes
"
)
raise
ValueError
(
"
expected bytes
"
)
...
@@ -206,7 +224,7 @@ class Decoder:
...
@@ -206,7 +224,7 @@ class Decoder:
if
err
:
if
err
:
raise
libde265Error
(
err
)
raise
libde265Error
(
err
)
def
push_end_of_frame
(
self
):
def
push_end_of_frame
(
self
):
err
=
libde265
.
de265_push_end_of_frame
(
self
.
_ctx
)
err
=
libde265
.
de265_push_end_of_frame
(
self
.
_ctx
)
...
@@ -229,11 +247,12 @@ class Decoder:
...
@@ -229,11 +247,12 @@ class Decoder:
'''
'''
de265_image
=
libde265
.
de265_get_next_picture
(
self
.
_ctx
)
de265_image
=
libde265
.
de265_get_next_picture
(
self
.
_ctx
)
if
not
de265_image
:
if
not
de265_image
:
return
None
return
None
res
=
self
.
_copy_image
(
de265_image
)
res
=
self
.
_copy_image
(
de265_image
)
libde265
.
de265_release_next_picture
(
self
.
_ctx
)
libde265
.
de265_release_next_picture
(
self
.
_ctx
)
return
res
return
res
...
@@ -243,11 +262,12 @@ class Decoder:
...
@@ -243,11 +262,12 @@ class Decoder:
def
peek_next_picture
(
self
):
def
peek_next_picture
(
self
):
de265_image
=
libde265
.
de265_peek_next_picture
(
self
.
_ctx
)
de265_image
=
libde265
.
de265_peek_next_picture
(
self
.
_ctx
)
if
not
de265_image
:
if
not
de265_image
:
return
None
return
None
res
=
self
.
_copy_image
(
de265_image
)
res
=
self
.
_copy_image
(
de265_image
)
libde265
.
de265_release_next_picture
(
self
.
_ctx
)
libde265
.
de265_release_next_picture
(
self
.
_ctx
)
return
res
return
res
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