Ask for help for my Plugin

Dear friend:
I am trying to modify the dsexample as my plugin. I did the following process:
(1) copy the “gst-dsexample” folder and rename as “gst-myplugin”

(2) modify all the files’ name of the folder in this folder from “dsexample” to “myplugin” include .c, .cpp, .h, makefile

(3) modify all the variables, classs, and functions in the files from “dsexample” to “myplugin”

I check the all files very carefully one by one. And I thank all the modification is right. However, when run “sudo make”
there is a error as below:

gstmyplugin.cpp: In function ‘GType gst_myplugin_get_type()’:
/usr/include/glib-2.0/gobject/gtype.h:1978:56: error: invalid application of ‘sizeof’ to incomplete type ‘GstMyplugin {aka _GstMyplugin}’
sizeof (TypeName),
^
/usr/include/glib-2.0/gobject/gtype.h:1995:3: note: in expansion of macro ‘_G_DEFINE_TYPE_EXTENDED_BEGIN_REGISTER’
_G_DEFINE_TYPE_EXTENDED_BEGIN_REGISTER(TypeName, type_name, TYPE_PARENT, flags)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/glib-2.0/gobject/gtype.h:1737:60: note: in expansion of macro ‘_G_DEFINE_TYPE_EXTENDED_BEGIN’
#define G_DEFINE_TYPE_EXTENDED(TN, t_n, T_P, f, C) _G_DEFINE_TYPE_EXTENDED_BEGIN (TN, t_n, T_P, f) {C;} _G_DEFINE_TYPE_EXTENDED_END()
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/glib-2.0/gobject/gtype.h:1595:43: note: in expansion of macro ‘G_DEFINE_TYPE_EXTENDED’
#define G_DEFINE_TYPE(TN, t_n, T_P) G_DEFINE_TYPE_EXTENDED (TN, t_n, T_P, 0, {})
^~~~~~~~~~~~~~~~~~~~~~
gstmyplugin.cpp:98:1: note: in expansion of macro ‘G_DEFINE_TYPE’
G_DEFINE_TYPE (GstMyplugin, gst_myplugin, GST_TYPE_BASE_TRANSFORM);
^
gstmyplugin.cpp: In function ‘void gst_myplugine_init(GstMyplugin*)’:
gstmyplugin.cpp:220:11: error: invalid use of incomplete type ‘GstMyplugin {aka struct _GstMyplugin}’
myplugin->unique_id = DEFAULT_UNIQUE_ID;

I guess the error “GstMyplugin” has not registered. I have no idea to solve the problem. Please help me. Thank you very much.

I checked. The make process broken at the point of
“G_DEFINE_TYPE (GstMyplugin, gst_myplugin, ST_TYPE_BASE_TRANSFORM);”

The code as below:

#include <string.h>
#include
#include
#include
#include
#include
#include “gstmyplugin.h”
#include <sys/time.h>
GST_DEBUG_CATEGORY_STATIC (gst_myplugin_debug);

#define GST_CAT_DEFAULT gst_myplugin_debug
#define USE_EGLIMAGE 1

#include<stdio.h>
#include
#include<unordered_set>
using namespace std;

#define MAX_DISPLAY_LEN 64
static GQuark _dsmeta_quark = 0;
enum
{
PROP_0,
PROP_UNIQUE_ID,
PROP_PROCESSING_WIDTH,
PROP_PROCESSING_HEIGHT,
PROP_PROCESS_FULL_FRAME,
PROP_BLUR_OBJECTS,
PROP_GPU_DEVICE_ID
};

#define CHECK_NVDS_MEMORY_AND_GPUID(object, surface)
({ int _errtype=0;
do {
if ((surface->memType == NVBUF_MEM_DEFAULT || surface->memType == NVBUF_MEM_CUDA_DEVICE) &&
(surface->gpuId != object->gpu_id)) {
GST_ELEMENT_ERROR (object, RESOURCE, FAILED,
(“Input surface gpu-id doesnt match with configured gpu-id for element,”
" please allocate input using unified memory, or use same gpu-ids"),
(“surface-gpu-id=%d,%s-gpu-id=%d”,surface->gpuId,GST_ELEMENT_NAME(object),
object->gpu_id));
_errtype = 1;
}
} while(0);
_errtype;
})

/* Default values for properties */
#define DEFAULT_UNIQUE_ID 15
#define DEFAULT_PROCESSING_WIDTH 640
#define DEFAULT_PROCESSING_HEIGHT 480
#define DEFAULT_PROCESS_FULL_FRAME TRUE
#define DEFAULT_BLUR_OBJECTS FALSE
#define DEFAULT_GPU_ID 0

#define RGB_BYTES_PER_PIXEL 3
#define RGBA_BYTES_PER_PIXEL 4
#define Y_BYTES_PER_PIXEL 1
#define UV_BYTES_PER_PIXEL 2

#define MIN_INPUT_OBJECT_WIDTH 16
#define MIN_INPUT_OBJECT_HEIGHT 16

#define CHECK_NPP_STATUS(npp_status,error_str) do {
if ((npp_status) != NPP_SUCCESS) {
g_print (“Error: %s in %s at line %d: NPP Error %d\n”,
error_str, FILE, LINE, npp_status);
goto error;
}
} while (0)

#define CHECK_CUDA_STATUS(cuda_status,error_str) do {
if ((cuda_status) != cudaSuccess) {
g_print (“Error: %s in %s at line %d (%s)\n”,
error_str, FILE, LINE, cudaGetErrorName(cuda_status));
goto error;
}
} while (0)

#define GST_CAPS_FEATURE_MEMORY_NVMM “memory:NVMM”
static GstStaticPadTemplate gst_myplugin_sink_template =
GST_STATIC_PAD_TEMPLATE (“sink”,
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE_WITH_FEATURES
(GST_CAPS_FEATURE_MEMORY_NVMM,
“{ NV12, RGBA, I420 }”)));

static GstStaticPadTemplate gst_myplugin_src_template =
GST_STATIC_PAD_TEMPLATE (“src”,
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE_WITH_FEATURES
(GST_CAPS_FEATURE_MEMORY_NVMM,
“{ NV12, RGBA, I420 }”)));

/* Define our element type. Standard GObject/GStreamer boilerplate stuff */
#define gst_myplugin_parent_class parent_class

G_DEFINE_TYPE (GstMyplugin, gst_myplugin, GST_TYPE_BASE_TRANSFORM);

//static void gst_myplugin_set_property (GObject * object, guint prop_id,
// const GValue * value, GParamSpec * pspec);
//static void gst_myplugin_get_property (GObject * object, guint prop_id,
// GValue * value, GParamSpec * pspec);
//
//static gboolean gst_myplugin_set_caps (GstBaseTransform * btrans,
// GstCaps * incaps, GstCaps * outcaps);
//static gboolean gst_myplugin_start (GstBaseTransform * btrans);
//static gboolean gst_myplugin_stop (GstBaseTransform * btrans);
//
//static GstFlowReturn gst_myplugin_transform_ip (GstBaseTransform *
// btrans, GstBuffer * inbuf);
//
//static void
//attach_metadata_full_frame (GstMyplugin * myplugin, NvDsFrameMeta *frame_meta,
// gdouble scale_ratio, MypluginOutput * output, guint batch_id);
//static void attach_metadata_object (GstMyplugin * myplugin,
// NvDsObjectMeta * obj_meta, MypluginOutput * output);

the rest code are commented out.

Thank you very much

This is not deepstream topic.

Plugin Writer’s Guide (gstreamer.freedesktop.org)

Modifying the gst-dsexample - Intelligent Video Analytics / DeepStream SDK - NVIDIA Developer Forums

Thank you for your reply. I have solve it.
Because the variable is spelled wrong.