# QuickTime Extension

## What does the QuickTime Extension do?

The QuickTime Extension allows you to interact with and create images for importing from webcams and movie files.

## Installing the QuickTime Extension

### Windows

First, make sure you have QuickTime installed if you don't you can download it here:

http://www.apple.com/quicktime/download/

A few files from your QuickTime installation need to be moved into the extension directory in order for the video extension to work.

- Copy `C:\Program Files\QuickTime\QTSystem\QTJava.zip` into the extension directory and rename it `QTJava.jar`.
- Make a directory called `lib` in the QTJ extension directory, then create a directory called `Windows` inside `lib`.
- Copy `C:\Program Files\QuickTime\QTSystem\QTJavaNative.dll` and `C:\Program Files\QuickTime\QTSystem\QTJNative.dll` into the `Windows` directory.

You will also need to install a digitizer, we recommend WinVDIG which can be downloaded here:

http://www.eden.net.nz/7/20071008/

You must install version 1.0.1 not a newer version.

You can then test that QTJ and the digitizer are installed correctly through their test application QTCap. (If you have trouble, see Contacting Us.)

On Windows Vista you will need to start NetLogo as administrator in order to use the video extension. You can do so by right clicking on the executable and selecting "Run As Administrator". You can also permanently change this setting: open the properties dialog, select the Compatibility tab and select "Run As Administrator" checkbox.

### Mac OS X

A few files from your QuickTime installation need to be moved into the extension directory in order for the video extension to work.

- Copy `/System/Library/Java/Extensions/QTJava.zip` into the extension directory and rename it `QTJava.jar`.
- Make a directory called `lib` in the QTJ extension directory, then create a directory called `Mac OS X` inside `lib`.
- Copy `/System/Library/Java/Extensions/libQTJNative.jnilib` into the `Mac OS X` directory.

Also, on 64-bit Macs (which includes all currently sold models), you will need to change NetLogo to run in 32-bit mode in order to use the extension. If you don't, the usual result is a java.lang.UnsatisfiedLinkError dialog. Here are the steps to follow:

- Select the NetLogo application icon in the Finder.
- On the File menu, choose Get Info.
- Check this checkbox: "Open in 32-bit mode"
- Open the application.

If you want, you can make a copy of the application first and performs these steps on the copy, so the original still opens in 64-bit mode. (64-bit mode is the recommended default unless you are using this extension.)

### Linux

The QuickTime Extension is not compatible with Linux, because Apple does not have a Linux version of QuickTime.

## Getting started

To import images from webcams and movies into NetLogo you will need to include both the QTJ and the Bitmap Extensions.

    extensions[ bitmap qtj ]

There are two code examples that present the basic functions of these extensions.

> Code Example: QuickTime Extension/QuickTime Camera Example

> Code Example: QuickTime Extension/QuickTime Movie Example

## Primitives

qtj:camera-image qtj:camera-select qtj:camera-start qtj:camera-stop qtj:movie-close qtj:movie-image qtj:movie-open qtj:movie-open-player qtj:movie-set-time qtj:movie-start qtj:movie-stop

### qtj:camera-image

Returns an image from the currently open camera suitable for importing with the bitmap extension

### qtj:camera-select

#### qtj:camera-select width height

Offers a dialog of installed cameras for you to choose from. When you select one a connection is opened with the selected camera at the given resolution. If you use `camera-select` you do not need to call `camera-start`. You must call either select or start before using `camera-image`.

### qtj:camera-start

#### qtj:camera-start width height

Opens the connected camera at the given resolution (given in patches) and prepares it to grab images. You must always call `camera-start` or `camera-select` before using `camera-image`. You should not use `camera-start` when the camera is already open. To select a different camera use `camera-stop` then `camera-select`.

### qtj:camera-stop

Closes the connected camera. You should always stop the camera before exiting NetLogo or before opening a new model.

### qtj:movie-close

Closes the currently open movie, disposes of any related resources including the player window. You should always close a movie before opening a new one or before exiting NetLogo.

### qtj:movie-image

Returns an image of the current frame of the open movie suitable for importing with the bitmap extension.

### qtj:movie-open

#### qtj:movie-open width height

Loads the specified movie at the specified resolution (given in patches).

### qtj:movie-player

#### qtj:movie-open-player

Opens a window where you can view the open movie.

### qtj:movie-set-time

#### qtj:movie-set-time seconds

Changes the frame of the movie to the frame corresponding to the given time.

### qtj:movie-start

Starts playing the movie.

### qtj:movie-stop

Stops playing the movie.