You've already forked libopenshot
mirror of
https://github.com/OpenShot/libopenshot.git
synced 2026-03-02 08:53:52 -08:00
Protobuf messages now compile with Cmake
This commit is contained in:
@@ -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 <TransformParam> 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 <size_t,CamTrajectory> trajectoryData; // Save camera trajectory data
|
||||
std::map <size_t,TransformParam> 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);
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
@@ -64,15 +64,15 @@ cv::Ptr<cv::Tracker> 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
|
||||
|
||||
Reference in New Issue
Block a user