@@ -34,9 +34,9 @@ using google::protobuf::util::TimeUtil;
34
34
// / Blank constructor, useful when using Json to load the effect properties
35
35
Tracker::Tracker (std::string clipTrackerDataPath)
36
36
{
37
- // Init effect properties
37
+ // Init effect properties
38
38
init_effect_details ();
39
- // Instantiate a TrackedObjectBBox object and point to it
39
+ // Instantiate a TrackedObjectBBox object and point to it
40
40
TrackedObjectBBox trackedDataObject;
41
41
trackedData = std::make_shared<TrackedObjectBBox>(trackedDataObject);
42
42
// Tries to load the tracked object's data from protobuf file
@@ -85,16 +85,16 @@ void Tracker::init_effect_details()
85
85
// modified openshot::Frame object
86
86
std::shared_ptr<Frame> Tracker::GetFrame (std::shared_ptr<Frame> frame, int64_t frame_number)
87
87
{
88
- // Get the frame's image
88
+ // Get the frame's image
89
89
cv::Mat frame_image = frame->GetImageCV ();
90
90
91
91
// Initialize the Qt rectangle that will hold the positions of the bounding-box
92
92
QRectF boxRect;
93
93
// Initialize the image of the TrackedObject child clip
94
94
std::shared_ptr<QImage> childClipImage = nullptr ;
95
95
96
- // Check if frame isn't NULL
97
- if (!frame_image.empty () &&
96
+ // Check if frame isn't NULL
97
+ if (!frame_image.empty () &&
98
98
trackedData->Contains (frame_number) &&
99
99
trackedData->visible .GetValue (frame_number) == 1 )
100
100
{
@@ -105,8 +105,8 @@ std::shared_ptr<Frame> Tracker::GetFrame(std::shared_ptr<Frame> frame, int64_t f
105
105
// Get the bounding-box of given frame
106
106
BBox fd = trackedData->GetBox (frame_number);
107
107
108
- // Check if track data exists for the requested frame
109
- if (trackedData->draw_box .GetValue (frame_number) == 1 )
108
+ // Check if track data exists for the requested frame
109
+ if (trackedData->draw_box .GetValue (frame_number) == 1 )
110
110
{
111
111
std::vector<int > stroke_rgba = trackedData->stroke .GetColorRGBA (frame_number);
112
112
int stroke_width = trackedData->stroke_width .GetValue (frame_number);
@@ -144,10 +144,10 @@ std::shared_ptr<Frame> Tracker::GetFrame(std::shared_ptr<Frame> frame, int64_t f
144
144
}
145
145
}
146
146
147
- }
147
+ }
148
148
149
149
// Set image with drawn box to frame
150
- // If the input image is NULL or doesn't have tracking data, it's returned as it came
150
+ // If the input image is NULL or doesn't have tracking data, it's returned as it came
151
151
frame->SetImageCV (frame_image);
152
152
153
153
// Set the bounding-box image with the Tracked Object's child clip image
@@ -211,23 +211,23 @@ void Tracker::DrawRectangleRGBA(cv::Mat &frame_image, cv::RotatedRect box, std::
211
211
// Get the indexes and IDs of all visible objects in the given frame
212
212
std::string Tracker::GetVisibleObjects (int64_t frame_number) const {
213
213
214
- // Initialize the JSON objects
215
- Json::Value root;
216
- root[" visible_objects_index" ] = Json::Value (Json::arrayValue);
217
- root[" visible_objects_id" ] = Json::Value (Json::arrayValue);
218
-
219
- // Iterate through the tracked objects
220
- for (const auto & trackedObject : trackedObjects){
221
- // Get the tracked object JSON properties for this frame
222
- Json::Value trackedObjectJSON = trackedObject.second ->PropertiesJSON (frame_number);
223
- if (trackedObjectJSON[" visible" ][" value" ].asBool ()){
224
- // Save the object's index and ID if it's visible in this frame
225
- root[" visible_objects_index" ].append (trackedObject.first );
226
- root[" visible_objects_id" ].append (trackedObject.second ->Id ());
227
- }
228
- }
229
-
230
- return root.toStyledString ();
214
+ // Initialize the JSON objects
215
+ Json::Value root;
216
+ root[" visible_objects_index" ] = Json::Value (Json::arrayValue);
217
+ root[" visible_objects_id" ] = Json::Value (Json::arrayValue);
218
+
219
+ // Iterate through the tracked objects
220
+ for (const auto & trackedObject : trackedObjects){
221
+ // Get the tracked object JSON properties for this frame
222
+ Json::Value trackedObjectJSON = trackedObject.second ->PropertiesJSON (frame_number);
223
+ if (trackedObjectJSON[" visible" ][" value" ].asBool ()){
224
+ // Save the object's index and ID if it's visible in this frame
225
+ root[" visible_objects_index" ].append (trackedObject.first );
226
+ root[" visible_objects_id" ].append (trackedObject.second ->Id ());
227
+ }
228
+ }
229
+
230
+ return root.toStyledString ();
231
231
}
232
232
233
233
// Generate JSON string of this object
@@ -252,12 +252,12 @@ Json::Value Tracker::JsonValue() const {
252
252
253
253
// Add trackedObjects IDs to JSON
254
254
Json::Value objects;
255
- for (auto const & trackedObject : trackedObjects){
256
- Json::Value trackedObjectJSON = trackedObject.second ->JsonValue ();
257
- // add object json
258
- objects[trackedObject.second ->Id ()] = trackedObjectJSON;
259
- }
260
- root[" objects" ] = objects;
255
+ for (auto const & trackedObject : trackedObjects){
256
+ Json::Value trackedObjectJSON = trackedObject.second ->JsonValue ();
257
+ // add object json
258
+ objects[trackedObject.second ->Id ()] = trackedObjectJSON;
259
+ }
260
+ root[" objects" ] = objects;
261
261
262
262
// return JsonValue
263
263
return root;
@@ -313,23 +313,23 @@ void Tracker::SetJsonValue(const Json::Value root) {
313
313
}
314
314
}
315
315
316
- if (!root[" objects" ].isNull ()){
317
- for (auto const & trackedObject : trackedObjects){
318
- std::string obj_id = std::to_string (trackedObject.first );
319
- if (!root[" objects" ][obj_id].isNull ()){
320
- trackedObject.second ->SetJsonValue (root[" objects" ][obj_id]);
321
- }
322
- }
316
+ if (!root[" objects" ].isNull ()){
317
+ for (auto const & trackedObject : trackedObjects){
318
+ std::string obj_id = std::to_string (trackedObject.first );
319
+ if (!root[" objects" ][obj_id].isNull ()){
320
+ trackedObject.second ->SetJsonValue (root[" objects" ][obj_id]);
321
+ }
322
+ }
323
323
}
324
324
325
- // Set the tracked object's ids
326
- if (!root[" objects_id" ].isNull ()){
327
- for (auto const & trackedObject : trackedObjects){
328
- Json::Value trackedObjectJSON;
329
- trackedObjectJSON[" box_id" ] = root[" objects_id" ][trackedObject.first ].asString ();
330
- trackedObject.second ->SetJsonValue (trackedObjectJSON);
331
- }
332
- }
325
+ // Set the tracked object's ids
326
+ if (!root[" objects_id" ].isNull ()){
327
+ for (auto const & trackedObject : trackedObjects){
328
+ Json::Value trackedObjectJSON;
329
+ trackedObjectJSON[" box_id" ] = root[" objects_id" ][trackedObject.first ].asString ();
330
+ trackedObject.second ->SetJsonValue (trackedObjectJSON);
331
+ }
332
+ }
333
333
334
334
return ;
335
335
}
@@ -345,8 +345,8 @@ std::string Tracker::PropertiesJSON(int64_t requested_frame) const {
345
345
for (auto const & trackedObject : trackedObjects){
346
346
Json::Value trackedObjectJSON = trackedObject.second ->PropertiesJSON (requested_frame);
347
347
// add object json
348
- objects[trackedObject.second ->Id ()] = trackedObjectJSON;
349
- }
348
+ objects[trackedObject.second ->Id ()] = trackedObjectJSON;
349
+ }
350
350
root[" objects" ] = objects;
351
351
352
352
// Append effect's properties
0 commit comments