Frame: Convert API to std::chrono

This commit is contained in:
Peter Keresztes Schmidt 2021-06-13 16:03:05 +02:00
parent 7c6a6ac309
commit 335e950654
3 changed files with 11 additions and 7 deletions

View File

@ -456,7 +456,7 @@ void Event::WriteDbFrames() {
frame_insert_sql += stringtf("\n( %" PRIu64 ", %d, '%s', from_unixtime( %ld ), %.2f, %d ),",
id, frame->frame_id,
frame_type_names[frame->type],
frame->timestamp.tv_sec,
std::chrono::system_clock::to_time_t(frame->timestamp),
std::chrono::duration_cast<FPSeconds>(frame->delta).count(),
frame->score);
if (config.record_event_stats and frame->zone_stats.size()) {
@ -588,7 +588,13 @@ void Event::AddFrame(
zone_stats.size());
// The idea is to write out 1/sec
frame_data.push(new Frame(id, frames, frame_type, timestamp, delta_time, score, zone_stats));
frame_data.push(new Frame(id,
frames,
frame_type,
SystemTimePoint(zm::chrono::duration_cast<Microseconds>(timestamp)),
delta_time,
score,
zone_stats));
double fps = monitor->get_capture_fps();
if (write_to_db
or

View File

@ -3,7 +3,7 @@
Frame::Frame(event_id_t p_event_id,
int p_frame_id,
FrameType p_type,
struct timeval p_timestamp,
SystemTimePoint p_timestamp,
Microseconds p_delta,
int p_score,
std::vector<ZoneStats> p_stats)

View File

@ -23,8 +23,6 @@
#include "zm_event.h"
#include "zm_time.h"
#include "zm_zone.h"
#include <sys/time.h>
#include <vector>
enum FrameType {
@ -41,7 +39,7 @@ class Frame {
Frame(event_id_t p_event_id,
int p_frame_id,
FrameType p_type,
struct timeval p_timestamp,
SystemTimePoint p_timestamp,
Microseconds p_delta,
int p_score,
std::vector<ZoneStats> p_stats
@ -50,7 +48,7 @@ class Frame {
event_id_t event_id;
int frame_id;
FrameType type;
struct timeval timestamp;
SystemTimePoint timestamp;
Microseconds delta;
int score;
std::vector<ZoneStats> zone_stats;