Skip to content

Commit

Permalink
Tracker Effect minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
BrennoCaldato committed Jul 22, 2020
1 parent 3b2acab commit 6d6c156
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
5 changes: 4 additions & 1 deletion include/CVTracker.h
Expand Up @@ -64,6 +64,9 @@ class CVTracker {
/// Will handle a Thread safely comutication between ClipProcessingJobs and the processing effect classes
ProcessingController *processingController;

size_t start;
size_t end;

// Initialize the tracker
bool initTracker(cv::Mat &frame, size_t frameId);

Expand All @@ -80,7 +83,7 @@ class CVTracker {

// Track object in the hole clip or in a given interval
// If start, end and process_interval are passed as argument, clip will be processed in [start,end)
void trackClip(openshot::Clip& video, size_t start=0, size_t end=0, bool process_interval=false);
void trackClip(openshot::Clip& video, size_t _start=0, size_t _end=0, bool process_interval=false);

// Get tracked data for a given frame
FrameData GetTrackedData(size_t frameId);
Expand Down
2 changes: 1 addition & 1 deletion include/effects/Tracker.h
Expand Up @@ -50,7 +50,7 @@ using google::protobuf::util::TimeUtil;

// Tracking info struct
struct EffectFrameData{
int frame_id = -1;
size_t frame_id = -1;
float rotation = 0;
int x1 = -1;
int y1 = -1;
Expand Down
14 changes: 9 additions & 5 deletions src/CVTracker.cpp
Expand Up @@ -61,18 +61,23 @@ 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){
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
end = video.Reader()->info.video_length;
start = video.Start() * video.Reader()->info.fps.ToInt();
end = video.End() * video.Reader()->info.fps.ToInt();
}

// Loop through video
for (frame = start; frame <= end; frame++)
for (frame = start; frame < end; frame++)
{

// Stop the feature tracker process
Expand Down Expand Up @@ -264,8 +269,7 @@ void CVTracker::SetJson(const std::string value) {
catch (const std::exception& e)
{
// Error parsing JSON (or missing keys)
// throw InvalidJSON("JSON is invalid (missing keys or invalid data types)");
std::cout<<"JSON is invalid (missing keys or invalid data types)"<<std::endl;
throw openshot::InvalidJSON("JSON is invalid (missing keys or invalid data types)");
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/effects/Tracker.cpp
Expand Up @@ -109,11 +109,11 @@ bool Tracker::LoadTrackedData(std::string inputFilePath){
trackedDataById.clear();

// Iterate over all frames of the saved message
for (int i = 0; i < trackerMessage.frame_size(); i++) {
for (size_t i = 0; i < trackerMessage.frame_size(); i++) {
const libopenshottracker::Frame& pbFrameData = trackerMessage.frame(i);

// Load frame and rotation data
int id = pbFrameData.id();
size_t id = pbFrameData.id();
float rotation = pbFrameData.rotation();

// Load bounding box data
Expand Down

0 comments on commit 6d6c156

Please sign in to comment.