karen.devices.Watcher

Watcher device to capture and process inbound video stream for objects and faces.

__init__(self, parent=None, classifierFile=None, recognizerFile=None, namesFile=None, trainingSourceFolder=None, videoDeviceIndex=0, framesPerSecond=29.97, orientation=0, callback=None) special

Watcher Initialization

Parameters:
  • classifierFile (str) – Classifier file such as haarcascades to identify generic objects.

  • recognizerFile (str) – Trained file to be used to identify specific objects. (optional)

  • namesFile (str) – File with friendly names tied to recognizer trained data set. (optional)

  • trainingSourceFolder (str) – The source directory that contains all the images to use for building a new recognizerFile.

  • videoDeviceIndex (int) – Video Device identifier. (optional)

  • framesPerSecond (float) – Number of frames per second. Defaults to NTSC.

  • orientation (int) – Device orientation which can be 0, 90, 180, or 270. (optional)

  • videoDeviceIndex (int) – Video device index number. If not set then will use default video capture device.

  • callback (function) – Callback function for which to send any captured data.

  • parent (object) – Containing object's reference. Normally this would be the device container. (optional)

isRunning(self)

Identifies if the device is actively running.

Returns:
  • (bool) – True if running; False if not running.

snapshot(self, httpRequest)

Displays the snapshot from the last frame

Parameters:
  • httpRequest (KHTTPHandler) – Handler for inbound request (from which to pull the socket).

Returns:
  • (bool) – True on success or False on failure

start(self, httpRequest=None, useThreads=True)

Starts the watcher.

Parameters:
  • httpRequest (KHTTPHandler) – Handler for inbound request. Not used.

  • useThreads (bool) – Indicates if the brain should be started on a new thread.

Returns:
  • (bool) – True on success else will raise an exception.

stop(self, httpRequest=None)

Stops the watcher.

Parameters:
  • httpRequest (KHTTPHandler) – Handler for inbound request. Not used.

Returns:
  • (bool) – True on success else will raise an exception.

stream(self, httpRequest)

Adds a streaming client to the watcher device for MJPEG streaming output

Parameters:
  • httpRequest (KHTTPHandler) – Handler for inbound request (from which to pull the socket).

Returns:
  • (bool) – True on success or False on failure

train(self, httpRequest=None, trainingSourceFolder=None)

Retrains the face recognition based on images in the supplied folder

Parameters:
  • httpRequest (KHTTPHandler) – Handler for inbound request. Not used.

  • trainingSourceFolder (str) – The source directory that contains all the images to use for building a new recognizerFile. Will use the configuration value if the input value is left empty. (optional)

Returns:
  • (bool) – True on success or False on failure

wait(self, seconds=0)

Waits for any active watchers to complete before closing.

Parameters:
  • httpRequest (KHTTPHandler) – Handler for inbound request. Not used.

  • seconds (int) – Number of seconds to wait before calling the "stop()" function

Returns:
  • (bool) – True on success else will raise an exception.