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

Class BBox

src/TrackedObjectBBox.h:37–116  ·  view source on GitHub ↗

* @brief This struct holds the information of a bounding-box. * * A bounding-box is a rectangular shape that enclosures an * object or a desired set of pixels in a digital image. * * The bounding-box structure holds five floating-point properties: * the x and y coordinates of the rectangle's center point (cx, cy), * the rectangle's width, height and rotation. */

Source from the content-addressed store, hash-verified

35 * the rectangle's width, height and rotation.
36 */
37 struct BBox
38 {
39 float cx = -1; ///< x-coordinate of the bounding box center
40 float cy = -1; ///< y-coordinate of the bounding box center
41 float width = -1; ///< bounding box width
42 float height = -1; ///< bounding box height
43 float angle = -1; ///< bounding box rotation angle [degrees]
44
45 /// Blank constructor
46 BBox() {}
47
48 /// Default constructor, which takes the bounding box top-left corner coordinates, width and height.
49 /// @param _cx X-coordinate of the bounding box center
50 /// @param _cy Y-coordinate of the bounding box center
51 /// @param _width Bounding box width
52 /// @param _height Bounding box height
53 /// @param _angle Bounding box rotation angle [degrees]
54 BBox(float _cx, float _cy, float _width, float _height, float _angle)
55 {
56 cx = _cx;
57 cy = _cy;
58 width = _width;
59 height = _height;
60 angle = _angle;
61 }
62
63
64 /// Generate JSON string of this object
65 std::string Json() const
66 {
67 return JsonValue().toStyledString();
68 }
69
70 /// Generate Json::Value for this object
71 Json::Value JsonValue() const
72 {
73 Json::Value root;
74 root["cx"] = cx;
75 root["cy"] = cy;
76 root["width"] = width;
77 root["height"] = height;
78 root["angle"] = angle;
79
80 return root;
81 }
82
83 /// Load JSON string into this object
84 void SetJson(const std::string value)
85 {
86 // Parse JSON string into JSON objects
87 try
88 {
89 const Json::Value root = openshot::stringToJson(value);
90 // Set all values that match
91 SetJsonValue(root);
92 }
93 catch (const std::exception &e)
94 {

Callers 1

AddBoxMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected