OpenShot Library | libopenshot 1.1.1
Loading...
Searching...
No Matches
openshot::TrackedObjectBBox Class Reference

This class contains the properties of a tracked object and functions to manipulate it. More...

#include <TrackedObjectBBox.h>

Inheritance diagram for openshot::TrackedObjectBBox:
openshot::TrackedObjectBase

Public Member Functions

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 AddBox (int64_t _frame_num, float _cx, float _cy, float _width, float _height, float _angle) override
 Add a BBox to the BoxVec map.
void AddMask (int64_t frame_num, const ObjectMaskData &mask)
void clear ()
 Clear the BoxVec map.
bool Contains (int64_t frame_number) const
 Check if there is a bounding-box in the given frame.
bool ExactlyContains (int64_t frame_number) const override
 Check if there is a bounding-box in the exact frame number.
double FrameNToTime (int64_t frame_number, double time_scale) const
 Get the time of the given frame.
Fraction GetBaseFPS ()
 Return the object's BaseFps.
BBox GetBox (int64_t frame_number)
 Return a bounding-box from BoxVec with it's properties adjusted by the Keyframes.
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< 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.
int64_t GetLength () const
 Get the size of BoxVec map.
ObjectMaskData GetMask (int64_t frame_number, int64_t max_frame_gap=0) const
bool HasMask (int64_t frame_number, int64_t max_frame_gap=0) const
bool HasMaskData () const
BBox InterpolateBoxes (double t1, double t2, BBox left, BBox right, double target)
 Interpolate the bouding-boxes properties.
std::string Json () const override
 Get and Set JSON methods.
Json::Value JsonValue () const override
 Generate Json::Value for this object.
bool LoadBoxData (std::string inputFilePath)
 Load the bounding-boxes information from the protobuf file.
Json::Value PropertiesJSON (int64_t requested_frame) const override
void RemoveBox (int64_t frame_number)
 Remove a bounding-box from the BoxVec map.
double ScaledStrokeWidth (int64_t frame_number, int image_width, int image_height) const
 Return stroke width adjusted for source-to-output raster scaling.
void ScalePoints (double scale) override
 Update the TimeScale member variable.
void SetBaseFPS (Fraction fps)
 Update object's BaseFps.
void SetJson (const std::string value) override
 Load JSON string into this object.
void SetJsonValue (const Json::Value root) override
 Load Json::Value into this object.
 TrackedObjectBBox ()
 Default Constructor.
 TrackedObjectBBox (int Red, int Green, int Blue, int Alfa)
Public Member Functions inherited from openshot::TrackedObjectBase
Json::Value add_property_choice_json (std::string name, int value, int selected_value) const
 Generate JSON choice for a property (dropdown properties).
std::string Id () const
 Get the id of this object.
void Id (std::string _id)
 Set the id of this object.
ClipBase * ParentClip () const
 Get and set the parentClip of this object.
void ParentClip (ClipBase *clip)
 TrackedObjectBase ()
 Default constructor.
 TrackedObjectBase (std::string _id)
 Constructor which takes an object ID.
virtual ~TrackedObjectBase ()=default
 Destructor.

Public Attributes

Color background
 Background fill color.
Keyframe background_alpha
 Background box opacity.
Keyframe background_corner
 Radius of rounded corners.
std::map< double, BBox > BoxVec
 Index the bounding-box by time of each frame.
Keyframe delta_x
 X-direction displacement Keyframe.
Keyframe delta_y
 Y-direction displacement Keyframe.
Keyframe mask_alpha
 Object mask overlay opacity.
Color mask_color
 Object mask overlay color.
std::map< double, ObjectMaskData > MaskVec
 Index optional object masks by time of each frame.
std::string protobufDataPath
 Path to the protobuf file that holds the bounding box points across the frames.
Keyframe scale_x
 X-direction scale Keyframe.
Keyframe scale_y
 Y-direction scale Keyframe.
Color stroke
 Border line color.
Keyframe stroke_alpha
 Stroke box opacity.
Keyframe stroke_width
 Thickness of border line.
Public Attributes inherited from openshot::TrackedObjectBase
Keyframe draw_box
 Keyframe to determine if a specific box is drawn (or hidden).
Keyframe draw_mask
 Keyframe to determine if a specific object mask is drawn (when mask data exists).
Keyframe draw_text
 Keyframe to determine if a specific object label is drawn (or hidden).
Keyframe visible
 Keyframe to track if a box is visible in the current frame (read-only).

Additional Inherited Members

Protected Attributes inherited from openshot::TrackedObjectBase
std::string id
ClipBase * parentClip

Detailed Description

This class contains the properties of a tracked object and functions to manipulate it.

The bounding-box displacement in X and Y directions, it's width, and height variation over the frames are set as openshot::Keyframe objects.

The bounding-box information over the clip's frames are saved into a protobuf file and loaded into an object of this class.

Definition at line 139 of file TrackedObjectBBox.h.

Constructor & Destructor Documentation

◆ TrackedObjectBBox() [1/2]

TrackedObjectBBox::TrackedObjectBBox ( )

Default Constructor.

Definition at line 118 of file TrackedObjectBBox.cpp.

Referenced by GetBox(), and TrackedObjectBBox().

◆ TrackedObjectBBox() [2/2]

TrackedObjectBBox::TrackedObjectBBox ( int Red,
int Green,
int Blue,
int Alfa )

Definition at line 123 of file TrackedObjectBBox.cpp.

Member Function Documentation

◆ add_property_json()

Json::Value TrackedObjectBBox::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

Definition at line 661 of file TrackedObjectBBox.cpp.

Referenced by PropertiesJSON().

◆ AddBox()

void TrackedObjectBBox::AddBox ( int64_t _frame_num,
float _cx,
float _cy,
float _width,
float _height,
float _angle )
overridevirtual

Add a BBox to the BoxVec map.

Reimplemented from openshot::TrackedObjectBase.

Definition at line 137 of file TrackedObjectBBox.cpp.

Referenced by LoadBoxData(), and openshot::ObjectDetection::LoadObjDetectdData().

◆ AddMask()

void TrackedObjectBBox::AddMask ( int64_t frame_num,
const ObjectMaskData & mask )

◆ clear()

void TrackedObjectBBox::clear ( )

Clear the BoxVec map.

Definition at line 467 of file TrackedObjectBBox.cpp.

Referenced by LoadBoxData().

◆ Contains()

bool TrackedObjectBBox::Contains ( int64_t frame_number) const

Check if there is a bounding-box in the given frame.

Definition at line 218 of file TrackedObjectBBox.cpp.

◆ ExactlyContains()

bool TrackedObjectBBox::ExactlyContains ( int64_t frame_number) const
overridevirtual

Check if there is a bounding-box in the exact frame number.

Reimplemented from openshot::TrackedObjectBase.

Definition at line 232 of file TrackedObjectBBox.cpp.

◆ FrameNToTime()

double TrackedObjectBBox::FrameNToTime ( int64_t frame_number,
double time_scale ) const

Get the time of the given frame.

Definition at line 396 of file TrackedObjectBBox.cpp.

Referenced by AddBox(), AddMask(), Contains(), ExactlyContains(), GetBox(), GetMask(), and RemoveBox().

◆ GetBaseFPS()

Fraction TrackedObjectBBox::GetBaseFPS ( )

Return the object's BaseFps.

Definition at line 391 of file TrackedObjectBBox.cpp.

◆ GetBox() [1/2]

BBox TrackedObjectBBox::GetBox ( int64_t frame_number)

Return a bounding-box from BoxVec with it's properties adjusted by the Keyframes.

Definition at line 261 of file TrackedObjectBBox.cpp.

Referenced by GetBox(), GetBoxValues(), and PropertiesJSON().

◆ GetBox() [2/2]

BBox openshot::TrackedObjectBBox::GetBox ( int64_t frame_number) const
inline

Const-cast of the GetBox function, so that it can be called inside other cont function.

Definition at line 197 of file TrackedObjectBBox.h.

◆ GetBoxValues()

std::map< std::string, float > TrackedObjectBBox::GetBoxValues ( int64_t frame_number) const
overridevirtual

Return a map that contains the bounding box properties and it's keyframes indexed by their names.

Reimplemented from openshot::TrackedObjectBase.

Definition at line 698 of file TrackedObjectBBox.cpp.

◆ GetLength()

int64_t TrackedObjectBBox::GetLength ( ) const

Get the size of BoxVec map.

Definition at line 208 of file TrackedObjectBBox.cpp.

◆ GetMask()

ObjectMaskData TrackedObjectBBox::GetMask ( int64_t frame_number,
int64_t max_frame_gap = 0 ) const

Definition at line 182 of file TrackedObjectBBox.cpp.

Referenced by HasMask().

◆ HasMask()

bool TrackedObjectBBox::HasMask ( int64_t frame_number,
int64_t max_frame_gap = 0 ) const

Definition at line 172 of file TrackedObjectBBox.cpp.

◆ HasMaskData()

bool TrackedObjectBBox::HasMaskData ( ) const

Definition at line 177 of file TrackedObjectBBox.cpp.

Referenced by PropertiesJSON().

◆ InterpolateBoxes()

BBox TrackedObjectBBox::InterpolateBoxes ( double t1,
double t2,
BBox left,
BBox right,
double target )

Interpolate the bouding-boxes properties.

Definition at line 351 of file TrackedObjectBBox.cpp.

Referenced by GetBox().

◆ Json()

std::string TrackedObjectBBox::Json ( ) const
overridevirtual

Get and Set JSON methods.

Generate JSON string of this object

Implements openshot::TrackedObjectBase.

Definition at line 474 of file TrackedObjectBBox.cpp.

◆ JsonValue()

Json::Value TrackedObjectBBox::JsonValue ( ) const
overridevirtual

Generate Json::Value for this object.

Implements openshot::TrackedObjectBase.

Definition at line 481 of file TrackedObjectBBox.cpp.

Referenced by Json().

◆ LoadBoxData()

bool TrackedObjectBBox::LoadBoxData ( std::string inputFilePath)

Load the bounding-boxes information from the protobuf file.

Definition at line 408 of file TrackedObjectBBox.cpp.

◆ PropertiesJSON()

Json::Value TrackedObjectBBox::PropertiesJSON ( int64_t requested_frame) const
overridevirtual

Get all properties for a specific frame (perfect for a UI to display the current state of all properties at any time)

Implements openshot::TrackedObjectBase.

Definition at line 598 of file TrackedObjectBBox.cpp.

◆ RemoveBox()

void TrackedObjectBBox::RemoveBox ( int64_t frame_number)

Remove a bounding-box from the BoxVec map.

Definition at line 246 of file TrackedObjectBBox.cpp.

◆ ScaledStrokeWidth()

double TrackedObjectBBox::ScaledStrokeWidth ( int64_t frame_number,
int image_width,
int image_height ) const

Return stroke width adjusted for source-to-output raster scaling.

Definition at line 309 of file TrackedObjectBBox.cpp.

◆ ScalePoints()

void TrackedObjectBBox::ScalePoints ( double scale)
overridevirtual

Update the TimeScale member variable.

Reimplemented from openshot::TrackedObjectBase.

Definition at line 403 of file TrackedObjectBBox.cpp.

Referenced by SetJsonValue().

◆ SetBaseFPS()

void TrackedObjectBBox::SetBaseFPS ( Fraction fps)

Update object's BaseFps.

Definition at line 385 of file TrackedObjectBBox.cpp.

◆ SetJson()

void TrackedObjectBBox::SetJson ( const std::string value)
overridevirtual

Load JSON string into this object.

Implements openshot::TrackedObjectBase.

Definition at line 517 of file TrackedObjectBBox.cpp.

◆ SetJsonValue()

void TrackedObjectBBox::SetJsonValue ( const Json::Value root)
overridevirtual

Load Json::Value into this object.

Implements openshot::TrackedObjectBase.

Definition at line 535 of file TrackedObjectBBox.cpp.

Referenced by SetJson().

Member Data Documentation

◆ background

Color openshot::TrackedObjectBBox::background

Background fill color.

Definition at line 158 of file TrackedObjectBBox.h.

Referenced by JsonValue(), PropertiesJSON(), SetJsonValue(), and TrackedObjectBBox().

◆ background_alpha

Keyframe openshot::TrackedObjectBBox::background_alpha

◆ background_corner

Keyframe openshot::TrackedObjectBBox::background_corner

Radius of rounded corners.

Definition at line 153 of file TrackedObjectBBox.h.

Referenced by JsonValue(), PropertiesJSON(), SetJsonValue(), and TrackedObjectBBox().

◆ BoxVec

std::map<double, BBox> openshot::TrackedObjectBBox::BoxVec

Index the bounding-box by time of each frame.

Definition at line 146 of file TrackedObjectBBox.h.

Referenced by AddBox(), clear(), Contains(), ExactlyContains(), GetBox(), GetLength(), GetMask(), and RemoveBox().

◆ delta_x

Keyframe openshot::TrackedObjectBBox::delta_x

X-direction displacement Keyframe.

Definition at line 148 of file TrackedObjectBBox.h.

Referenced by GetBox(), GetBoxValues(), JsonValue(), PropertiesJSON(), SetJsonValue(), and TrackedObjectBBox().

◆ delta_y

Keyframe openshot::TrackedObjectBBox::delta_y

Y-direction displacement Keyframe.

Definition at line 149 of file TrackedObjectBBox.h.

Referenced by GetBox(), GetBoxValues(), JsonValue(), PropertiesJSON(), SetJsonValue(), and TrackedObjectBBox().

◆ mask_alpha

Keyframe openshot::TrackedObjectBBox::mask_alpha

Object mask overlay opacity.

Definition at line 154 of file TrackedObjectBBox.h.

Referenced by JsonValue(), PropertiesJSON(), SetJsonValue(), and TrackedObjectBBox().

◆ mask_color

Color openshot::TrackedObjectBBox::mask_color

Object mask overlay color.

Definition at line 159 of file TrackedObjectBBox.h.

Referenced by JsonValue(), PropertiesJSON(), SetJsonValue(), and TrackedObjectBBox().

◆ MaskVec

std::map<double, ObjectMaskData> openshot::TrackedObjectBBox::MaskVec

Index optional object masks by time of each frame.

Definition at line 147 of file TrackedObjectBBox.h.

Referenced by AddMask(), clear(), GetMask(), HasMaskData(), and JsonValue().

◆ protobufDataPath

std::string openshot::TrackedObjectBBox::protobufDataPath

Path to the protobuf file that holds the bounding box points across the frames.

Definition at line 161 of file TrackedObjectBBox.h.

Referenced by SetJsonValue().

◆ scale_x

Keyframe openshot::TrackedObjectBBox::scale_x

X-direction scale Keyframe.

Definition at line 150 of file TrackedObjectBBox.h.

Referenced by GetBox(), GetBoxValues(), JsonValue(), PropertiesJSON(), SetJsonValue(), and TrackedObjectBBox().

◆ scale_y

Keyframe openshot::TrackedObjectBBox::scale_y

Y-direction scale Keyframe.

Definition at line 151 of file TrackedObjectBBox.h.

Referenced by GetBox(), GetBoxValues(), JsonValue(), PropertiesJSON(), SetJsonValue(), and TrackedObjectBBox().

◆ stroke

Color openshot::TrackedObjectBBox::stroke

Border line color.

Definition at line 157 of file TrackedObjectBBox.h.

Referenced by JsonValue(), PropertiesJSON(), SetJsonValue(), and TrackedObjectBBox().

◆ stroke_alpha

Keyframe openshot::TrackedObjectBBox::stroke_alpha

◆ stroke_width

Keyframe openshot::TrackedObjectBBox::stroke_width

Thickness of border line.

Definition at line 155 of file TrackedObjectBBox.h.

Referenced by JsonValue(), PropertiesJSON(), ScaledStrokeWidth(), SetJsonValue(), and TrackedObjectBBox().


The documentation for this class was generated from the following files: