Skip to content
TheMrtN edited this page Jun 21, 2011 · 7 revisions

This page gets you started with OpenTLD and explains some features.

First install the software using the Installation page and solve any problems using the FAQ.

Use your (web)cam for tracking

You can use your own camera for tracking.

  1. In MATLAB, run imaqhwinfo to see what adaptors are installed (for example: 'winvideo' or 'macvideo').
  2. Use a=imaqhwinfo('intalled_adaptor_name'); a.DeviceInfo to figure out the supported formats.
  3. Open initcamera.m and change the line source.vid = videoinput('winvideo', 1,'YUY2_320x240'); with your adaptor name and format.
  4. Open run_TLD.m and set camera to 1 like this: opt.source = struct('camera',0, ...
  5. Run run_TLD.m to start tracking. It will pop up a figure with an image from your camera in which you can draw the bounding box.

Load your own movie

You've seen the motor bike example running, but how do you load your own movie?

  1. Install ffmpeg or another tool that can convert a video into a frame image sequence.
  2. Make a new folder for your own movie (we take /path/to/input/ as an example path).
  3. Convert the movie. For ffmpeg, use: ffmpeg -i movie.avi -sameq /path/to/input/%5d.png or dos('ffmpeg -i movie.avi -sameq /path/to/input/%5d.png') from within Matlab on Windows. Note: consider using .jpg which might save disk space and time (during tracking).
  4. (optional) Define the bounding box of the first frame by creating /path/to/input/init.txt and filling it with the following numbers: X_topleft,Y_topleft,X_bottomright,Y_bottomright. For example: 101,200,320,299 You can determine those numbers by opening the first frame in a picture editor and use the mouse XY position. If you skip this step, OpenTLD will ask you to draw the bounding box yourself, but it won't create an init.txt, so you'll have to draw it each time you use this video.
  5. Tell TLD where your movie is found by opening run_TLD.m and changing input to the folder like this: opt.source = struct('camera',0,'input','/path/to/input/', ...
  6. Run run_TLD.m to start tracking.

It is also possible to load videos without converting them first. See this issue.

Make a movie of the tracking process

Maybe you would like to make a movie of the tracking process to show it to others. You can use screen capture software like Camtasia (Windows), but here's an alternative:

  1. Open other/run_TLD_demo.m and set the save variable to 1 like this: opt.plot = struct('pex',1,'nex',1,'save',1, ...
  2. Start the tracking process by running other/run_TLD_demo.m. (Troubleshooting: if you receive the error ??? Undefined function or method 'tldDemo' for input arguments of type 'struct'., make sure that your current MATLAB folder is the OpenTLD root, so jump out of the 'other' folder. Then while running, MATLAB could popup a message File .../run_TLD_demo.m is not found in the current folder or in the MATLAB path. Choose Add to Path to solve this.)
  3. Now each frame is saved to the to the _snapshots/ folder. Use ffmpeg (or another tool) to reconstruct it to a movie: ffmpeg -i _snapshots/%05d.png -sameq movie.mp4 If you wish to do this from Matlab on Windows you can navigate to the _snapshots/ directory, and enter: dos '(ffmpeg -i _snapshots/%05d.png -sameq movie.mp4') You may need to tell Windows where to find ffmpeg which you can do like this: dos('<system_path_to_ffmpeg> -i _snapshots/%05d.png -sameq movie.mp4')

Note that enabling saving will lower your frame rate (fps).

Clone this wiki locally