Skip to main content

ORPHE ANALYTICIS SDK for Python

Project description

ORPHE ANALYTICIS SDK for Python is a client library that accesses the ORPHE ANALYTICS resource API and real-time API.

Install

You can install ORPHE ANALYTICIS SDK for Python (hereafter orphe-py) using PyPI. Install with the following command.

$ pip install orphe

If you are using Python 3, you can install it with the following command.

$ pip3 install orphe

Usage

To start using ORPHE ANALYTICIS SDK, create a client. To create a client, use the URL of the connection destination and the credentials of the edge account (token or user name/password combination). See intdash client for other available parameters.

import orphe

analytics = orphe.Analytics(
    url = "https://example.analytics.orphe.ai",
    token = "your_token",
)

Example: An example for retrieving and storing a value is given below.

import orphe

# Generate a client with a URL and an edge token
analytics = orphe.Analytics(
    url = "https://example.analytics.orphe.ai",
    token= "your_token"
)
# Get data by specifying the measurement UUID
analyzed = analytics.load(
    measurement_uuid = "e07cdf8c-83e6-46cf-8a03-e315eef6162a",
)

# Extract, analyze and display values from stored data (channel 1 -> plantar left, channel 2 -> plantar right)
for gait in analyzed.gait.stored[1]:
    print(f"Plantar left/{gait.time}/{gait.quaternion_w}/{gait.quaternion_x}/{gait.quaternion_y}/{gait.quaternion_z}")

for gait in analyzed.gait.stored[2]:
    print(f"Plantar right/{gait.time}/{gait.quaternion_w}/{gait.quaternion_x}/{gait.quaternion_y}/{gait.quaternion_z}")
    
# If you want to take out the value of gait analysis, you can filter it by [gait.analyzed] from stored data (channel 3 -> Instep left, channel 4 -> Instep right)
for gait in analyzed.gait.stored[3]:
    if not gait.analyzed:
        continue
    print(f"Instep left/{gait.time}/{gait.stride}/{gait.cadence}/{gait.duration}")

for gait in analyzed.gait.stored[4]:
    if not gait.analyzed:
        continue
    print(f"Instep right/{gait.time}/{gait.stride}/{gait.cadence}/{gait.duration}")

# To save the value, use [orphe.Unit]
units = []
for gait in analyzed.gait.left:
    units.append(orphe.Unit(
        time = gait.time,
        id = "Height",
        value = 160
    ))

# Save the data by specifying the measurement UUID and the list of [orphe.Unit].
analytics.save(
    measurement_uuid="e07cdf8c-83e6-46cf-8a03-e315eef6162a",
    units=units
)

After analytics.load is performed, the retrieved valuesanalyzed will contain the values retrieved from ORPHE CORE and the values analyzed by ANALYTICS. By gait, the data of gait analysis is retrieved, and left and right data can be retrieved respectively.

In addition, if you want to perform real-time analysis, you can use the following method.

import orphe

# Generate a client with a URL and an edge token
analytics = orphe.Analytics(
    url = "https://example.analytics.orphe.ai",
    token= "your_token"
)

# Defines a callback for realtime. [value] will contain the raw and parsed data.
# New real-time data can be sent by returning list[Unit].
# * Real-time data transmission is sent to a separate edge specified by [upstream_edge_uuid].
def callback(value: AnalyticsValue) -> list[Unit]:
    if value.gait.left.stride != None:
        print(value.gait.left.stride)
    if value.gait.left.euler_x != None:
        print(value.gait.left.euler_x)
        
    units = []
    time = value.pose.realtime.time
    val = random.randint(0, 100)
    units.append(Unit(
        time=time,
        channel=3,
        id="RANDOM",
        value=val,
    ))
    return units

# Start real-time acquisition by specifying the callback and the ID of the edge.
# Specify the EdgeUUID to get the real-time data being measured in [downstream_edge_uuid].
# Specify the EdgeUUID for sending real-time values from the SDK in [upstream_edge_uuid].
analytics.realtime(
    callback = callback,
    downstream_edge_uuid="08058fc6-3374-407a-b9ed-fcbe81217ac9",
    upstream_edge_uuid="2e21f332-fb85-4679-ba55-e07e36c12667"
)

Documentation

Documentation and links to additional resources are available at https://analytics.orphe.io

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

orphe-0.1.0.tar.gz (12.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

orphe-0.1.0-py3-none-any.whl (14.3 kB view details)

Uploaded Python 3

File details

Details for the file orphe-0.1.0.tar.gz.

File metadata

  • Download URL: orphe-0.1.0.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.26.0 requests-toolbelt/0.9.1 urllib3/1.26.6 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.7

File hashes

Hashes for orphe-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e5908df4fcb2bd072f0070d1a08f8a041769772e58fbbd139ed7dc9354425ed9
MD5 24b6404dd702c7794747495cdae04606
BLAKE2b-256 0b78913addcbb98d1dc109dc4a90755fcede750902a054f6ce09f9eb542245f3

See more details on using hashes here.

File details

Details for the file orphe-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: orphe-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 14.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.26.0 requests-toolbelt/0.9.1 urllib3/1.26.6 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.7

File hashes

Hashes for orphe-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b1bbd50c3ef8ed680ca7da5d7e11439c8e3976049121c1da3893e2bc896269c9
MD5 d4e0aadb49fe72b56f860c98ee8534f6
BLAKE2b-256 b9fb6891aa4f41a60afe36461716ecda10eccc75e00801c2a781ceebff455492

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page