Create tiler

This commit is contained in:
Barzan Hayati 2025-06-30 19:38:19 +00:00
parent d92e7bdb11
commit e12a3096af
5 changed files with 50 additions and 1 deletions

View File

@ -51,10 +51,11 @@ include_directories(${PROJECT_SOURCE_DIR}/pipeline_manager.hpp)
include_directories(${PROJECT_SOURCE_DIR}/streammux_manager.hpp)
include_directories(${PROJECT_SOURCE_DIR}/source_bin.hpp)
include_directories(${PROJECT_SOURCE_DIR}/gstds_example_manager.hpp)
include_directories(${PROJECT_SOURCE_DIR}/tiler_manager.hpp)
set(SOURCES src/main.cpp src/camera_manager.cpp src/pipeline_manager.cpp src/streammux_manager.cpp src/source_bin.cpp src/gstds_example_manager.cpp)
set(SOURCES src/main.cpp src/camera_manager.cpp src/pipeline_manager.cpp src/streammux_manager.cpp src/source_bin.cpp src/gstds_example_manager.cpp src/tiler_manager.cpp)
# Create the executable
add_executable(${PROJECT_NAME} ${SOURCES})

View File

@ -58,6 +58,9 @@ bool PipelineManager::create_pipeline_elements(int num_sources,
}
gstds_example_manager->create_gstds_example();
tiler_manager->create_tiler(num_sources,
streammux_manager->MUXER_OUTPUT_WIDTH,
streammux_manager->MUXER_OUTPUT_HEIGHT);
return true;
}

View File

@ -5,6 +5,7 @@
#include "gstds_example_manager.hpp"
#include "source_bin.hpp"
#include "streammux_manager.hpp"
#include "tiler_manager.hpp"
class PipelineManager {
private:
@ -14,6 +15,7 @@ class PipelineManager {
GMutex eos_lock;
StreammuxManager *streammux_manager = new StreammuxManager();
GstdsExampleManager *gstds_example_manager = new GstdsExampleManager();
TilerManager *tiler_manager = new TilerManager();
public:
int current_device = -1;

29
src/tiler_manager.cpp Normal file
View File

@ -0,0 +1,29 @@
#include "tiler_manager.hpp"
#define SET_GPU_ID(object, gpu_id) \
g_object_set(G_OBJECT(object), "gpu-id", gpu_id, NULL);
#define GPU_ID 0
TilerManager::TilerManager() {}
bool TilerManager::create_tiler(int num_sources, const int MUXER_OUTPUT_WIDTH,
const int MUXER_OUTPUT_HEIGHT) {
/* Use nvtiler to composite the batched frames into a 2D tiled array based
* on the source of the frames. */
tiler = gst_element_factory_make("nvmultistreamtiler", "nvtiler");
tiler_rows = (guint)sqrt(num_sources);
tiler_columns = (guint)ceil(1.0 * num_sources / tiler_rows);
/* we set the tiler properties here */
g_object_set(G_OBJECT(tiler), "rows", tiler_rows, "columns", tiler_columns,
"width", MUXER_OUTPUT_WIDTH, "height", MUXER_OUTPUT_HEIGHT,
NULL);
SET_GPU_ID(tiler, GPU_ID);
// g_object_set (G_OBJECT (tiler), "show-source", 1);
// g_object_set (G_OBJECT (tiler), "show-source", 0, NULL);
if (!tiler) {
g_printerr("Could not create Tiler. Exiting.\n");
return false;
}
return true;
}

14
src/tiler_manager.hpp Normal file
View File

@ -0,0 +1,14 @@
#include <gst/gst.h>
#include <cmath>
class TilerManager {
private:
guint tiler_rows, tiler_columns;
public:
GstElement *tiler = NULL;
TilerManager();
bool create_tiler(int num_sources, const int, const int);
~TilerManager();
};