Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bob
bob.io.stream
Commits
30e0ea12
Commit
30e0ea12
authored
Sep 07, 2020
by
David GEISSBUHLER
Browse files
moved adjust in stream.py
parent
005f889d
Changes
2
Hide whitespace changes
Inline
Side-by-side
bob/io/stream/stream.py
View file @
30e0ea12
...
...
@@ -395,4 +395,50 @@ class StreamView(StreamFilter):
return
super
().
process
(
data
,
indices
)
def
process_frame
(
self
,
data
,
data_index
,
stream_index
):
return
data
[
self
.
__bulk_view_full
]
\ No newline at end of file
return
data
[
self
.
__bulk_view_full
]
################################################################################
### ajust ###
@
stream_filter
(
"adjust"
)
class
StreamAdjust
(
StreamFilter
):
def
__init__
(
self
,
adjust_to
,
name
,
parent
):
super
().
__init__
(
name
=
name
,
parent
=
parent
)
self
.
adjust_to
=
adjust_to
def
set_source
(
self
,
src
):
super
().
set_source
(
src
)
self
.
adjust_to
.
set_source
(
src
)
@
property
def
shape
(
self
):
return
(
self
.
adjust_to
.
shape
[
0
],
self
.
parent
.
shape
[
1
],
self
.
parent
.
shape
[
2
],
self
.
parent
.
shape
[
3
])
@
property
def
timestamps
(
self
):
return
self
.
adjust_to
.
timestamps
def
get_frame_indices
(
self
,
index
):
return
super
().
get_frame_indices
(
index
)
def
load
(
self
,
index
):
# TODO load only relevant data if cropped
if
isinstance
(
index
,
tuple
):
index
=
index
[
0
]
print
(
"WARNING: cropping not yet implemented"
)
# original stream indices
old_indices
=
self
.
get_frame_indices
(
index
)
selected_timestamps
=
[
self
.
adjust_to
.
timestamps
[
i
]
for
i
in
old_indices
]
kdtree
=
cKDTree
(
self
.
parent
.
timestamps
[:,
np
.
newaxis
])
def
get_index
(
val
,
kdtree
):
_
,
i
=
kdtree
.
query
(
val
,
k
=
1
)
return
i
new_indices
=
[
get_index
(
ts
[
np
.
newaxis
],
kdtree
)
for
ts
in
selected_timestamps
]
if
False
:
print
(
"DEBUG: indices alignement:"
)
print
(
old_indices
)
print
(
new_indices
)
print
(
self
.
parent
.
timestamps
)
print
(
self
.
adjust_to
.
timestamps
)
return
super
().
load
(
new_indices
)
\ No newline at end of file
bob/io/stream/stream_filters.py
View file @
30e0ea12
...
...
@@ -119,52 +119,6 @@ class StreamStacked(StreamFilter):
return
np
.
concatenate
((
data
,
self
.
data2
[
data_index
]),
axis
=
0
)
### ajust ###
@
stream_filter
(
"adjust"
)
class
StreamAdjust
(
StreamFilter
):
def
__init__
(
self
,
adjust_to
,
name
,
parent
):
super
().
__init__
(
name
=
name
,
parent
=
parent
)
self
.
adjust_to
=
adjust_to
def
set_source
(
self
,
src
):
super
().
set_source
(
src
)
self
.
adjust_to
.
set_source
(
src
)
@
property
def
shape
(
self
):
return
(
self
.
adjust_to
.
shape
[
0
],
self
.
parent
.
shape
[
1
],
self
.
parent
.
shape
[
2
],
self
.
parent
.
shape
[
3
])
@
property
def
timestamps
(
self
):
return
self
.
adjust_to
.
timestamps
def
get_frame_indices
(
self
,
index
):
return
super
().
get_frame_indices
(
index
)
def
load
(
self
,
index
):
# TODO load only relevant data if cropped
if
isinstance
(
index
,
tuple
):
index
=
index
[
0
]
print
(
"WARNING: cropping not yet implemented"
)
# original stream indices
old_indices
=
self
.
get_frame_indices
(
index
)
selected_timestamps
=
[
self
.
adjust_to
.
timestamps
[
i
]
for
i
in
old_indices
]
kdtree
=
cKDTree
(
self
.
parent
.
timestamps
[:,
np
.
newaxis
])
def
get_index
(
val
,
kdtree
):
_
,
i
=
kdtree
.
query
(
val
,
k
=
1
)
return
i
new_indices
=
[
get_index
(
ts
[
np
.
newaxis
],
kdtree
)
for
ts
in
selected_timestamps
]
if
False
:
print
(
"DEBUG: indices alignement:"
)
print
(
old_indices
)
print
(
new_indices
)
print
(
self
.
parent
.
timestamps
)
print
(
self
.
adjust_to
.
timestamps
)
return
super
().
load
(
new_indices
)
### warp_with ###
@
stream_filter
(
"warp"
)
class
StreamWarp
(
StreamFilter
):
...
...
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