sdk package — QTI's python SDK for IOT connected camera 0.0 documentation

# sdk package

## Submodules

## sdk.camera module

This module contains the high level client APIs.

class `sdk.camera.` `CameraClient`(ipc_provider)

  Bases: `object`

  This is a class for high level client APIs.

  Variables

    - ipc_provider (IpcProvider object) –

    - preview_running (bool) – Flag for preview status.

    - preview_url (str) –

    - vam_running (bool) – Flag for vam status.

    - vam_url (str) –

    - resolutions (list of str) – List of supported resolutions values. Use this for configure_preview API.

    - encodetype (list of str) – List of supported codec types. Use this for configure_preview API.

    - bitrates (list of str) – List of supported bitrates values. Use this for configure_preview API.

    - framerates (list of int) – List of supported fps values. Use this for configure_preview API.

    - cur_resolution (str) – Current preview resolution

    - cur_codec (str) – Current preview encode type

    - cur_bitrate (str) – Current preview bitrate

    - cur_framerate (int) – Current preview framerate

    - display_out (int) – Flag that tells whether HDMI display/preview is enabled or not. HDMI display/preview is enabled if this flag is 1 else disabled. This can be configured using configure_preview API.

  `captureimage`()

    This method is for taking a snapshot.

    The snapshot is taken and stored as snapshot_<timestamp>.jpg when the call is successful.

    Returns

      True if the request was successful. False on failure.

    Return type

      bool

  `configure_overlay`(type=None, text=None)

    This is for configuring overlay params.

    Parameters

      - type ({None, "inference", "text"}) – Type of the overlay you want to configure.

      - text (str, optional) – Text for text overlay type (the default is None).

      - Returns – True if the configuration was successful. False on failure.

  `configure_preview`(resolution=None, encode=None, bitrate=None, framerate=None, display_out=None)

    This method is for setting preview params.

    Parameters

      - resolution (str) – A value from resolutions attribute

      - encode (str) – A value from encodetype attribute

      - bitrate (str) – A value from bitrates attribute

      - framerate (int) – A value from framerates attribute

      - display_out ({0, 1}) – For enabling or disabling HDMI output

    Returns

      True if the request is successful. False on failure.

    Return type

      bool

  classmethod `connect`(ipc_provider=None, ip_address=None, username=None, password=None)

    This method is used to create CameraClient handle for application.

    Parameters

      - ipc_provider (IpcProvider object) – IpcProvider handle for class methods.

      - ip_address (str) – IP address of the camera.

      - username (str) – username for the camera.

      - password (str) – password for the camera.

    Yields

      CameraClient – CameraClient handle for the application.

  `get_inferences`()

    Inference generator for the application.

    This inference generator gives inferences from the VA metadata stream.

    Yields

      AiCameraInference (AiCameraInference class object) – This AiCameraInference object yielded from VideoInferenceIterator.start()

    Raises

      EOFError – If the preview is not started. Or if the vam is not started.

  `logger` = <Logger iotccsdk (INFO)>
  `logout`()

    This method is for logging out from the camera.

    Returns

      True if the request was successful. False on failure.

    Return type

      bool

  `set_analytics_state`(state)

    This is a switch for video analytics(VA).

    VA can be enabled or disabled using this API.

    Parameters

      state (str) – Set it “on” for enabling or “off” for disabling Video Analytics.

    Returns

      True if the request was successful. False on failure.

    Return type

      bool

  `set_overlay_state`(state=None)

    This is a switch for overlay.

    Overlay can be enabled or disabled using this API.

    Parameters

      state (str) – Set it “on” for enabling or “off” for disabling overlay.

    Returns

      True if the request was successful. False on failure.

    Return type

      bool

  `set_preview_state`(state)

    This is a switch for preview.

    Preview can be enabled or disabled using this API.

    Parameters

      state (str) – Set it “on” for enabling or “off” for disabling preview.

    Returns

      True if the request was successful. False on failure.

    Return type

      bool

  `set_recording_state`(state)

    This is a switch for recording.

    Recording can be enabled or disabled using this API.

    Parameters

      state (str) – Set it “on” for enabling or “off” for disabling recording.

    Returns

      True if the request was successful. False on failure.

    Return type

      bool

## sdk.frame_iterators module

This module provides iterator for getting frame and inference.

class `sdk.frame_iterators.` `CameraInference`(timestamp, objects)

  Bases: `object`

  This is a class for inferences obtained from the camera.

  Variables

    - timestamp (int) – Timestamp at which the inferences where made by the camera.

    - objects (list of CameraInferenceObject objects) – List of inferences obtained from the camera.

class `sdk.frame_iterators.` `CameraInferenceObject`(id, label, confidence, position=None)

  Bases: `object`

  This is a class for inference data obtained from the camera.

  Variables

    - id (int) – ID of the identified object.

    - label (str) – Label of the identified object.

    - confidence (int) – Confidence value for the object in %.

    - position (object of CameraInferenceObjectPosition type) – Position of the identified object.

class `sdk.frame_iterators.` `CameraInferenceObjectPosition`(x, y, width, height)

  Bases: `object`

  This is a class for inferenced object position.

  Variables

    - x (int) – x coordinate of the inferenced object.

    - y (int) – y coordinate of the inferenced object.

    - width (int) – width of the inferenced object from x.

    - height (int) – height of the inferenced object from y.

class `sdk.frame_iterators.` `VideoInferenceIterator`(preview_width, preview_height)

  Bases: `object`

  This is a class for inference generator.

  Provides an generator method which can be used to get inferences from RTSP VA stream from the camera.

  Variables

    - preview_width (int) – Preview stream width. This is required for object location calculation.

    - preview_height (int) – Preview stream height. This is required for object location calculation.

  `start`(result_src)

    This is the inference generator method

    It gets inferences from the RTSP VA stream from the camera.

    Parameters

      result_src (str) – VA RTSP stream url.

    Yields

      CameraInference – An object of CameraInference type. Which has timestamp and list of CameraInferenceObject objects.

    Raises

      Exception – Any exception that occurs during inference handling.

  `stop`()

    This method stops the inference generator.

## sdk.ipcprovider module

This module provides APIs for communicating with QMMF IPC webserver.

class `sdk.ipcprovider.` `IpcProvider`(ip=None, username=None, password=None)

  Bases: `object`

  This class provides interface to QMMF IPC webserver.

  Variables

    - username (str) – username of the camera.

    - password (str) – password of the camera.

    - ip_address (str) – IP address of the camera.

  `connect`()

    Establish a connection with QMMF IPC webserver on the camera.

    This API also sets the session_token attribute from the token obtained from the camera.

    Returns

      True if the connection was successful. False on failure.

    Return type

      bool

    Raises

      - Timeout – When the request times out on the connect request.

      - RequestException – The request is not correctly formed.

  `get`(path, payload=None, param=None)

    GET API for QMMF IPC webserver.

    Parameters

      - path (str) – QMMF IPC webserver API.

      - payload (str) – JSON payload for the path API.

      - param (str) – Params for the path API.

    Returns

      True if the GET was successful. False on failure.

    Return type

      bool

    Raises

      Exception – Any exception that occurs during the request.

  `logout`()

    Logout from the QMMF IPC webserver on the camera.

    Returns

      True if the logout was successful. False on failure.

    Return type

      bool

    Raises

      Exception – Any exception that occurs during the request.

  `post`(path, payload=None, param=None)

    POST API for QMMF IPC webserver.

    Parameters

      - path (str) – QMMF IPC webserver API.

      - payload (str) – JSON payload for the path API.

      - param (str) – Params for the path API.

    Returns

      True if the GET was successful. False on failure.

    Return type

      bool

    Raises

      Exception – Any exception that occurs during the request.

## Module contents