Skip to content

Commit

Permalink
Merge branch 'last-frame' into idi-merged
Browse files Browse the repository at this point in the history
* last-frame:
  Document the --process-frames option in the README.
  Add an option to only process part of the input.

Conflicts:
	README.md
	main.cpp
  • Loading branch information
hainesr committed Sep 7, 2015
2 parents 4e5f00c + 9390f77 commit 7306c79
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ For example, vc12 is to be used for Visual Studio 2013.
# Usage
```
usage: ./cmt [--challenge] [--no-scale] [--with-rotation] [--bbox BBOX]
[--skip N] [--skip-msecs N] [--output-file FILE]
[--skip N] [--skip-msecs N] [--process-frames N]
[--output-file FILE]
[--quiet] [--verbose] [inputpath]
```
## Optional arguments
Expand All @@ -64,6 +65,7 @@ usage: ./cmt [--challenge] [--no-scale] [--with-rotation] [--bbox BBOX]
* `--bbox BBOX` Specify initial bounding box. Format: x,y,w,h
* `--skip N` Skip N frames of the video input
* `--skip-msecs N` Skip N milliseconds of the video input
* `--process-frames N` Process N frames of input, then exit
* `--output-file FILE` Save data to a file in CSV format
* `--quiet` Do not show graphical output (Useful in combination with `--output-file`)
* `--verbose`, `-v` Turn on debugging console output
Expand Down Expand Up @@ -99,6 +101,13 @@ It is also possible to specify the initial bounding box on the command line:
cmt --bbox=123,85,60,140 test.avi
```

You can limit processing to a particular part of the input using the `--skip`
and `--process-frames` options. To process 1000 frames starting from the
2000th frame, use:
```
cmt --skip=2000 --process-frames=1000 test.avi
```

You can output data (number of active points, bounding box parameters) to a
file in CSV format:
```
Expand Down
16 changes: 16 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ int main(int argc, char **argv)
int skip_msecs = 0;
int quiet_flag = 0;
int output_flag = 0;
int last_frame = 0;
string input_path;
string output_path;

Expand All @@ -128,6 +129,7 @@ int main(int argc, char **argv)
const int skip_cmd = 1005;
const int skip_msecs_cmd = 1006;
const int output_file_cmd = 1007;
const int process_frames_cmd = 1008;

struct option longopts[] =
{
Expand All @@ -145,6 +147,7 @@ int main(int argc, char **argv)
{"output-file", required_argument, 0, output_file_cmd},
{"skip", required_argument, 0, skip_cmd},
{"skip-msecs", required_argument, 0, skip_msecs_cmd},
{"process-frames", required_argument, 0, process_frames_cmd},
{0, 0, 0, 0}
};

Expand Down Expand Up @@ -201,6 +204,15 @@ int main(int argc, char **argv)
}
}
break;
case process_frames_cmd:
{
int ret = sscanf(optarg, "%d", &last_frame);
if (ret != 1)
{
last_frame = 0;
}
}
break;
case no_scale_cmd:
cmt.consensus.estimate_scale = false;
break;
Expand Down Expand Up @@ -362,6 +374,7 @@ int main(int argc, char **argv)
skip_frames = (int) cap.get(CV_CAP_PROP_POS_FRAMES);
}

last_frame += skip_frames; // Adjust the last frame number accordingly.
show_preview = false;
}

Expand Down Expand Up @@ -479,6 +492,9 @@ int main(int argc, char **argv)
char key = display(im, cmt);
if(key == 'q') break;
}

// Quit if we've reached the last frame that we are processing.
if (frame == last_frame) break;
}

//Close output file.
Expand Down

0 comments on commit 7306c79

Please sign in to comment.