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.1.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.1-py3-none-any.whl (14.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: orphe-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 b8488b9f94e7e9fe57f878330835f7e4cffb5cb62d5db5fcdccb72019adb5f42
MD5 43aaa010d567ab00fc9a0694d8738744
BLAKE2b-256 5b958d48562a12e3d5e367d4c246f59fcd6ed155dea2dd7cd507e4664b254d2f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: orphe-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0c5a1cb59dd53df078b8bb9e218b05ae1c3b43abb81b7fab1c09e504ce23ea3b
MD5 3b71b8b4af00cf8b0b1bc3a576782944
BLAKE2b-256 0cce0701af348ab741d27204567fc71f83779a4ef7fdef516a407c9fff66ddf7

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