inference.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #pragma once
  2. #include <iostream>
  3. #include <stdio.h>
  4. #include <string.h>
  5. #include <gst/gst.h>
  6. #include <glib.h>
  7. #include <stdio.h>
  8. #include <math.h>
  9. #include <string.h>
  10. #include <sys/time.h>
  11. #include "gstnvdsmeta.h"
  12. #include "gst-nvmessage.h"
  13. #include "user_app.h"
  14. #include <list>
  15. using namespace std;
  16. namespace VIA{
  17. // 基于Deepstream
  18. class Inference
  19. {
  20. private:
  21. // Deepstream
  22. GMainLoop *loop = NULL;
  23. GstElement *pipeline = NULL,*streammux = NULL, *sink = NULL, *pgie = NULL,
  24. *queue1, *queue2, *queue3, *queue4, *queue5, *nvvidconv = NULL,
  25. *nvosd = NULL, *tiler = NULL;
  26. GstElement *transform = NULL;
  27. GstBus *bus = NULL;
  28. guint bus_watch_id;
  29. GstPad *tiler_src_pad = NULL;
  30. guint tiler_rows, tiler_columns;
  31. guint pgie_batch_size;
  32. public:
  33. static std::shared_ptr<Inference> CreateNew();
  34. Inference();
  35. ~Inference();
  36. public:
  37. int32_t Init();
  38. void Destory();
  39. void StartTask();
  40. private:
  41. // static
  42. static GstPadProbeReturn tiler_src_pad_buffer_probe(GstPad * pad, GstPadProbeInfo * info, gpointer u_data);
  43. static gboolean bus_call (GstBus * bus, GstMessage * msg, gpointer data);
  44. static void cb_newpad (GstElement * decodebin, GstPad * decoder_src_pad, gpointer data);
  45. static void decodebin_child_added (GstChildProxy * child_proxy, GObject * object,
  46. gchar * name, gpointer user_data);
  47. static GstElement* create_source_bin(guint index, gchar * uri);
  48. };
  49. }