Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
elphel-tools-x393
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Elphel
elphel-tools-x393
Commits
ab168e7e
Commit
ab168e7e
authored
Jun 28, 2019
by
Oleg Dzhimiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
script for filtering and copying
parent
abf01d80
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
141 additions
and
0 deletions
+141
-0
footage_filter_lwir_visible.py
footage_filter_lwir_visible.py
+141
-0
No files found.
footage_filter_lwir_visible.py
0 → 100644
View file @
ab168e7e
#!/usr/bin/env python3
import
os
import
sys
import
numpy
as
np
# returns timestamp in microseconds from 1970
def
helper_ts
(
s
):
tmp
=
s
.
split
(
'.'
)
tmp
=
tmp
[
0
]
tmp
=
tmp
.
split
(
'_'
)
return
1000000
*
int
(
tmp
[
0
])
+
int
(
tmp
[
1
])
def
helper_update_name
(
s
,
b
=
0
):
tmp
=
s
.
split
(
'.'
)
ext
=
tmp
[
1
]
tmp
=
tmp
[
0
]
tmp2
=
tmp
.
split
(
'_'
)
tmp2
[
2
]
=
str
(
int
(
tmp2
[
2
])
+
b
)
return
'_'
.
join
(
tmp2
)
+
"."
+
ext
# source files dirs
srcs
=
[
'lwir/results'
,
'visible/results'
]
# number of channels in complete set
srcs_chn_n
=
[
4
,
4
]
# correction if files carry wrong indices
srcs_chn_offsets
=
[
0
,
4
]
# positive or negative
srcs_latencies_us
=
[
0
,
-
228000
]
# allowed discrepancy in timestamps within a set
srcs_ts_precision_us
=
[
10000
,
10000
]
dst
=
'sets'
srcs_complete_set_n
=
sum
(
srcs_chn_n
)
print
(
"Step 1: filtering"
)
# scan all
file_lists
=
[
os
.
listdir
(
x
)
for
x
in
srcs
]
for
a
in
file_lists
:
a
.
sort
()
# take ts list from the file_lists[0], based in '_0.' pattern
base_ts_list
=
[
helper_ts
(
x
)
for
x
in
file_lists
[
0
]
if
'_0.'
in
x
]
results_list
=
[[]
for
x
in
base_ts_list
]
for
i
,
j
in
enumerate
(
base_ts_list
):
for
k
,
l
in
enumerate
(
file_lists
):
for
m
in
l
:
delta
=
helper_ts
(
m
)
-
srcs_latencies_us
[
k
]
-
j
#delta = helper_ts(m) - j
if
abs
(
delta
)
<
abs
(
srcs_ts_precision_us
[
k
]):
results_list
[
i
]
.
append
(
m
)
#if (k==1):
# print(str(helper_ts(m))+" "+str(srcs_latencies_us[k])+" "+str(j)+" "+str(delta))
if
(
delta
>
srcs_ts_precision_us
[
k
]):
break
#print(i)
#print(results_list[i])
#if i==100:
# break
print
(
"Step 2: copying"
)
os
.
makedirs
(
dst
,
exist_ok
=
True
)
for
i
,
j
in
enumerate
(
base_ts_list
):
if
len
(
results_list
[
i
])
==
srcs_complete_set_n
:
s
=
str
(
j
)
dirname
=
s
[
0
:
10
]
+
"_"
+
s
[
10
:
len
(
s
)]
print
(
"Copying "
+
dirname
)
dst_path
=
os
.
path
.
join
(
dst
,
dirname
)
os
.
makedirs
(
dst_path
,
exist_ok
=
True
)
# now need to iterate
tmp_i
=
0
for
k
in
range
(
len
(
srcs
)):
for
l
in
range
(
srcs_chn_n
[
k
]):
# tmp_i+l
src_fname
=
results_list
[
i
][
tmp_i
+
l
]
dst_fname
=
helper_update_name
(
src_fname
,
srcs_chn_offsets
[
k
])
sp
=
os
.
path
.
join
(
srcs
[
k
],
src_fname
)
dp
=
os
.
path
.
join
(
dst_path
,
dst_fname
)
os
.
system
(
"cp "
+
sp
+
" "
+
dp
)
tmp_i
+=
srcs_chn_n
[
k
]
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