1 /* 2 * GStreamer gstreamer-onnxobjectdetector 3 * Copyright (C) 2021 Collabora Ltd 4 * 5 * gstonnxobjectdetector.h 6 * 7 * This library is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Library General Public 9 * License as published by the Free Software Foundation; either 10 * version 2 of the License, or (at your option) any later version. 11 * 12 * This library is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Library General Public License for more details. 16 * 17 * You should have received a copy of the GNU Library General Public 18 * License along with this library; if not, write to the 19 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, 20 * Boston, MA 02110-1301, USA. 21 */ 22 23 #ifndef __GST_ONNX_OBJECT_DETECTOR_H__ 24 #define __GST_ONNX_OBJECT_DETECTOR_H__ 25 26 #include <gst/gst.h> 27 #include <gst/video/video.h> 28 #include <gst/video/gstvideofilter.h> 29 #include "gstonnxelement.h" 30 31 G_BEGIN_DECLS 32 33 #define GST_TYPE_ONNX_OBJECT_DETECTOR (gst_onnx_object_detector_get_type()) 34 G_DECLARE_FINAL_TYPE (GstOnnxObjectDetector, gst_onnx_object_detector, GST, ONNX_OBJECT_DETECTOR, GstBaseTransform) 35 #define GST_ONNX_OBJECT_DETECTOR(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_ONNX_OBJECT_DETECTOR,GstOnnxObjectDetector)) 36 #define GST_ONNX_OBJECT_DETECTOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_ONNX_OBJECT_DETECTOR,GstOnnxObjectDetectorClass)) 37 #define GST_ONNX_OBJECT_DETECTOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GST_TYPE_ONNX_OBJECT_DETECTOR,GstOnnxObjectDetectorClass)) 38 #define GST_IS_ONNX_OBJECT_DETECTOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_ONNX_OBJECT_DETECTOR)) 39 #define GST_IS_ONNX_OBJECT_DETECTOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_ONNX_OBJECT_DETECTOR)) 40 41 #define GST_ONNX_OBJECT_DETECTOR_META_NAME "onnx-object_detector" 42 #define GST_ONNX_OBJECT_DETECTOR_META_PARAM_NAME "extra-data" 43 #define GST_ONNX_OBJECT_DETECTOR_META_FIELD_LABEL "label" 44 #define GST_ONNX_OBJECT_DETECTOR_META_FIELD_SCORE "score" 45 46 /** 47 * GstOnnxObjectDetector: 48 * 49 * @model_file model file 50 * @label_file label file 51 * @score_threshold score threshold 52 * @confidence_threshold confidence threshold 53 * @iou_threhsold iou threshold 54 * @optimization_level ONNX optimization level 55 * @execution_provider: ONNX execution provider 56 * @onnx_ptr opaque pointer to ONNX implementation 57 * 58 * Since: 1.20 59 */ 60 struct _GstOnnxObjectDetector 61 { 62 GstBaseTransform basetransform; 63 gchar *model_file; 64 gchar *label_file; 65 gfloat score_threshold; 66 gfloat confidence_threshold; 67 gfloat iou_threshold; 68 GstOnnxOptimizationLevel optimization_level; 69 GstOnnxExecutionProvider execution_provider; 70 gpointer onnx_ptr; 71 gboolean onnx_disabled; 72 73 void (*process) (GstOnnxObjectDetector * onnx_object_detector, 74 GstVideoFrame * inframe, GstVideoFrame * outframe); 75 }; 76 77 /** 78 * GstOnnxObjectDetectorClass: 79 * 80 * @parent_class base transform base class 81 * 82 * Since: 1.20 83 */ 84 struct _GstOnnxObjectDetectorClass 85 { 86 GstBaseTransformClass parent_class; 87 }; 88 89 GST_ELEMENT_REGISTER_DECLARE (onnx_object_detector) 90 91 G_END_DECLS 92 93 #endif /* __GST_ONNX_OBJECT_DETECTOR_H__ */ 94