i cant see renderd output window , what is the reason
#include <vtk-9.1/vtkVersion.h>
#include <vtk-9.1/vtkActor.h>
#include <vtk-9.1/vtkDiskSource.h>
#include <vtk-9.1/vtkPolyDataMapper.h>
#include <vtk-9.1/vtkRenderer.h>
#include <vtk-9.1/vtkRenderWindow.h>
#include <vtk-9.1/vtkRenderWindowInteractor.h>
#include <vtk-9.1/vtkSmartPointer.h>
#include <vtk-9.1/vtkNamedColors.h>
#include <iostream>
int main() {
// Print the VTK version
std::cout << "VTK Version: " << vtkVersion::GetVTKVersion() << std::endl;
// Create a disk source to generate a circle (a disk)
vtkSmartPointer<vtkDiskSource> diskSource = vtkSmartPointer<vtkDiskSource>::New();
diskSource->SetOuterRadius(5.0);
diskSource->SetRadialResolution(100); // Resolution of the circle
// Create a mapper to map the disk data to graphics
vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputConnection(diskSource->GetOutputPort());
// Create an actor to represent the circle in the window
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);
// Create a renderer
vtkSmartPointer<vtkRenderer> renderer = vtkSmartPointer<vtkRenderer>::New();
// Create a render window
vtkSmartPointer<vtkRenderWindow> renderWindow = vtkSmartPointer<vtkRenderWindow>::New();
renderWindow->AddRenderer(renderer);
// Create a render window interactor to interact with the window
vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor = vtkSmartPointer<vtkRenderWindowInteractor>::New();
renderWindowInteractor->SetRenderWindow(renderWindow);
// Add the actor to the renderer
renderer->AddActor(actor);
// Set the background color to white
vtkSmartPointer<vtkNamedColors> colors = vtkSmartPointer<vtkNamedColors>::New();
renderer->SetBackground(colors->GetColor3d("White").GetData());
// Start the rendering loop
renderWindow->Render();
renderWindowInteractor->Start();
return 0;
}
here i attaching makefile, in this makfile i included deepstream and opencv for developing my application
Hi When I integrate Deepstream and OpenCV at CMakeLists.txt, My code is working It didnt show any error but i cant see rendering output, here I attaching my code and CMakeLists.txt
#include <gst/gst.h>
#include <glib.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <sys/time.h>
#include <cuda_runtime_api.h>
#include <tuple>
#include <GeographicLib/UTMUPS.hpp> // Example: Include a UTM conversion library like GeographicLib or proj
#include "gstnvdsmeta.h"
#include "nvds_yml_parser.h"
#include "gst-nvmessage.h"
#include <opencv2/opencv.hpp>
#include <iostream>
#include <cmath>
#include <vector>
#include <random>
#include <string>
#include <gdal.h>
#include <gdal_priv.h>
#include <ogrsf_frmts.h>
#include "ogr_spatialref.h"
#include <gdal_priv.h> // For GDAL, used to read shapefiles and handle projections
#include <ogr_api.h>
#include <ogr_geometry.h>
#include <ogr_feature.h>
#include <utility>
#include <vtkActor.h>
#include <vtkCamera.h>
#include <vtkCylinderSource.h>
#include <vtkNamedColors.h>
#include <vtkNew.h>
#include <vtkPolyDataMapper.h>
#include <vtkProperty.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkRenderer.h>
#include <array>
#define MAX_DISPLAY_LEN 64
#define PGIE_CLASS_ID_VEHICLE 0
#define PGIE_CLASS_ID_PERSON 2
/* By default, OSD process-mode is set to GPU_MODE. To change mode, set as:
* 0: CPU mode
* 1: GPU mode
*/
#define OSD_PROCESS_MODE 1
/* By default, OSD will not display text. To display text, change this to 1 */
#define OSD_DISPLAY_TEXT 0
/* The muxer output resolution must be set if the input streams will be of
* different resolution. The muxer will scale all the input frames to this
* resolution. */
#define MUXER_OUTPUT_WIDTH 854
#define MUXER_OUTPUT_HEIGHT 480
/* Muxer batch formation timeout, for e.g. 40 millisec. Should ideally be set
* based on the fastest source's framerate. */
#define MUXER_BATCH_TIMEOUT_USEC 40000
#define TILED_OUTPUT_WIDTH 1280
#define TILED_OUTPUT_HEIGHT 720
/* NVIDIA Decoder source pad memory feature. This feature signifies that source
* pads having this capability will push GstBuffers containing cuda buffers. */
#define GST_CAPS_FEATURES_NVMM "memory:NVMM"
/* Check for parsing error. */
#define RETURN_ON_PARSER_ERROR(parse_expr) \
if (NVDS_YAML_PARSER_SUCCESS != parse_expr) { \
g_printerr("Error in parsing configuration file.\n"); \
return -1; \
}
int main(int, char*[])
{
vtkNew<vtkNamedColors> colors;
// Set the background color.
std::array<unsigned char, 4> bkg{{26, 51, 102, 255}};
colors->SetColor("BkgColor", bkg.data());
// This creates a polygonal cylinder model with eight circumferential facets
// (i.e, in practice an octagonal prism).
vtkNew<vtkCylinderSource> cylinder;
cylinder->SetResolution(8);
// The mapper is responsible for pushing the geometry into the graphics
// library. It may also do color mapping, if scalars or other attributes are
// defined.
vtkNew<vtkPolyDataMapper> cylinderMapper;
cylinderMapper->SetInputConnection(cylinder->GetOutputPort());
// The actor is a grouping mechanism: besides the geometry (mapper), it
// also has a property, transformation matrix, and/or texture map.
// Here we set its color and rotate it around the X and Y axes.
vtkNew<vtkActor> cylinderActor;
cylinderActor->SetMapper(cylinderMapper);
cylinderActor->GetProperty()->SetColor(
colors->GetColor4d("Tomato").GetData());
cylinderActor->RotateX(30.0);
cylinderActor->RotateY(-45.0);
// The renderer generates the image
// which is then displayed on the render window.
// It can be thought of as a scene to which the actor is added
vtkNew<vtkRenderer> renderer;
renderer->AddActor(cylinderActor);
renderer->SetBackground(colors->GetColor3d("BkgColor").GetData());
// Zoom in a little by accessing the camera and invoking its "Zoom" method.
renderer->ResetCamera();
renderer->GetActiveCamera()->Zoom(1.5);
// The render window is the actual GUI window
// that appears on the computer screen
vtkNew<vtkRenderWindow> renderWindow;
renderWindow->SetSize(300, 300);
renderWindow->AddRenderer(renderer);
renderWindow->SetWindowName("Cylinder");
// The render window interactor captures mouse events
// and will perform appropriate camera or actor manipulation
// depending on the nature of the events.
vtkNew<vtkRenderWindowInteractor> renderWindowInteractor;
renderWindowInteractor->SetRenderWindow(renderWindow);
// This starts the event loop and as a side effect causes an initial render.
renderWindow->Render();
renderWindowInteractor->Start();
return EXIT_SUCCESS;
}
This is CMakeLists.txt
# Set minimum required CMake version
cmake_minimum_required(VERSION 3.12)
# Define the project name
project(DeepstreamTest3App)
# Set CUDA version and paths
set(CUDA_VER "12.2")
# Set the DeepStream version
set(NVDS_VERSION "7.0")
# Find VTK and OpenCV packages
find_package(VTK REQUIRED
COMPONENTS
CommonColor
CommonCore
FiltersSources
InteractionStyle
RenderingCore
RenderingFreeType
RenderingOpenGL2
IOCore
IOImage
CommonDataModel
)
find_package(OpenCV REQUIRED)
# Find GStreamer (for DeepStream)
find_package(PkgConfig REQUIRED)
pkg_check_modules(GSTREAMER REQUIRED gstreamer-1.0)
# Add include directories
include_directories(
/usr/local/cuda-${CUDA_VER}/include
/usr/include/gstreamer-1.0
/usr/include/aarch64-linux-gnu
/usr/include/glib-2.0
/usr/lib/aarch64-linux-gnu/glib-2.0/include
/usr/include/opencv4
/opt/nvidia/deepstream/deepstream-${NVDS_VERSION}/sources/includes
${VTK_INCLUDE_DIRS}
${OpenCV_INCLUDE_DIRS}
)
# Define the source files
set(SRCS
main.cxx
)
# Define the executable
add_executable(${PROJECT_NAME} ${SRCS})
# Set compiler flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
# Link directories for DeepStream libraries
link_directories(
/opt/nvidia/deepstream/deepstream-${NVDS_VERSION}/lib
/opt/nvidia/deepstream/deepstream-${NVDS_VERSION}/sources/libs
)
# Link libraries
target_link_libraries(${PROJECT_NAME}
${GSTREAMER_LIBRARIES}
${VTK_LIBRARIES}
${OpenCV_LIBS}
/lib/aarch64-linux-gnu/libGeographic.so.19.2.0
/usr/local/cuda-${CUDA_VER}/lib64/libcudart.so
/usr/lib/aarch64-linux-gnu/libcuda.so
/usr/lib/aarch64-linux-gnu/libproj.so
/opt/nvidia/deepstream/deepstream-7.0/lib/libnvdsgst_meta.so
/opt/nvidia/deepstream/deepstream-7.0/lib/libnvds_meta.so
/opt/nvidia/deepstream/deepstream-7.0/lib/libnvdsgst_helper.so
/opt/nvidia/deepstream/deepstream-7.0/lib/libnvds_utils.so
/opt/nvidia/deepstream/deepstream-7.0/lib/libnvds_msgbroker.so
/opt/nvidia/deepstream/deepstream-7.0/lib/libnvbufsurface.so
/opt/nvidia/deepstream/deepstream-7.0/lib/libnvbufsurftransform.so
-lGL
-lGLU
-lgdal
-lsqlite3
)
# Set RPATH for DeepStream libraries
set_target_properties(${PROJECT_NAME} PROPERTIES
INSTALL_RPATH "/opt/nvidia/deepstream/deepstream-${NVDS_VERSION}/lib"
)
# Install the executable to the DeepStream bin directory
install(TARGETS ${PROJECT_NAME} DESTINATION /opt/nvidia/deepstream/deepstream-${NVDS_VERSION}/bin)
# Enable debugging symbols
set(CMAKE_BUILD_TYPE Debug)