Skip to content

Commit d87a126

Browse files
committed
Added interval to apply OpenCV effects
1 parent e69f7b8 commit d87a126

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

include/CVTracker.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ class CVTracker {
6464
/// Will handle a Thread safely comutication between ClipProcessingJobs and the processing effect classes
6565
ProcessingController *processingController;
6666

67+
bool json_interval;
6768
size_t start;
6869
size_t end;
6970

src/CVTracker.cpp

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
// Constructor
3434
CVTracker::CVTracker(std::string processInfoJson, ProcessingController &processingController)
35-
: processingController(&processingController){
35+
: processingController(&processingController), json_interval(false){
3636
SetJson(processInfoJson);
3737
}
3838

@@ -63,19 +63,25 @@ cv::Ptr<cv::Tracker> CVTracker::selectTracker(std::string trackerType){
6363
// Track object in the hole clip or in a given interval
6464
void CVTracker::trackClip(openshot::Clip& video, size_t _start, size_t _end, bool process_interval){
6565

66-
start = _start; end = _end;
67-
6866
video.Open();
69-
70-
bool trackerInit = false;
7167

72-
size_t frame;
73-
if(!process_interval || end == 0 || end-start <= 0){
74-
// Get total number of frames in video
75-
start = video.Start() * video.Reader()->info.fps.ToInt();
68+
if(!json_interval){
69+
start = _start; end = _end;
70+
71+
if(!process_interval || end <= 0 || end-start <= 0){
72+
// Get total number of frames in video
73+
start = video.Start() * video.Reader()->info.fps.ToInt();
74+
end = video.End() * video.Reader()->info.fps.ToInt();
75+
}
76+
}
77+
else{
78+
start = start + video.Start() * video.Reader()->info.fps.ToInt();
7679
end = video.End() * video.Reader()->info.fps.ToInt();
7780
}
7881

82+
bool trackerInit = false;
83+
84+
size_t frame;
7985
// Loop through video
8086
for (frame = start; frame <= end; frame++)
8187
{
@@ -291,4 +297,8 @@ void CVTracker::SetJsonValue(const Json::Value root) {
291297
cv::Rect2d prev_bbox(x,y,w,h);
292298
bbox = prev_bbox;
293299
}
300+
if (!root["first_frame"].isNull()){
301+
start = root["first_frame"].asInt64();
302+
json_interval = true;
303+
}
294304
}

0 commit comments

Comments
 (0)