Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Thiago Santini
EyeRecToo
Commits
d3796708
Commit
d3796708
authored
Feb 06, 2019
by
Thiago Santini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improves post processing timestamp matching
parent
af6cf409
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
36 deletions
+19
-36
EyeRecToo/src/post-processing/PostProcessingWidget.cpp
EyeRecToo/src/post-processing/PostProcessingWidget.cpp
+5
-2
EyeRecToo/src/post-processing/PostProcessingWidget.h
EyeRecToo/src/post-processing/PostProcessingWidget.h
+0
-19
EyeRecToo/src/post-processing/VideoSource.h
EyeRecToo/src/post-processing/VideoSource.h
+1
-14
EyeRecToo/src/utils.h
EyeRecToo/src/utils.h
+13
-1
No files found.
EyeRecToo/src/post-processing/PostProcessingWidget.cpp
View file @
d3796708
...
...
@@ -587,8 +587,11 @@ void PostProcessingWidget::present(const VideoFrame& videoFrame)
updatePresentIdx
(
videoFrame
.
idx
);
ui
->
playbackSlider
->
setValue
(
presentIdx
);
auto
getTimestamp
=
[](
const
DataTuple
&
d
)
{
return
d
.
timestamp
;
};
size_t
idx
=
ts2idx
(
playbackTuples
,
videoFrame
.
t
,
getTimestamp
)
+
1
;
// Note that given a field frame, there might be more than one data tuple that contains it
// we simply pick one of them
auto
getTimestamp
=
[](
const
DataTuple
&
d
)
{
return
d
.
field
.
timestamp
;
};
auto
idx
=
findClosestIdx
(
playbackTuples
,
videoFrame
.
t
,
getTimestamp
);
DataTuple
tuple
;
if
(
idx
<
playbackTuples
.
size
())
tuple
=
playbackTuples
[
idx
];
...
...
EyeRecToo/src/post-processing/PostProcessingWidget.h
View file @
d3796708
...
...
@@ -156,25 +156,6 @@ private:
void
updatePresentIdx
(
const
int
idx
);
void
keyPressEvent
(
QKeyEvent
*
event
)
override
;
template
<
typename
T
,
typename
Functor
>
size_t
ts2idx
(
const
std
::
vector
<
T
>&
v
,
const
double
&
t
,
Functor
&
functor
)
const
{
size_t
s
=
0
;
size_t
e
=
v
.
size
();
while
(
true
)
{
size_t
mid
=
round
((
e
+
s
)
/
2
);
if
(
mid
==
s
||
mid
==
e
)
return
mid
;
if
(
t
<
functor
(
v
[
mid
]))
e
=
mid
;
else
s
=
mid
;
}
return
-
1
;
}
QStateMachine
batchStateMachine
;
};
...
...
EyeRecToo/src/post-processing/VideoSource.h
View file @
d3796708
...
...
@@ -80,20 +80,7 @@ private:
size_t
ts2idx
(
const
Timestamp
&
t
)
const
{
size_t
s
=
0
;
size_t
e
=
timestamps
.
size
();
while
(
true
)
{
size_t
mid
=
round
((
e
+
s
)
/
2
);
if
(
mid
==
s
||
mid
==
e
)
return
mid
;
if
(
t
<
timestamps
[
mid
])
e
=
mid
;
else
s
=
mid
;
}
return
-
1
;
return
findClosestIdx
(
timestamps
,
t
,
[](
const
Timestamp
&
t
)
{
return
t
;
});
}
private
slots
:
...
...
EyeRecToo/src/utils.h
View file @
d3796708
...
...
@@ -130,7 +130,7 @@ public:
{
total
=
0
;
}
double
average
()
const
{
return
mean
(
values
);
}
double
average
()
const
{
return
total
/
values
.
size
(
);
}
void
update
(
const
T
t
)
{
values
.
emplace_back
(
t
);
...
...
@@ -148,4 +148,16 @@ private:
double
total
;
};
template
<
typename
Vec
,
typename
Val
,
typename
Functor
>
size_t
findClosestIdx
(
const
Vec
&
vec
,
const
Val
&
val
,
const
Functor
&
f
,
size_t
start
=
0
,
size_t
end
=
0
)
{
if
(
start
==
0
&&
end
==
0
)
return
findClosestIdx
(
vec
,
val
,
f
,
0
,
vec
.
size
()
-
1
);
if
(
end
-
start
<=
1
)
return
abs
(
f
(
vec
[
start
])
-
val
)
<
abs
(
f
(
vec
[
end
])
-
val
)
?
start
:
end
;
auto
mid
=
(
end
+
start
)
/
2
;
return
f
(
vec
[
mid
])
>
val
?
findClosestIdx
(
vec
,
val
,
f
,
start
,
mid
)
:
findClosestIdx
(
vec
,
val
,
f
,
mid
,
end
);
}
#endif // UTILS_H
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