Command Line Interface for AnyMotion API
Project description
AnyMotion CLI
This package provides a command line interface to AnyMotion, which is a motion analysis API using pose estimation. It uses the AnyMotion Python SDK.
It works on Python versions:
- Python 3.6
- Python 3.7
- Python 3.8
Installation
Install using pip:
$ pip install anymotion-cli
Getting Started
Before using anymotion-cli, you need to tell it about your credentials which issued by the AnyMotion Portal. You can do this in several ways:
- CLI command
- Credentials file
- Environment variables
The quickest way to get started is to run the amcli configure
command:
$ amcli configure
AnyMotion API URL [https://api.customer.jp/anymotion/v1/]:
AnyMotion Client ID: your_client_id
AnyMotion Client Secret: your_client_secret
To use environment variables, do the following:
export ANYMOTION_CLIENT_ID=<your_client_id>
export ANYMOTION_CLIENT_SECRET=<your_client_secret>
To use the credentials file, create an INI formatted file like this:
[default]
anymotion_client_id=<your_client_id>
anymotion_client_secret=<your_client_secret>
and place it in ~/.anymotion/credentials
.
Note: If set in both the credentials file and environment variables, the environment variables takes precedence.
Usage
You can use amcli
.
amcli [OPTIONS] COMMAND [ARGS]...
See the table below for more information, or run it with the --help
option.
Commands to process something (verb commands)
command name | description |
---|---|
upload | Upload the local movie or image file to the cloud storage. |
download | Download the drawn file. |
extract | Extract keypoints from uploaded images or movies. |
draw | Draw points and/or lines on uploaded movie or image. |
analyze | Analyze the extracted keypoint data. |
Commands to show something (noun commands)
command name | description |
---|---|
image | Show the information of the uploaded images. |
movie | Show the information of the uploaded movies. |
keypoint | Show the extracted keypoints. |
drawing | Show the information of the drawn images or movies. |
analysis | Show the analysis results. |
Other commands
command name | description |
---|---|
configure | Configure your AnyMotion Credentials. |
Examples
Draw keypoints in image file
First, upload the image file.
$ amcli upload image.jpg
Success: Uploaded image.jpg to the cloud storage. (image id: 111)
When the upload is complete, you will get an image id
.
Extract keypoints using this image id
.
$ amcli extract --image-id 111
Keypoint extraction started. (keypoint id: 222)
Success: Keypoint extraction is complete.
Draw points/lines to image using keypoint id
.
$ amcli draw 222
Drawing is started. (drawing id: 333)
Success: Drawing is complete.
Downloaded the file to image.jpg.
When the drawing is complete, the drawing file is downloaded (by default, to the current directory).
To save to a specific file or directory, use the --out
option.
Draw using rules
You can use the rules to draw a variety of things. In the following example, draw the lines of stick picture in red.
$ amcli draw 222 --rule '{"drawingType": "stickPicture", "pattern": "all", "color": "red"}'
You can also specify it in the JSON file.
$ amcli draw 222 --rule-file rule.json
For more information on the drawing rules, see the documentation.
Show extracted keypoints
You can use the keypoint show
command to display the extracted keypoint data.
$ amcli keypoint show 1234
{
"id": 1234,
"image": null,
"movie": 123,
"keypoint": [
{
"leftKnee": [
487,
730
],
...
The --only
option allows you to display only the keypoint data.
$ amcli keypoint show 1234 --only
[
{
"leftKnee": [
487,
730
],
"rightKnee": [
1118,
703
]
...
With jq, it's also easy to take out only certain parts of the body.
$ amcli keypoint show 1234 --only | jq '[.[].leftKnee]'
[
[
487,
730
],
null,
null,
...
Shell Complete
The anymotion-cli supports Shell completion.
For Bash, add this to ~/.bashrc
:
eval "$(_AMCLI_COMPLETE=source amcli)"
For Zsh, add this to ~/.zshrc
:
eval "$(_AMCLI_COMPLETE=source_zsh amcli)"
For Fish, add this to ~/.config/fish/completions/amcli.fish
:
eval (env _AMCLI_COMPLETE=source_fish amcli)
Change Log
See CHANGELOG.md.
Contributing
-
Code must work on Python 3.6 and higher.
-
Code should follow black.
-
Docstring should follow Google Style.
-
Install all development dependencies using:
$ poetry install
-
Before submitting pull requests, run tests with:
$ poetry run tox
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
Built Distribution
Hashes for anymotion_cli-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8f1fb90aea444b402ca2cb0e239df3faefe41a8f08bf003c2a67ea64fa43990c |
|
MD5 | 7a426572c4951b851af0c96495bfddcb |
|
BLAKE2b-256 | 286819ac7e2e3840e0ce1b4be05e223a85b43c7a2955b436434a9c6458ff6d26 |