Summary: Nested Classes | Methods | Inherited Methods | [Expand All]
public class

# MultiDetector

extends Detector<Object>

java.lang.Object
↳ | com.google.android.gms.vision.Detector<java.lang.Object>
| ↳ | com.google.android.gms.vision.MultiDetector

## Class Overview

A multi-detector is used to combine multiple detectors, so that multiple detectors can be used together on a frame or frames received from a source within a pipeline. Each detector is run separately on each associated frame.

For example, the code below creates and starts a pipeline that continuously receives preview frames from a camera source, runs two different detectors on each frame, and delivers results to associated processors.

    fooDetector.setProcessor(new MyFooProcessor());
     barDetector.setProcessor(new MyBarProcessor());

     MultiDetector multiDetector = new MultiDetector.Builder()
       .add(fooDetector)
       .add(barDetector)
       .build();

     CameraSource cameraSource = new CameraSource.Builder(context, multiDetector)
       .build()
       .start();

Where "fooDetector" is a Detector implementation for detecting "foos" and "MyFooProcessor" is a Detector.Processor implementation for receiving the "foos" that are detected.

## Summary

Nested Classes
class | MultiDetector.Builder | Builder for creating MultiDetector instances.

Public Methods
SparseArray<Object> | detect(Frame frame) Runs detection on the supplied frame with each underlying detector, returning the combined detection results from all detectors.
boolean | isOperational() Indicates whether the detector has all of the required dependencies available locally in order to do detection.
void | release() Releases the underlying resources associated with the multi-detector and its underlying detectors.
void | setProcessor(Processor<Object> processor) This method is not supported on MultiDetector.

[Expand] Inherited Methods
From class com.google.android.gms.vision.Detector
abstract SparseArray<Object> | detect(Frame frame) Analyzes the supplied frame to find target item instances (e.g., the face detector finds faces).
boolean | isOperational() Indicates whether the detector has all of the required dependencies available locally in order to do detection.
void | receiveFrame(Frame frame) Pipeline method (see class level documentation above) for receiving frames for detection.
void | release() Shuts down the detector, releasing any underlying resources.
boolean | setFocus(int id) Sets the ID of the detected item in which to exclusively track in future use of the detector.
void | setProcessor(Processor<Object> processor) Pipeline method (see class level documentation above) which sets the `Detector.Processor` instance.
From class java.lang.Object
Object | clone()
boolean | equals(Object arg0)
void | finalize()
final Class<?> | getClass()
int | hashCode()
final void | notify()
final void | notifyAll()
String | toString()
final void | wait(long arg0, int arg1)
final void | wait(long arg0)
final void | wait()

## Public Methods

#### public SparseArray<Object> detect (Frame frame)

Runs detection on the supplied frame with each underlying detector, returning the combined detection results from all detectors.

##### Returns

- mapping of int to detected object, where the int domain represents the ID of the associated item. If tracking is enabled, as the same item is detected in consecutive frames, the detector will return the same ID for that item.

##### Throws

IllegalStateException | This indicates that the results from the underlying detectors could not be combined, because the same ID was associated with different detected items. This likely means that there is a bug with one of the detectors, in that it did not translate its detected item IDs to the global ID space.

#### public boolean isOperational ()

Indicates whether the detector has all of the required dependencies available locally in order to do detection.

When an app is first installed, it may be necessary to download required files. If this returns false, those files are not yet available. Usually this download is taken care of at application install time, but this is not guaranteed. In some cases the download may have been delayed.

If your code has added a processor, an indication of the detector operational state is also indicated with the `detectorIsOperational()` method. You can check this in your app as it processes detection results, and can convey this state to the user if appropriate.

##### Returns

- true if the detector is operational, false if the dependency download is in progress

#### public void release ()

Releases the underlying resources associated with the multi-detector and its underlying detectors.

#### public void setProcessor (Processor<Object> processor)

This method is not supported on MultiDetector. Instead, processor instances may be set on each underlying detector that is added in creating this MultiDetector.

##### Throws

UnsupportedOperationException |