diff --git a/include/effects/Stabilizer.h b/include/effects/Stabilizer.h
index 36f57417..ed29c1c4 100644
--- a/include/effects/Stabilizer.h
+++ b/include/effects/Stabilizer.h
@@ -90,6 +90,7 @@ namespace openshot
/// Init effect settings
void init_effect_details();
std::string protobuf_data_path;
+ Keyframe zoom;
public:
std::string teste;
diff --git a/src/CVStabilization.cpp b/src/CVStabilization.cpp
index aa98f629..0283b1c3 100644
--- a/src/CVStabilization.cpp
+++ b/src/CVStabilization.cpp
@@ -51,7 +51,7 @@ void CVStabilization::stabilizeClip(openshot::Clip& video, size_t _start, size_t
}
// Extract and track opticalflow features for each frame
- for (frame_number = start; frame_number < end; frame_number++)
+ for (frame_number = start; frame_number <= end; frame_number++)
{
// Stop the feature tracker process
if(processingController->ShouldStop()){
@@ -67,7 +67,7 @@ void CVStabilization::stabilizeClip(openshot::Clip& video, size_t _start, size_t
TrackFrameFeatures(cvimage, frame_number);
// Update progress
- processingController->SetProgress(uint(100*frame_number/end));
+ processingController->SetProgress(uint(100*(frame_number-start)/(end-start)));
}
// Calculate trajectory data
diff --git a/src/CVTracker.cpp b/src/CVTracker.cpp
index fa91a98f..aabc79b4 100644
--- a/src/CVTracker.cpp
+++ b/src/CVTracker.cpp
@@ -77,7 +77,7 @@ void CVTracker::trackClip(openshot::Clip& video, size_t _start, size_t _end, boo
}
// Loop through video
- for (frame = start; frame < end; frame++)
+ for (frame = start; frame <= end; frame++)
{
// Stop the feature tracker process
@@ -110,7 +110,7 @@ void CVTracker::trackClip(openshot::Clip& video, size_t _start, size_t _end, boo
}
// Update progress
- processingController->SetProgress(uint(100*frame_number/end));
+ processingController->SetProgress(uint(100*(frame_number-start)/(end-start)));
}
}
diff --git a/src/effects/Stabilizer.cpp b/src/effects/Stabilizer.cpp
index b04ba6e2..9704fd1c 100644
--- a/src/effects/Stabilizer.cpp
+++ b/src/effects/Stabilizer.cpp
@@ -63,7 +63,7 @@ void Stabilizer::init_effect_details()
info.has_audio = false;
info.has_video = true;
protobuf_data_path = "";
-
+ zoom = 1.0;
}
// This method is required for all derived classes of EffectBase, and returns a
@@ -79,6 +79,8 @@ std::shared_ptr Stabilizer::GetFrame(std::shared_ptr frame, int64_
// Check if track data exists for the requested frame
if(transformationData.find(frame_number) != transformationData.end()){
+
+ float zoom_value = zoom.GetValue(frame_number);
// Create empty rotation matrix
cv::Mat T(2,3,CV_64F);
@@ -97,7 +99,7 @@ std::shared_ptr Stabilizer::GetFrame(std::shared_ptr frame, int64_
cv::warpAffine(frame_image, frame_stabilized, T, frame_image.size());
// Scale up the image to remove black borders
- cv::Mat T_scale = cv::getRotationMatrix2D(cv::Point2f(frame_stabilized.cols/2, frame_stabilized.rows/2), 0, 1.04);
+ cv::Mat T_scale = cv::getRotationMatrix2D(cv::Point2f(frame_stabilized.cols/2, frame_stabilized.rows/2), 0, zoom_value);
cv::warpAffine(frame_stabilized, frame_stabilized, T_scale, frame_stabilized.size());
frame_image = frame_stabilized;
}
@@ -178,6 +180,7 @@ Json::Value Stabilizer::JsonValue() const {
Json::Value root = EffectBase::JsonValue(); // get parent properties
root["type"] = info.class_name;
root["protobuf_data_path"] = protobuf_data_path;
+ root["zoom"] = zoom.JsonValue();
// return JsonValue
return root;
@@ -215,6 +218,8 @@ void Stabilizer::SetJsonValue(const Json::Value root) {
protobuf_data_path = "";
}
}
+ if(!root["zoom"].isNull())
+ zoom.SetJsonValue(root["zoom"]);
}
// Get all properties for a specific frame
@@ -229,6 +234,8 @@ std::string Stabilizer::PropertiesJSON(int64_t requested_frame) const {
root["end"] = add_property_json("End", End(), "float", "", NULL, 0, 1000 * 60 * 30, false, requested_frame);
root["duration"] = add_property_json("Duration", Duration(), "float", "", NULL, 0, 1000 * 60 * 30, true, requested_frame);
+ root["zoom"] = add_property_json("Zoom", zoom.GetValue(requested_frame), "float", "", &zoom, 0.0, 2.0, false, requested_frame);
+
// Return formatted string
return root.toStyledString();
}
diff --git a/src/examples/Example_opencv.cpp b/src/examples/Example_opencv.cpp
index 5865c4ce..2ed03408 100644
--- a/src/examples/Example_opencv.cpp
+++ b/src/examples/Example_opencv.cpp
@@ -71,6 +71,16 @@ void displayClip(openshot::Clip &r9){
cv::destroyAllWindows();
}
+
+/*
+||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+
+The following methods are just for getting JSON info to the pre-processing effects
+
+||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+*/
+
+
// Return JSON string for the tracker effect
string trackerJson(cv::Rect2d r, bool onlyProtoPath){
// Set the tracker
@@ -108,6 +118,16 @@ string stabilizerJson(bool onlyProtoPath){
return "{" + protobuf_data_path + ", " + smoothing_window.str() + "}";
}
+string objectDetectionJson(bool onlyProtoPath){
+
+ // Construct all the composition of the JSON string
+ string protobuf_data_path = "\"protobuf_data_path\": \"example_object_detection.data\"";
+
+ // Return only the the protobuf path in JSON format
+ if(onlyProtoPath)
+ return "{" + protobuf_data_path + "}";
+}
+
int main(int argc, char* argv[]) {
// Set pre-processing effects
diff --git a/tests/CVStabilizer_Tests.cpp b/tests/CVStabilizer_Tests.cpp
index b5445afd..016c25b7 100644
--- a/tests/CVStabilizer_Tests.cpp
+++ b/tests/CVStabilizer_Tests.cpp
@@ -55,10 +55,10 @@ SUITE(CVStabilizer_Tests)
c1.Open();
// Create stabilizer
- CVStabilization stabilizer("{\"protobuf_data_path\": \"stabilizer.data\"}", processingController);
+ CVStabilization stabilizer("{\"protobuf_data_path\": \"stabilizer.data\", \"smoothing_window\": 30}", processingController);
- // Stabilize clip for frames 0-20
- stabilizer.stabilizeClip(c1, 0, 20+1, true);
+ // Stabilize clip for frames 0-21
+ stabilizer.stabilizeClip(c1, 0, 21, true);
// Get stabilized data
TransformParam tp = stabilizer.GetTransformParamData(20);
@@ -93,7 +93,7 @@ SUITE(CVStabilizer_Tests)
c1.Open();
// Create first stabilizer
- CVStabilization stabilizer_1("{\"protobuf_data_path\": \"stabilizer.data\"}", processingController);
+ CVStabilization stabilizer_1("{\"protobuf_data_path\": \"stabilizer.data\", \"smoothing_window\": 30}", processingController);
// Stabilize clip for frames 0-20
stabilizer_1.stabilizeClip(c1, 0, 20+1, true);
@@ -106,7 +106,7 @@ SUITE(CVStabilizer_Tests)
stabilizer_1.SaveStabilizedData();
// Create second stabilizer
- CVStabilization stabilizer_2("{\"protobuf_data_path\": \"stabilizer.data\"}", processingController);
+ CVStabilization stabilizer_2("{\"protobuf_data_path\": \"stabilizer.data\", \"smoothing_window\": 30}", processingController);
// Load stabilized data from first stabilizer protobuf data
stabilizer_2.LoadStabilizedData();