AnyMotion Python SDK
This is the Software Development Kit (SDK) for Python, which allows Python developers to write software that makes use of AnyMotion. It works on Python 3.6 or greater.
Installation
Install using pip:
$ pip install anymotion-sdk
If you want to use a CV-based methods:
$ pip install anymotion-sdk[cv]
Usage
To use AnyMotion Python SDK, you must first import it and tell it about your credentials which issued by the AnyMotion Portal:
import anymotion_sdk
# Setup client
client = anymotion_sdk.Client(client_id="your_client_id", client_secret="your_client_secret")
You can also use environment variables:
export ANYMOTION_CLIENT_ID=<your_client_id>
export ANYMOTION_CLIENT_SECRET=<your_client_secret>
# Setup client using environment variables
client = anymotion_sdk.Client()
The following is how to upload an image and extract the keypoints:
# Upload image file
upload_result = client.upload("image.jpg")
# Extract keypoint
keypoint_id = client.extract_keypoint(image_id=upload_result.image_id)
extraction_result = client.wait_for_extraction(keypoint_id)
# Get keypoint data from result
keypoint = extraction_result.json
You can get the uploaded data or the keypoint extracted data and so on as follows:
# Get data of a specific id
image = client.get_image(image_id)
movie = client.get_movie(movie_id)
keypoint = client.get_keypoint(keypoint_id)
drawing = client.get_drawing(drawing_id)
analysis = client.get_analysis(analysis_id)
comparison = client.get_comparison(comparison_id)
# Get all data
images = client.get_images()
movies = client.get_movies()
keypoints = client.get_keypoints()
drawings = client.get_drawings()
analyses = client.get_analyses()
comparisons = client.get_comparisons()
In get_keypoint, get_drawing, get_analysis, and get_comparison, you can use the join_data option to get the relevant data at the same time.
>>> client.get_keypoint(keypoint_id)
{'id': 1, 'image': 2, 'movie': None, 'keypoint': [{'nose': [10, 20]}], 'execStatus': 'SUCCESS', 'failureDetail': None, 'createdAt': '2020-01-01T00:00:00.000000Z', 'updatedAt': '2020-01-01T00:00:00.000000Z'}
>>> client.get_keypoint(keypoint_id, join_data=True)
{'id': 1, 'image': {'id': 2, 'name': 'image', 'text': '', 'height': 100, 'width': 100, 'contentMd5': 'ecWkdCSrnBa9+EYREt/fbg==', 'createdAt': '2020-01-01T00:00:00.000000Z', 'updatedAt': '2020-01-01T00:00:00.000000Z'}, 'movie': None, 'keypoint': [{'nose': [10, 20]}], 'execStatus': 'SUCCESS', 'failureDetail': None, 'createdAt': '2020-01-01T00:00:00.000000Z', 'updatedAt': '2020-01-01T00:00:00.000000Z'}
The way to output the log to stdout is as follows:
# Log level is INFO by default.
anymotion_sdk.set_stream_logger()
# Set the log level to DEBUG.
# At the DEBUG level, the content of the request and response to the API is output.
anymotion_sdk.set_stream_logger(level=logging.DEBUG)
For more examples, see here.
CV-based methods
If you install the extra package, download_and_read is available.
download_and_read returns the downloaded image or video in numpy format.
data = client.download_and_read(drawing_id)
Warning: Large videos use a lot of RAM.
Change Log
See CHANGELOG.md.
Metadata
Release files for anymotion-sdk 1.2.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| anymotion-sdk-1.2.8.tar.gz | 13.3 kB | Without provenance | Details for anymotion-sdk-1.2.8.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| anymotion_sdk-1.2.8-py3-none-any.whl | Python 3 | none | any | Details for anymotion_sdk-1.2.8-py3-none-any.whl |
Total release size: 27.1 kB
Release files / anymotion-sdk-1.2.8.tar.gz
| Download URL | anymotion-sdk-1.2.8.tar.gz |
|---|---|
| Size | 13.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8f3c00655598151db7f5fdd0853df745252a33bb777d9563ebae33e581eb7c78
|
|
BLAKE2b-256 checksum How to use checksums |
b73a6a8bb29e2c52c09e3c6b4bb09240bcc39e3c71d71b168bfbc02cbf8a4ad0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7
|
Release files / anymotion_sdk-1.2.8-py3-none-any.whl
| Download URL | anymotion_sdk-1.2.8-py3-none-any.whl |
|---|---|
| Size | 13.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0f897d32eb4d1e7c3f471475a64719623c5f39cffbb358798496025b80accf11
|
|
BLAKE2b-256 checksum How to use checksums |
6f7f53f2cff04957989d29f6bcc01c83f5a22029404bf5c1c2e92769014ee422
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7
|
Security for anymotion-sdk 1.2.8
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.