32#ifndef OPENSHOT_OBJECT_DETECTION_EFFECT_H
33#define OPENSHOT_OBJECT_DETECTION_EFFECT_H
35#include "../EffectBase.h"
40#include <opencv2/opencv.hpp>
43#include "../KeyFrame.h"
44#include "protobuf_messages/objdetectdata.pb.h"
50 std::vector<int> _classIds,
51 std::vector<float> _confidences,
52 std::vector<cv::Rect_<float>> _boxes,
54 std::vector<int> _objectIds)
65 std::vector<cv::Rect_<float>>
boxes;
77 std::string protobuf_data_path;
78 std::map<size_t, DetectionData> detectionsData;
79 std::vector<std::string> classNames;
81 std::vector<cv::Scalar> classesColor;
86 float confidence_threshold = 0.5;
88 std::vector<std::string> display_classes;
89 std::string class_filter;
92 void init_effect_details();
94 void drawPred(
int classId,
float conf, cv::Rect2d box, cv::Mat& frame,
int objectNumber, std::vector<int> color,
float alpha,
95 int thickness,
bool is_background,
bool draw_text);
97 void DrawRectangleRGBA(cv::Mat &frame_image, cv::RotatedRect box, std::vector<int> color,
float alpha,
int thickness,
bool is_background);
118 std::shared_ptr<Frame>
GetFrame(std::shared_ptr<Frame> frame, int64_t frame_number)
override;
120 std::shared_ptr<openshot::Frame>
GetFrame(int64_t frame_number)
override {
return GetFrame(std::make_shared<Frame>(), frame_number); }
129 std::string
Json()
const override;
130 void SetJson(
const std::string value)
override;
136 std::string
PropertiesJSON(int64_t requested_frame)
const override;
This abstract class is the base class, used by all effects in libopenshot.
A Keyframe is a collection of Point instances, which is used to vary a number or property over time.
This effect displays all the detected objects on a clip.
std::shared_ptr< openshot::Frame > GetFrame(int64_t frame_number) override
This method is required for all derived classes of ClipBase, and returns a new openshot::Frame object...
Json::Value JsonValue() const override
Generate Json::Value for this object.
int selectedObjectIndex
Index of the Tracked Object that was selected to modify it's properties.
std::shared_ptr< Frame > GetFrame(std::shared_ptr< Frame > frame, int64_t frame_number) override
This method is required for all derived classes of EffectBase, and returns a modified openshot::Frame...
ObjectDetection()
Default constructor.
bool LoadObjDetectdData(std::string inputFilePath)
Load protobuf data file.
std::string GetVisibleObjects(int64_t frame_number) const override
Get the indexes and IDs of all visible objects in the given frame.
std::string Json() const override
Generate JSON string of this object.
std::string PropertiesJSON(int64_t requested_frame) const override
void SetJsonValue(const Json::Value root) override
Load Json::Value into this object.
void SetJson(const std::string value) override
Load JSON string into this object.
This namespace is the default namespace for all code in the openshot library.
std::vector< cv::Rect_< float > > boxes
DetectionData(std::vector< int > _classIds, std::vector< float > _confidences, std::vector< cv::Rect_< float > > _boxes, size_t _frameId, std::vector< int > _objectIds)
std::vector< float > confidences
std::vector< int > classIds
std::vector< int > objectIds