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 ),", frame_insert_sql += stringtf("\n( %" PRIu64 ", %d, '%s', from_unixtime( %ld ), %.2f, %d ),",
id, frame->frame_id, id, frame->frame_id,
frame_type_names[frame->type], 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(), std::chrono::duration_cast<FPSeconds>(frame->delta).count(),
frame->score); frame->score);
if (config.record_event_stats and frame->zone_stats.size()) { if (config.record_event_stats and frame->zone_stats.size()) {
@ -588,7 +588,13 @@ void Event::AddFrame(
zone_stats.size()); zone_stats.size());
// The idea is to write out 1/sec // 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(); double fps = monitor->get_capture_fps();
if (write_to_db if (write_to_db
or or

View File

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

View File

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