Af2Camera.get - affluxis/csjava GitHub Wiki

Usage
Af2Camera.get(context [, index])

Parameters
context - An interface to global information about an application environment.
index - An optional zero-based integer that specifies which camera to get, as determined from the array returned by Af2Camera.names. To get the default camera (which is recommended for most applications), omit this parameter.

Returns
If index is not specified, this method returns a reference to the default camera. If index is specified, this method returns a reference to the requested camera.

Description
Method; returns a reference to a Af2Camera object for capturing video. To actually begin capturing the video, you must get the renderer object either from Af2Camera or from Af2NetStream object. Unlike objects that you create using the new constructor, multiple calls to Af2Camera.get reference the same camera. Thus, if your script contains the lines cam1 = Af2Camera.get(this) and cam2 = Af2Camera.get(this), both cam1 and cam2 reference the same (default) camera. In general, you shouldn’t pass a value for index; simply use Af2Camera.get(this) to return a reference to the default camera. When a client runtime tries to access the camera returned by Af2Camera.get — for example, when you issue Af2NetStream.attachVideo — the target environment displays a Privacy dialog box that lets the user choose whether to allow or deny access to the camera. You can display the Privacy panel for the user by using System.showSettings(this, 0). To determine whether any cameras are installed, use Af2Camera.names.length. To display the target environment Camera Settings panel, which lets the user choose the camera to be referenced by Af2Camera.get, use Af2System.showSettings(this, 3). Note that scanning the hardware for cameras takes time.

Example
The following example captures and displays video locally within an object named myVid.

myCam = Af2Camera.get(this);
myRndr = myCam.getRenderer();
myView.addView(myRndr);

See also
Af2Camera.index, Af2Camera.names, Af2Camera.setMode, Af2NetStream.attachAudio, Af2System.showSettings, Af2Video.attachVideo