Skip to content

Commit

Permalink
Applied code review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
BrennoCaldato committed Nov 6, 2020
1 parent 3ef94f4 commit 2d18143
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 20 deletions.
20 changes: 16 additions & 4 deletions tests/CVStabilizer_Tests.cpp
Expand Up @@ -54,8 +54,14 @@ SUITE(CVStabilizer_Tests)
openshot::Clip c1(path.str());
c1.Open();

std::string json_data = R"proto(
{
"protobuf_data_path": "stabilizer.data",
"smoothing-window": 30
} )proto";

// Create stabilizer
CVStabilization stabilizer("{\"protobuf_data_path\": \"stabilizer.data\", \"smoothing-window\": 30}", processingController);
CVStabilization stabilizer(json_data, processingController);

// Stabilize clip for frames 0-21
stabilizer.stabilizeClip(c1, 0, 21, true);
Expand Down Expand Up @@ -92,8 +98,14 @@ SUITE(CVStabilizer_Tests)
openshot::Clip c1(path.str());
c1.Open();

std::string json_data = R"proto(
{
"protobuf_data_path": "stabilizer.data",
"smoothing-window": 30
} )proto";

// Create first stabilizer
CVStabilization stabilizer_1("{\"protobuf_data_path\": \"stabilizer.data\", \"smoothing-window\": 30}", processingController);
CVStabilization stabilizer_1(json_data, processingController);

// Stabilize clip for frames 0-20
stabilizer_1.stabilizeClip(c1, 0, 20+1, true);
Expand All @@ -106,15 +118,15 @@ SUITE(CVStabilizer_Tests)
stabilizer_1.SaveStabilizedData();

// Create second stabilizer
CVStabilization stabilizer_2("{\"protobuf_data_path\": \"stabilizer.data\", \"smoothing-window\": 30}", processingController);
CVStabilization stabilizer_2(json_data, processingController);

// Load stabilized data from first stabilizer protobuf data
stabilizer_2._LoadStabilizedData();

// Get stabilized data
TransformParam tp_2 = stabilizer_2.GetTransformParamData(20);
CamTrajectory ct_2 = stabilizer_2.GetCamTrajectoryTrackedData(20);

// Compare first stabilizer data with second stabilizer data
CHECK_EQUAL((int) (tp_1.dx * 10000), (int) (tp_2.dx *10000));
CHECK_EQUAL((int) (tp_1.dy * 10000), (int) (tp_2.dy * 10000));
Expand Down
25 changes: 9 additions & 16 deletions tests/CVTracker_Tests.cpp
Expand Up @@ -54,17 +54,15 @@ SUITE(CVTracker_Tests)
openshot::Clip c1(path.str());
c1.Open();

std::string proto_data = R"proto(
std::string json_data = R"proto(
{
"protobuf_data_path": "",
"protobuf_data_path": "kcf_tracker.data",
"tracker-type": "KCF",
"region": {"x": 294, "y": 102, "width": 180, "height": 166, "first-frame": 0}
} )proto";

// Create tracker
//CVTracker kcfTracker("{\"protobuf_data_path\": \"\", \"tracker_type\": \"KCF\", \"bbox\": {\"x\": 294, \"y\": 102, \"w\": 180, \"h\": 166}, \"first_frame\": 0}", processingController);
CVTracker kcfTracker(proto_data, processingController);

CVTracker kcfTracker(json_data, processingController);

// Track clip for frames 0-20
kcfTracker.trackClip(c1, 0, 20, true);
Expand Down Expand Up @@ -94,18 +92,16 @@ SUITE(CVTracker_Tests)
openshot::Clip c1(path.str());
c1.Open();

std::string proto_data = R"proto(
std::string json_data = R"proto(
{
"protobuf_data_path": "kcf_tracker.data",
"tracker_type": "KCF",
"bbox": {"x": 294, "y": 102, "w": 180, "h": 166},
"first_frame": 0
"tracker-type": "KCF",
"region": {"x": 294, "y": 102, "width": 180, "height": 166, "first-frame": 0}
} )proto";

// Create first tracker
//CVTracker kcfTracker_1("{\"protobuf_data_path\": \"kcf_tracker.data\", \"tracker_type\": \"KCF\", \"bbox\": {\"x\": 294, \"y\": 102, \"w\": 180, \"h\": 166}, \"first_frame\": 0}", processingController);
CVTracker kcfTracker_1(proto_data, processingController);

// Create first tracker
CVTracker kcfTracker_1(json_data, processingController);

// Track clip for frames 0-20
kcfTracker_1.trackClip(c1, 0, 20, true);
Expand All @@ -125,15 +121,12 @@ SUITE(CVTracker_Tests)
{
"protobuf_data_path": "kcf_tracker.data",
"tracker_type": "",
"bbox": {"x": -1, "y": -1, "w": -1, "h": -1},
"first_frame": 0
"region": {"x": -1, "y": -1, "width": -1, "height": -1, "first-frame": 0}
} )proto";

// Create second tracker
//CVTracker kcfTracker_2("{\"protobuf_data_path\": \"kcf_tracker.data\", \"tracker_type\": \"\", \"bbox\": {\"x\": -1, \"y\": -1, \"w\": -1, \"h\": -1}, \"first_frame\": 0}", processingController);
CVTracker kcfTracker_2(proto_data_1, processingController);


// Load tracked data from first tracker protobuf data
kcfTracker_2._LoadTrackedData();

Expand Down

0 comments on commit 2d18143

Please sign in to comment.