diff --git a/include/CVStabilization.h b/include/CVStabilization.h index 279ffb6f..59cca78a 100644 --- a/include/CVStabilization.h +++ b/include/CVStabilization.h @@ -79,6 +79,8 @@ struct CamTrajectory class CVStabilization { private: + + int smoothingWindow; // In frames. The larger the more stable the video, but less reactive to sudden panning cv::Mat last_T; cv::Mat cur, cur_grey; @@ -86,11 +88,9 @@ class CVStabilization { std::vector prev_to_cur_transform; // Previous to current std::string protobuf_data_path; - bool smoothingWindowSet = false; - uint progress; - /// Will handle a Thread saflly comutication between ClipProcessingJobs and the processing effect classes + /// Will handle a Thread safely comutication between ClipProcessingJobs and the processing effect classes ProcessingController *processingController; // Track current frame features and find the relative transformation @@ -104,16 +104,12 @@ class CVStabilization { public: - int smoothingWindow; // In frames. The larger the more stable the video, but less reactive to sudden panning std::map trajectoryData; // Save camera trajectory data std::map transformationData; // Save transormation data // Set default smoothing window value to compute stabilization CVStabilization(std::string processInfoJson, ProcessingController &processingController); - // Set desirable smoothing window value to compute stabilization - void setSmoothingWindow(int _smoothingWindow); - // Process clip and store necessary stabilization data void stabilizeClip(openshot::Clip& video, size_t start=0, size_t end=0, bool process_interval=false); diff --git a/include/CVTracker.h b/include/CVTracker.h index 45ea41cb..308ee478 100644 --- a/include/CVTracker.h +++ b/include/CVTracker.h @@ -61,7 +61,7 @@ class CVTracker { uint progress; // Pre-processing effect progress - /// Will handle a Thread saflly comutication between ClipProcessingJobs and the processing effect classes + /// Will handle a Thread safely comutication between ClipProcessingJobs and the processing effect classes ProcessingController *processingController; // Initialize the tracker diff --git a/include/ClipProcessingJobs.h b/include/ClipProcessingJobs.h index 1c071857..55d551d4 100644 --- a/include/ClipProcessingJobs.h +++ b/include/ClipProcessingJobs.h @@ -59,7 +59,7 @@ class ClipProcessingJobs{ std::thread t; - /// Will handle a Thread saflly comutication between ClipProcessingJobs and the processing effect classes + /// Will handle a Thread safely comutication between ClipProcessingJobs and the processing effect classes ProcessingController processingController; // Apply object tracking to clip diff --git a/include/effects/Stabilizer.h b/include/effects/Stabilizer.h index 4c1a40a7..36f57417 100644 --- a/include/effects/Stabilizer.h +++ b/include/effects/Stabilizer.h @@ -41,7 +41,7 @@ #include "../Color.h" #include "../Json.h" #include "../KeyFrame.h" -#include "../stabilizedata.pb.h" +#include "stabilizedata.pb.h" using namespace std; using google::protobuf::util::TimeUtil; diff --git a/include/effects/Tracker.h b/include/effects/Tracker.h index 76323b52..5b6112d1 100644 --- a/include/effects/Tracker.h +++ b/include/effects/Tracker.h @@ -42,7 +42,7 @@ #include "../Color.h" #include "../Json.h" #include "../KeyFrame.h" -#include "../trackerdata.pb.h" +#include "trackerdata.pb.h" using namespace std; using google::protobuf::util::TimeUtil; diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 85da89aa..fd83fe13 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -97,6 +97,29 @@ if (OpenCV_FOUND) endif() include_directories(${PROTOBUF_INCLUDE_DIR}) + + set(PROTOBUF_MESSAGES_FOLDER "${CMAKE_CURRENT_SOURCE_DIR}/protobuf_messages") + + FILE(GLOB PROTO_MSGS "${PROTOBUF_MESSAGES_FOLDER}/*.proto") + foreach(PROTO_MSG ${PROTO_MSGS}) + execute_process ( + COMMAND bash -c "${PROTOBUF_PROTOC_EXECUTABLE} -I=${PROTOBUF_MESSAGES_FOLDER} --cpp_out=${PROTOBUF_MESSAGES_FOLDER} ${PROTO_MSG}" + ) + endforeach() + + FILE(GLOB PROTO_CCS "${PROTOBUF_MESSAGES_FOLDER}/*.pb.cc") + foreach(PROTO_CC ${PROTO_CCS}) + execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${PROTO_CC} ${CMAKE_CURRENT_SOURCE_DIR}) + file(REMOVE ${PROTO_CC}) + endforeach() + + FILE(GLOB PROTO_HS "${PROTOBUF_MESSAGES_FOLDER}/*.pb.h") + foreach(PROTO_H ${PROTO_HS}) + execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${PROTO_H} ${CMAKE_CURRENT_SOURCE_DIR}/../include) + file(REMOVE ${PROTO_H}) + endforeach() + + endif() ################# LIBOPENSHOT-AUDIO ################### @@ -195,8 +218,9 @@ set(OPENSHOT_CV_SOURCES # Compiled Protobuf messages set(PROTOBUF_MESSAGES - trackerdata.pb.cc - stabilizedata.pb.cc) + stabilizedata.pb.cc + trackerdata.pb.cc + ) # Video effects set(EFFECTS_SOURCES diff --git a/src/CVStabilization.cpp b/src/CVStabilization.cpp index c267f3b3..a2454587 100644 --- a/src/CVStabilization.cpp +++ b/src/CVStabilization.cpp @@ -32,16 +32,14 @@ // Set default smoothing window value to compute stabilization CVStabilization::CVStabilization(std::string processInfoJson, ProcessingController &processingController) -: smoothingWindow(30), processingController(&processingController){ +: processingController(&processingController){ SetJson(processInfoJson); } // Process clip and store necessary stabilization data void CVStabilization::stabilizeClip(openshot::Clip& video, size_t start, size_t end, bool process_interval){ + size_t frame_number; - - smoothingWindowSet = true; // Certificate that smoothing window value won't change - if(!process_interval || end == 0 || end-start <= 0){ // Get total number of frames in video end = video.Reader()->info.video_length; @@ -351,11 +349,7 @@ void CVStabilization::SetJsonValue(const Json::Value root) { if (!root["protobuf_data_path"].isNull()){ protobuf_data_path = (root["protobuf_data_path"].asString()); } -} - -// Set desirable smoothing window value to compute stabilization -void CVStabilization::setSmoothingWindow(int _smoothingWindow){ - if(!smoothingWindowSet) - smoothingWindow = _smoothingWindow; - smoothingWindowSet = true; + if (!root["smoothing_window"].isNull()){ + smoothingWindow = (root["smoothing_window"].asInt()); + } } \ No newline at end of file diff --git a/src/CVTracker.cpp b/src/CVTracker.cpp index ea9e24de..216932ad 100644 --- a/src/CVTracker.cpp +++ b/src/CVTracker.cpp @@ -64,15 +64,15 @@ cv::Ptr CVTracker::selectTracker(std::string trackerType){ void CVTracker::trackClip(openshot::Clip& video, size_t start, size_t end, bool process_interval){ bool trackerInit = false; - size_t frame; + size_t frame; if(!process_interval || end == 0 || end-start <= 0){ // Get total number of frames in video end = video.Reader()->info.video_length; } // Loop through video - for (frame = start; frame < end; frame++) + for (frame = start; frame <= end; frame++) { // Stop the feature tracker process