Skip to content

Commit

Permalink
Added interval to apply OpenCV effects
Browse files Browse the repository at this point in the history
  • Loading branch information
BrennoCaldato committed Jul 23, 2020
1 parent e69f7b8 commit d87a126
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
1 change: 1 addition & 0 deletions include/CVTracker.h
Expand Up @@ -64,6 +64,7 @@ class CVTracker {
/// Will handle a Thread safely comutication between ClipProcessingJobs and the processing effect classes
ProcessingController *processingController;

bool json_interval;
size_t start;
size_t end;

Expand Down
28 changes: 19 additions & 9 deletions src/CVTracker.cpp
Expand Up @@ -32,7 +32,7 @@

// Constructor
CVTracker::CVTracker(std::string processInfoJson, ProcessingController &processingController)
: processingController(&processingController){
: processingController(&processingController), json_interval(false){
SetJson(processInfoJson);
}

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

start = _start; end = _end;

video.Open();

bool trackerInit = false;

size_t frame;
if(!process_interval || end == 0 || end-start <= 0){
// Get total number of frames in video
start = video.Start() * video.Reader()->info.fps.ToInt();
if(!json_interval){
start = _start; end = _end;

if(!process_interval || end <= 0 || end-start <= 0){
// Get total number of frames in video
start = video.Start() * video.Reader()->info.fps.ToInt();
end = video.End() * video.Reader()->info.fps.ToInt();
}
}
else{
start = start + video.Start() * video.Reader()->info.fps.ToInt();
end = video.End() * video.Reader()->info.fps.ToInt();
}

bool trackerInit = false;

size_t frame;
// Loop through video
for (frame = start; frame <= end; frame++)
{
Expand Down Expand Up @@ -291,4 +297,8 @@ void CVTracker::SetJsonValue(const Json::Value root) {
cv::Rect2d prev_bbox(x,y,w,h);
bbox = prev_bbox;
}
if (!root["first_frame"].isNull()){
start = root["first_frame"].asInt64();
json_interval = true;
}
}

0 comments on commit d87a126

Please sign in to comment.