File

src/interfaces/IDetector.ts

Description

Interface used to configure, load and get detections from the camera.

Index

Methods

Methods

init
init()

Convenience function for setting up the camera for starting/stopping genius framing. Should be called before any other methods.

Returns : Promise<any>

Returns a promise which resolves in case the detector init is completed otherwise it rejects with a rejection message!

on
on(message: string, callback: any)

EventEmitter on listener. It is used for emitting detector events such as DETECTOR_START, DETECTOR_STOP, DETECTIONS etc. The list of detector events together with all the other camera events can be found in the Events.ts class.

Parameters :
Name Type Optional Description
message string No

The message use to setup the listener for.

callback any No

A callback used to perform actions on the caught event.

Returns : any
once
once(message: string, callback: any)

EventEmitter once listener. Similar to the #on function, instead here the listener is invoked only once and that is the first time the message is emitted from the Detector implementation class.

Parameters :
Name Type Optional Description
message string No

The message use to setup the listener for

callback any No

A callback used to perform actions on the caught event

Returns : any
start
start()

Sends a sequence of commands to the camera to start autozoom on the camera and register for detection events.

Returns : Promise<void>
stop
stop()

Sends a sequence of commands to the camera to stop autozoom and unregister from getting detection events.

Returns : Promise<void>

How to use the detector interface!

Below you can find an example on how to get started with Genius Framing on IQ. Follow the steps below for configuring Genius Framing on the camera and subscribing for detection and framing information!

/* 
We suppose that the SDK has been initialized previously
and the camera is attached and an instance of IDeviceManager
is created!
*/
const detector = await cameraManager.getDetector();
await detector.init();
await detector.start();

/*
In order to subscribe for detection and framing information
proceed with the following code snippet
*/

detector.on('DETECTIONS', (detectionList) => {
  // Process the array
});

detector.on('FRAMING', (framingInfo) => {
  // Process framing info
});


/* To stop Genius Framing on IQ, use the #stop method */
await detector.stop();

Detector Events

The detector class can emit the following events:

Event Description
DETECTIONS Subscribe to this event to get detections from the camera. At the moment only the People class is supported from the detector.
FRAMING Subscribe to this event to get information about the framing. Framing data consists of a property called bbox which contains the coordinates (x, y, width and height) representing the framing data. The framer configuration on the camera will always make sure that the perfect framing of the people in the view is selected.

export default interface IDetector {
  /**
   * Convenience function for setting up the camera
   * for starting/stopping genius framing. Should be
   * called before any other methods.
   *
   * @returns {Promise<any>} Returns a promise which
   * resolves in case the detector init is completed
   * otherwise it rejects with a rejection message!
   * @memberof IDetector
   */
  init(): Promise<any>;

  /**
   * Sends a sequence of commands to the camera to start autozoom
   * on the camera and register for detection events.
   *
   * @memberof IDetector
   */
  start(): Promise<void>;

  /**
   * Sends a sequence of commands to the camera to stop autozoom
   * and unregister from getting detection events.
   *
   * @memberof IDetector
   */
  stop(): Promise<void>;

  /**
   * @ignore
   * Uploads the CNN blob used for detecting people and other
   * objects in the field of view on to the camera.
   *
   * @param {Buffer} blobBuffer The Cnn blob as a Buffer
   * @returns {Promise<void>}
   * @memberof IDetector
   */
  uploadBlob(blobBuffer: Buffer): Promise<void>;

  /**
   * @ignore
   * Uploads the detector configuration.
   *
   * @param {JSON} config JSON representation of the detector configuration file.
   * @returns {Promise<void>}
   * @memberof IDetector
   */
  setDetectorConfig(config: JSON): Promise<void>;

  /**
   * @ignore
   * Uploads the framing configuration file on to the camera.
   *
   * @param {JSON} config JSON representation of the framing configuration file.
   * @returns {Promise<void>}
   * @memberof IDetector
   */
  uploadFramingConfig(config: JSON): Promise<void>;

  /**
   * EventEmitter `on` listener. It is used for emitting detector events
   * such as DETECTOR_START, DETECTOR_STOP, DETECTIONS etc. The list of
   * detector events together with all the other camera events can be found in the `Events.ts` class.
   *
   * @param {string} message The message use to setup the listener for.
   * @param {*} callback A callback used to perform actions on the caught event.
   * @memberof IDetector
   */
  on(message: string, callback: any);

  /**
   * EventEmitter `once` listener. Similar to the `#on` function,
   * instead here the listener is invoked only once and that is
   * the first time the message is emitted from the `Detector` implementation class.
   *
   * @param {string} message The message use to setup the listener for
   * @param {*} callback A callback used to perform actions on the caught event
   * @memberof IDetector
   */
  once(message: string, callback: any);
}

result-matching ""

    No results matching ""