gstreamer插件知识总结

gstreamer插件知识总结

1.gstreamer插件内部结构及函数总结

(1)定义插件属性及信号

enum
{
  /* FILL ME */
  SIGNAL_DETECTED,
  LAST_SIGNAL
};

(2)定义衬垫接收和发送的数据类型

static GstStaticPadTemplate sink_factory...

(3)元件属性及信号初始化

gst_human_detection_class_init()

属性初始化样例:

g_object_class_install_property (gobject_class, PROP_PICTUREPATH,
      g_param_spec_string ("picturePath", "picturePath", "output picturePath",
          "NULL", (GParamFlags)(G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS)));

信号初始化样例:

gst_human_detection_signals[SIGNAL_DETECTED] =
			g_signal_new ("detected", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
            G_STRUCT_OFFSET (GstHumanDetectionClass, detected), NULL, NULL,
            g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER);

(4)元件初始化(在加载或使用元件时进行的初始化)

gst_human_detection_init()

在函数中存放如加载网络等只需加载一次无需在循环中次次加载的事件。

(5)属性设置函数

gst_human_detection_set_property()

(6)属性获取函数

gst_human_detection_get_property()

(7)运行主函数(视频流中每一帧图像都会经过此函数处理)

gst_human_detection_chain()

2.插件内部使用知识

(1)锁的使用

pthread_mutex_t threadMutex = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_lock(&threadMutex);
pthread_mutex_unlock(&threadMutex);

(2)初始化信号

static guint gst_human_detection_signals[LAST_SIGNAL] = { 0 };

(3)获取视频流分辨率

int width, height;
GstCaps *caps;
caps = gst_pad_get_current_caps (pad);
GstStructure* structure = gst_caps_get_structure(caps, 0);

gst_structure_get_int(structure, "width", &width);
gst_structure_get_int(structure, "height", &height);
...
gst_caps_unref (caps);

(4)获取视频中每帧的图像

GstMapInfo map;
gst_buffer_map(buf, &map, GST_MAP_READ);
v = Mat(Size(width,height),CV_8UC4,(char *)map.data);
...
memcpy(map.data, v.data, map.size);
gst_buffer_unmap (buf, &map);
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章