diff --git a/src/EffectBase.h b/src/EffectBase.h index 16c1ba95..dc78a7c9 100644 --- a/src/EffectBase.h +++ b/src/EffectBase.h @@ -31,14 +31,15 @@ #ifndef OPENSHOT_EFFECT_BASE_H #define OPENSHOT_EFFECT_BASE_H -#include -#include -#include #include "ClipBase.h" + #include "Json.h" -#include "Frame.h" #include "TrackedObjectBase.h" +#include +#include +#include + namespace openshot { /** diff --git a/src/TrackedObjectBBox.cpp b/src/TrackedObjectBBox.cpp index cc8be187..88e5a0a6 100644 --- a/src/TrackedObjectBBox.cpp +++ b/src/TrackedObjectBBox.cpp @@ -30,15 +30,13 @@ */ #include "TrackedObjectBBox.h" + #include "Clip.h" -#include -#include -#include -#include -using namespace std; -using namespace openshot; +#include "protobuf_messages/trackerdata.pb.h" +#include +using google::protobuf::util::TimeUtil; // Default Constructor that sets the bounding-box displacement as 0 and the scales as 1 for the first frame TrackedObjectBBox::TrackedObjectBBox() : delta_x(0.0), delta_y(0.0), scale_x(1.0), scale_y(1.0), rotation(0.0), @@ -247,22 +245,24 @@ void TrackedObjectBBox::ScalePoints(double time_scale){ this->TimeScale = time_scale; } -// Load the bounding-boxes information from the protobuf file +// Load the bounding-boxes information from the protobuf file bool TrackedObjectBBox::LoadBoxData(std::string inputFilePath) { + using std::ios; + // Variable to hold the loaded data pb_tracker::Tracker bboxMessage; // Read the existing tracker message. - fstream input(inputFilePath, ios::in | ios::binary); + std::fstream input(inputFilePath, ios::in | ios::binary); // Check if it was able to read the protobuf data if (!bboxMessage.ParseFromIstream(&input)) { - cerr << "Failed to parse protobuf message." << endl; + std::cerr << "Failed to parse protobuf message." << std::endl; return false; } - + this->clear(); // Iterate over all frames of the saved message @@ -294,7 +294,8 @@ bool TrackedObjectBBox::LoadBoxData(std::string inputFilePath) // Show the time stamp from the last update in tracker data file if (bboxMessage.has_last_updated()) { - cout << " Loaded Data. Saved Time Stamp: " << TimeUtil::ToString(bboxMessage.last_updated()) << endl; + std::cout << " Loaded Data. Saved Time Stamp: " + << TimeUtil::ToString(bboxMessage.last_updated()) << std::endl; } // Delete all global objects allocated by libprotobuf. diff --git a/src/TrackedObjectBBox.h b/src/TrackedObjectBBox.h index ae951e22..d7a7b7ce 100644 --- a/src/TrackedObjectBBox.h +++ b/src/TrackedObjectBBox.h @@ -32,33 +32,22 @@ #ifndef OPENSHOT_TRACKEDOBJECTBBOX_H #define OPENSHOT_TRACKEDOBJECTBBOX_H -#include -#include -#include -#include -#include +#include "TrackedObjectBase.h" + +#include "Color.h" #include "Exceptions.h" #include "Fraction.h" -#include "Coordinate.h" -#include "Point.h" #include "Json.h" #include "KeyFrame.h" -#include "TrackedObjectBase.h" -#include "Color.h" -#include "protobuf_messages/trackerdata.pb.h" -#include - - -using google::protobuf::util::TimeUtil; namespace openshot { /** * @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. @@ -89,7 +78,7 @@ namespace openshot angle = _angle; } - + /// Generate JSON string of this object std::string Json() const { @@ -141,17 +130,17 @@ namespace openshot height = root["height"].asDouble(); if (!root["angle"].isNull()) angle = root["angle"].asDouble(); - } + } }; /** * @brief 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, * height and rotation 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. @@ -160,7 +149,7 @@ namespace openshot { private: Fraction BaseFps; - double TimeScale; + double TimeScale; public: std::map BoxVec; ///< Index the bounding-box by time of each frame @@ -184,7 +173,7 @@ namespace openshot /// Add a BBox to the BoxVec map void AddBox(int64_t _frame_num, float _cx, float _cy, float _width, float _height, float _angle) override; - + /// Update object's BaseFps void SetBaseFPS(Fraction fps); @@ -213,7 +202,7 @@ namespace openshot return const_cast(this)->GetBox(frame_number); } - /// Load the bounding-boxes information from the protobuf file + /// Load the bounding-boxes information from the protobuf file bool LoadBoxData(std::string inputFilePath); /// Get the time of the given frame @@ -223,7 +212,7 @@ namespace openshot BBox InterpolateBoxes(double t1, double t2, BBox left, BBox right, double target); /// Clear the BoxVec map - void clear(); + void clear(); /// Get and Set JSON methods std::string Json() const override; ///< Generate JSON string of this object @@ -242,8 +231,8 @@ namespace openshot std::map GetBoxValues(int64_t frame_number) const override; /// Return a map that contains the properties of this object's parent clip std::map GetParentClipProperties(int64_t frame_number) const override; - + }; } // namespace openshot -#endif \ No newline at end of file +#endif diff --git a/src/TrackedObjectBase.cpp b/src/TrackedObjectBase.cpp index f065b10a..e3d6ed24 100644 --- a/src/TrackedObjectBase.cpp +++ b/src/TrackedObjectBase.cpp @@ -30,9 +30,8 @@ */ #include "TrackedObjectBase.h" -#include -#include -#include + +#include "Json.h" namespace openshot { diff --git a/src/TrackedObjectBase.h b/src/TrackedObjectBase.h index 86278e63..0ab88130 100644 --- a/src/TrackedObjectBase.h +++ b/src/TrackedObjectBase.h @@ -32,22 +32,17 @@ #ifndef OPENSHOT_TRACKEDOBJECTBASE_H #define OPENSHOT_TRACKEDOBJECTBASE_H -#include -#include -#include -#include #include #include -#include "Exceptions.h" -#include "Fraction.h" -#include "Coordinate.h" -#include "KeyFrame.h" -#include "Point.h" -#include "Json.h" -#include "ClipBase.h" +#include "KeyFrame.h" +#include "Json.h" namespace openshot { + + // Forward decls + class ClipBase; + /** * @brief This abstract class is the base class of all Tracked Objects. * @@ -108,8 +103,6 @@ namespace openshot { virtual Json::Value PropertiesJSON(int64_t requested_frame) const = 0; /// Generate JSON choice for a property (dropdown properties) Json::Value add_property_choice_json(std::string name, int value, int selected_value) const; - - }; } // Namespace openshot