Export static variables
This commit is contained in:
parent
2e25249117
commit
3f50111715
@ -1,5 +1,15 @@
|
|||||||
#include "pipeline_manager.hpp"
|
#include "pipeline_manager.hpp"
|
||||||
|
|
||||||
|
guint64 PipelineManager::frame_count_osd_sink = 0;
|
||||||
|
guint64 PipelineManager::frame_count_fps_probe = 0;
|
||||||
|
guint64 PipelineManager::frame_count_buffer_probe = 0;
|
||||||
|
std::chrono::time_point<std::chrono::steady_clock>
|
||||||
|
PipelineManager::last_time_osd_sink = std::chrono::steady_clock::now();
|
||||||
|
std::chrono::time_point<std::chrono::steady_clock>
|
||||||
|
PipelineManager::last_time_fps_probe = std::chrono::steady_clock::now();
|
||||||
|
std::chrono::time_point<std::chrono::steady_clock>
|
||||||
|
PipelineManager::last_time_buffer_probe = std::chrono::steady_clock::now();
|
||||||
|
|
||||||
PipelineManager::PipelineManager() { ; }
|
PipelineManager::PipelineManager() { ; }
|
||||||
|
|
||||||
PipelineManager::PipelineManager(int num_sources, char** url_camera) {
|
PipelineManager::PipelineManager(int num_sources, char** url_camera) {
|
||||||
@ -52,18 +62,17 @@ GstPadProbeReturn PipelineManager::osd_sink_pad_buffer_probe(
|
|||||||
GstPad* pad, GstPadProbeInfo* info, gpointer user_data) {
|
GstPad* pad, GstPadProbeInfo* info, gpointer user_data) {
|
||||||
(void)pad; // This explicitly marks it as unused
|
(void)pad; // This explicitly marks it as unused
|
||||||
(void)user_data; // This explicitly marks it as unused
|
(void)user_data; // This explicitly marks it as unused
|
||||||
static guint64 frame_count_osd_sink = 0;
|
|
||||||
static auto last_time_osd_sink = std::chrono::steady_clock::now();
|
|
||||||
GstBuffer* buf = (GstBuffer*)info->data;
|
GstBuffer* buf = (GstBuffer*)info->data;
|
||||||
NvDsBatchMeta* batch_meta = gst_buffer_get_nvds_batch_meta(buf);
|
NvDsBatchMeta* batch_meta = gst_buffer_get_nvds_batch_meta(buf);
|
||||||
|
|
||||||
frame_count_osd_sink += batch_meta->num_frames_in_batch;
|
frame_count_osd_sink += batch_meta->num_frames_in_batch;
|
||||||
|
|
||||||
if (frame_count_osd_sink % 60 == 0) {
|
if (frame_count_osd_sink % 60 == 0) {
|
||||||
auto now = std::chrono::steady_clock::now();
|
std::chrono::time_point<std::chrono::steady_clock> now =
|
||||||
double ms = std::chrono::duration_cast<std::chrono::milliseconds>(
|
std::chrono::steady_clock::now();
|
||||||
now - last_time_osd_sink)
|
long long ms = std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||||
.count();
|
now - last_time_osd_sink)
|
||||||
|
.count();
|
||||||
double fps = 60000.0 / ms;
|
double fps = 60000.0 / ms;
|
||||||
g_print("FPS_osd_sink: %.2f\n", fps);
|
g_print("FPS_osd_sink: %.2f\n", fps);
|
||||||
last_time_osd_sink = now;
|
last_time_osd_sink = now;
|
||||||
@ -85,14 +94,13 @@ GstPadProbeReturn PipelineManager::fps_probe(GstPad* pad, GstPadProbeInfo* info,
|
|||||||
gpointer user_data) {
|
gpointer user_data) {
|
||||||
(void)pad; // This explicitly marks it as unused
|
(void)pad; // This explicitly marks it as unused
|
||||||
(void)user_data; // This explicitly marks it as unused
|
(void)user_data; // This explicitly marks it as unused
|
||||||
static guint64 frame_count_fps_probe = 0;
|
|
||||||
static auto last_time_fps_probe = std::chrono::steady_clock::now();
|
|
||||||
if (GST_PAD_PROBE_INFO_TYPE(info) & GST_PAD_PROBE_TYPE_BUFFER) {
|
if (GST_PAD_PROBE_INFO_TYPE(info) & GST_PAD_PROBE_TYPE_BUFFER) {
|
||||||
frame_count_fps_probe++;
|
frame_count_fps_probe++;
|
||||||
|
|
||||||
if (frame_count_fps_probe % 30 == 0) { // Calculate FPS every 30 frames
|
if (frame_count_fps_probe % 30 == 0) { // Calculate FPS every 30 frames
|
||||||
auto current_time_fps_probe = std::chrono::steady_clock::now();
|
std::chrono::time_point<std::chrono::steady_clock>
|
||||||
auto duration =
|
current_time_fps_probe = std::chrono::steady_clock::now();
|
||||||
|
long long duration =
|
||||||
std::chrono::duration_cast<std::chrono::milliseconds>(
|
std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||||
current_time_fps_probe - last_time_fps_probe)
|
current_time_fps_probe - last_time_fps_probe)
|
||||||
.count();
|
.count();
|
||||||
@ -120,18 +128,17 @@ GstPadProbeReturn PipelineManager::buffer_probe(GstPad* pad,
|
|||||||
(void)pad; // This explicitly marks it as unused
|
(void)pad; // This explicitly marks it as unused
|
||||||
(void)info; // This explicitly marks it as unused
|
(void)info; // This explicitly marks it as unused
|
||||||
(void)user_data; // This explicitly marks it as unused
|
(void)user_data; // This explicitly marks it as unused
|
||||||
static guint frame_count_buffer_probe = 0;
|
|
||||||
static auto last_time_buffer_probe = std::chrono::steady_clock::now();
|
|
||||||
|
|
||||||
frame_count_buffer_probe++;
|
frame_count_buffer_probe++;
|
||||||
auto current_time_buffer_probe = std::chrono::steady_clock::now();
|
std::chrono::time_point<std::chrono::steady_clock>
|
||||||
auto elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(
|
current_time_buffer_probe = std::chrono::steady_clock::now();
|
||||||
current_time_buffer_probe - last_time_buffer_probe)
|
long long elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||||
.count();
|
current_time_buffer_probe - last_time_buffer_probe)
|
||||||
|
.count();
|
||||||
|
|
||||||
if (elapsed >= 1000) { // Update every second
|
if (elapsed >= 1000) { // Update every second
|
||||||
g_print("FPS_buffer_probe: %ld\n",
|
g_print("FPS_buffer_probe: %.2f\n",
|
||||||
frame_count_buffer_probe * 1000 / elapsed);
|
(double)(frame_count_buffer_probe * 1000 / (double)elapsed));
|
||||||
frame_count_buffer_probe = 0;
|
frame_count_buffer_probe = 0;
|
||||||
last_time_buffer_probe = current_time_buffer_probe;
|
last_time_buffer_probe = current_time_buffer_probe;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -49,6 +49,15 @@ class PipelineManager {
|
|||||||
bool setup_pipeline();
|
bool setup_pipeline();
|
||||||
void playing_pipeline(int, char **);
|
void playing_pipeline(int, char **);
|
||||||
void set_cuda_device();
|
void set_cuda_device();
|
||||||
|
static guint64 frame_count_osd_sink;
|
||||||
|
static guint64 frame_count_fps_probe;
|
||||||
|
static guint64 frame_count_buffer_probe;
|
||||||
|
static std::chrono::time_point<std::chrono::steady_clock>
|
||||||
|
last_time_osd_sink;
|
||||||
|
static std::chrono::time_point<std::chrono::steady_clock>
|
||||||
|
last_time_fps_probe;
|
||||||
|
static std::chrono::time_point<std::chrono::steady_clock>
|
||||||
|
last_time_buffer_probe;
|
||||||
static gboolean event_thread_func(gpointer);
|
static gboolean event_thread_func(gpointer);
|
||||||
static gboolean check_pipeline_state(gpointer);
|
static gboolean check_pipeline_state(gpointer);
|
||||||
static GstPadProbeReturn buffer_probe(GstPad *, GstPadProbeInfo *,
|
static GstPadProbeReturn buffer_probe(GstPad *, GstPadProbeInfo *,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user