MCPcopy Create free account
hub / github.com/OpenShot/libopenshot / main

Function main

examples/Example_opencv.cpp:74–175  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

72}
73
74int main(int argc, char* argv[]) {
75
76 // Set pre-processing effects
77 bool TRACK_DATA = true;
78 bool SMOOTH_VIDEO = false;
79 bool OBJECT_DETECTION_DATA = false;
80
81 // Get media path
82 std::stringstream path;
83 path << TEST_MEDIA_PATH << ((OBJECT_DETECTION_DATA) ? "run.mp4" : "test.avi");
84 // run.mp4 --> Used for object detector
85 // test.avi --> Used for tracker and stabilizer
86
87 // Thread controller just for the pre-processing constructors, it won't be used
88 ProcessingController processingController;
89
90 // Open clip
91 openshot::Clip r9(path.str());
92 r9.Open();
93
94 // Apply tracking effect on the clip
95 if(TRACK_DATA){
96
97 // Take the bounding box coordinates
98 cv::Mat roi = r9.GetFrame(0)->GetImageCV();
99 cv::Rect2d r = cv::selectROI(roi);
100 cv::destroyAllWindows();
101
102 // Create a tracker object by passing a JSON string and a thread controller, this last one won't be used
103 // JSON info: path to save the tracked data, type of tracker and bbox coordinates
104 CVTracker tracker(trackerJson(r, false), processingController);
105
106 // Start the tracking
107 tracker.trackClip(r9, 0, 0, true);
108 // Save the tracked data
109 tracker.SaveTrackedData();
110
111 // Create a tracker effect
112 EffectBase* e = EffectInfo().CreateEffect("Tracker");
113
114 // Pass a JSON string with the saved tracked data
115 // The effect will read and save the tracking in a map::<frame,data_struct>
116 e->SetJson(trackerJson(r, true));
117 // Add the effect to the clip
118 r9.AddEffect(e);
119 }
120
121 // Apply stabilizer effect on the clip
122 if(SMOOTH_VIDEO){
123
124 // Create a stabilizer object by passing a JSON string and a thread controller, this last one won't be used
125 // JSON info: path to save the stabilized data and smoothing window value
126 CVStabilization stabilizer(stabilizerJson(false), processingController);
127
128 // Start the stabilization
129 stabilizer.stabilizeClip(r9, 0, 100, true);
130 // Save the stabilization data
131 stabilizer.SaveStabilizedData();

Callers

nothing calls this directly

Calls 15

trackerJsonFunction · 0.85
stabilizerJsonFunction · 0.85
objectDetectionJsonFunction · 0.85
displayClipFunction · 0.85
GetImageCVMethod · 0.80
SaveTrackedDataMethod · 0.80
CreateEffectMethod · 0.80
SaveStabilizedDataMethod · 0.80
SaveObjDetectedDataMethod · 0.80
EffectInfoClass · 0.50
OpenMethod · 0.45
GetFrameMethod · 0.45

Tested by

no test coverage detected