Skip to content

Commit

Permalink
Using normalized initial bounding box on CVTracker
Browse files Browse the repository at this point in the history
  • Loading branch information
BrennoCaldato committed Mar 16, 2021
1 parent 8b861f0 commit 1f4d33d
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/CVTracker.cpp
Expand Up @@ -108,6 +108,12 @@ void CVTracker::trackClip(openshot::Clip& video, size_t _start, size_t _end, boo
// Grab OpenCV Mat image
cv::Mat cvimage = f->GetImageCV();

if(frame == start){
// Take the normalized inital bounding box and multiply to the current video shape
bbox = cv::Rect2d(bbox.x*cvimage.cols,bbox.y*cvimage.rows,bbox.width*cvimage.cols,
bbox.height*cvimage.rows);
}

// Pass the first frame to initialize the tracker
if(!trackerInit){

Expand Down Expand Up @@ -284,10 +290,10 @@ void CVTracker::SetJsonValue(const Json::Value root) {
}

if (!root["region"].isNull()){
double x = root["region"]["x"].asDouble();
double y = root["region"]["y"].asDouble();
double w = root["region"]["width"].asDouble();
double h = root["region"]["height"].asDouble();
double x = root["region"]["normalized_x"].asDouble();
double y = root["region"]["normalized_y"].asDouble();
double w = root["region"]["normalized_width"].asDouble();
double h = root["region"]["normalized_height"].asDouble();
cv::Rect2d prev_bbox(x,y,w,h);
bbox = prev_bbox;
}
Expand Down

0 comments on commit 1f4d33d

Please sign in to comment.