14 #ifndef OPENSHOT_TRACKEDOBJECTBBOX_H
15 #define OPENSHOT_TRACKEDOBJECTBBOX_H
31 std::vector<uint32_t>
rle;
63 BBox(
float _cx,
float _cy,
float _width,
float _height,
float _angle)
85 root[
"width"] =
width;
87 root[
"angle"] =
angle;
102 catch (
const std::exception &e)
105 throw InvalidJSON(
"JSON is invalid (missing keys or invalid data types)");
114 if (!root[
"cx"].isNull())
115 cx = root[
"cx"].asDouble();
116 if (!root[
"cy"].isNull())
117 cy = root[
"cy"].asDouble();
118 if (!root[
"width"].isNull())
119 width = root[
"width"].asDouble();
120 if (!root[
"height"].isNull())
121 height = root[
"height"].asDouble();
122 if (!root[
"angle"].isNull())
123 angle = root[
"angle"].asDouble();
168 void AddBox(int64_t _frame_num,
float _cx,
float _cy,
float _width,
float _height,
float _angle)
override;
170 bool HasMask(int64_t frame_number, int64_t max_frame_gap = 0)
const;
184 bool Contains(int64_t frame_number)
const;
203 double ScaledStrokeWidth(int64_t frame_number,
int image_width,
int image_height)
const;
209 double FrameNToTime(int64_t frame_number,
double time_scale)
const;
218 std::string
Json()
const override;
220 void SetJson(
const std::string value)
override;
225 Json::Value
PropertiesJSON(int64_t requested_frame)
const override;
228 Json::Value
add_property_json(std::string name,
float value, std::string type, std::string memo,
const Keyframe* keyframe,
float min_value,
float max_value,
bool readonly, int64_t requested_frame)
const;
231 std::map<std::string, float>
GetBoxValues(int64_t frame_number)
const override;
Header file for Color class.
Header file for all Exception classes.
Header file for Fraction class.
Header file for JSON class.
Header file for the Keyframe class.
Header file for the TrackedObjectBase class.
This class represents a color (used on the timeline and clips)
This class represents a fraction.
Exception for invalid JSON.
A Keyframe is a collection of Point instances, which is used to vary a number or property over time.
This class contains the properties of a tracked object and functions to manipulate it.
Keyframe delta_x
X-direction displacement Keyframe.
Color mask_color
Object mask overlay color.
bool LoadBoxData(std::string inputFilePath)
Load the bounding-boxes information from the protobuf file.
Color stroke
Border line color.
int64_t GetLength() const
Get the size of BoxVec map.
Keyframe stroke_width
Thickness of border line.
void SetJsonValue(const Json::Value root) override
Load Json::Value into this object.
std::map< double, ObjectMaskData > MaskVec
Index optional object masks by time of each frame.
void AddBox(int64_t _frame_num, float _cx, float _cy, float _width, float _height, float _angle) override
Add a BBox to the BoxVec map.
TrackedObjectBBox()
Default Constructor.
void SetBaseFPS(Fraction fps)
Update object's BaseFps.
void SetJson(const std::string value) override
Load JSON string into this object.
Json::Value add_property_json(std::string name, float value, std::string type, std::string memo, const Keyframe *keyframe, float min_value, float max_value, bool readonly, int64_t requested_frame) const
void clear()
Clear the BoxVec map.
Keyframe delta_y
Y-direction displacement Keyframe.
Keyframe mask_alpha
Object mask overlay opacity.
Color background
Background fill color.
double ScaledStrokeWidth(int64_t frame_number, int image_width, int image_height) const
Return stroke width adjusted for source-to-output raster scaling.
BBox GetBox(int64_t frame_number) const
Const-cast of the GetBox function, so that it can be called inside other cont function.
std::map< double, BBox > BoxVec
Index the bounding-box by time of each frame.
std::string Json() const override
Get and Set JSON methods.
bool ExactlyContains(int64_t frame_number) const override
Check if there is a bounding-box in the exact frame number.
void ScalePoints(double scale) override
Update the TimeScale member variable.
void AddMask(int64_t frame_num, const ObjectMaskData &mask)
BBox InterpolateBoxes(double t1, double t2, BBox left, BBox right, double target)
Interpolate the bouding-boxes properties.
Fraction GetBaseFPS()
Return the object's BaseFps.
Json::Value PropertiesJSON(int64_t requested_frame) const override
Keyframe background_alpha
Background box opacity.
void RemoveBox(int64_t frame_number)
Remove a bounding-box from the BoxVec map.
bool HasMask(int64_t frame_number, int64_t max_frame_gap=0) const
bool Contains(int64_t frame_number) const
Check if there is a bounding-box in the given frame.
std::map< std::string, float > GetBoxValues(int64_t frame_number) const override
Return a map that contains the bounding box properties and it's keyframes indexed by their names.
Json::Value JsonValue() const override
Generate Json::Value for this object.
Keyframe scale_y
Y-direction scale Keyframe.
std::string protobufDataPath
Path to the protobuf file that holds the bounding box points across the frames.
Keyframe stroke_alpha
Stroke box opacity.
double FrameNToTime(int64_t frame_number, double time_scale) const
Get the time of the given frame.
Keyframe scale_x
X-direction scale Keyframe.
BBox GetBox(int64_t frame_number)
Return a bounding-box from BoxVec with it's properties adjusted by the Keyframes.
ObjectMaskData GetMask(int64_t frame_number, int64_t max_frame_gap=0) const
Keyframe background_corner
Radius of rounded corners.
This abstract class is the base class of all Tracked Objects.
This namespace is the default namespace for all code in the openshot library.
const Json::Value stringToJson(const std::string value)
This struct holds the information of a bounding-box.
float cy
y-coordinate of the bounding box center
float height
bounding box height
float cx
x-coordinate of the bounding box center
std::string Json() const
Generate JSON string of this object.
void SetJson(const std::string value)
Load JSON string into this object.
Json::Value JsonValue() const
Generate Json::Value for this object.
void SetJsonValue(const Json::Value root)
Load Json::Value into this object.
BBox(float _cx, float _cy, float _width, float _height, float _angle)
float width
bounding box width
float angle
bounding box rotation angle [degrees]
std::vector< uint32_t > rle