MCPcopy Create free account
hub / github.com/OpenShot/libopenshot / ObjectDetection

Class ObjectDetection

src/effects/ObjectDetection.h:57–116  ·  view source on GitHub ↗

* @brief This effect displays all the detected objects on a clip. */

Source from the content-addressed store, hash-verified

55 * @brief This effect displays all the detected objects on a clip.
56 */
57 class ObjectDetection : public EffectBase
58 {
59 private:
60 std::string protobuf_data_path;
61 std::map<size_t, DetectionData> detectionsData;
62 std::vector<std::string> classNames;
63 std::vector<cv::Scalar> classesColor;
64
65 /// Draw ALL class name and ID #'s on top of the bounding boxes (or hide all text)
66 Keyframe display_box_text;
67
68 /// Draw ALL tracked bounding boxes (or hide all boxes)
69 Keyframe display_boxes;
70
71 /// Minimum confidence value to display the detected objects
72 float confidence_threshold = 0.5;
73
74 /// Contain the user selected classes for visualization
75 std::vector<std::string> display_classes;
76 std::string class_filter;
77
78 /// Init effect settings
79 void init_effect_details();
80
81 public:
82 /// Index of the Tracked Object that was selected to modify it's properties
83 int selectedObjectIndex;
84
85 /// Default constructor
86 ObjectDetection();
87
88 /// @brief This method is required for all derived classes of EffectBase, and returns a
89 /// modified openshot::Frame object
90 ///
91 /// The frame object is passed into this method, and a frame_number is passed in which
92 /// tells the effect which settings to use from its keyframes (starting at 1).
93 ///
94 /// @returns The modified openshot::Frame object
95 /// @param frame The frame object that needs the effect applied to it
96 /// @param frame_number The frame number (starting at 1) of the effect on the timeline.
97 std::shared_ptr<Frame> GetFrame(std::shared_ptr<Frame> frame, int64_t frame_number) override;
98
99 std::shared_ptr<openshot::Frame> GetFrame(int64_t frame_number) override { return GetFrame(std::make_shared<Frame>(), frame_number); }
100
101 /// Load protobuf data file
102 bool LoadObjDetectdData(std::string inputFilePath);
103
104 /// Get the indexes and IDs of all visible objects in the given frame
105 std::string GetVisibleObjects(int64_t frame_number) const override;
106
107 // Get and Set JSON methods
108 std::string Json() const override; ///< Generate JSON string of this object
109 void SetJson(const std::string value) override; ///< Load JSON string into this object
110 Json::Value JsonValue() const override; ///< Generate Json::Value for this object
111 void SetJsonValue(const Json::Value root) override; ///< Load Json::Value into this object
112
113 /// Get all properties for a specific frame (perfect for a UI to display the current state
114 /// of all properties at any time)

Callers 1

JsonValueMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected