PhoneSensor for machinevisiontoolbox. Get camera and IMU data from a camera remotely with Python
Project description
machinevision-toolbox-python.phone-sensor
Quickstart
Install with pip
:
pip install -U machinevision-toolbox-python.phone-sensor
# or
pip install git+https://github.com/CallumJHays/machinevision-toolbox-python.phone-sensor
Example Code:
from phone_sensor import PhoneSensor
from matplotlib import pyplot as plt
# Hosts a webserver in a background thread.
# Display a QR code link to the app
phone = PhoneSensor(qrcode=True)
# wait for button press to snap a photo
img = phone.grab(button=True)
# get device orientation as a Quaternion
quaternion = phone.imu().quaternion
plt.subplot(1, 2, 1)
plt.imshow(img)
plt.subplot(1, 2, 2)
plt.bar(['x', 'y', 'z', 'w'], quaternion)
plt.show()
The above code will create an ASCII QRcode in your terminal. Scanning it with a smartphone will take you to a webapp hosted by the PhoneSensor
, which looks like:
The output img
is a width x height x 3
rgb np.ndarray
like you'd expect from machinevisiontoolbox
or opencv-python
.
Contributing
PRs welcome! The stack is Python3.6 and Typescript4.1 & CreateReactApp4.0
Development Install
First, clone this repo and install dependencies
npm install
pip install -e .
Running in Development Mode
- Run the dev-server (and keep it running):
npm start
- Create a PhoneSensor in proxy mode:
>>> from phone_sensor import PhoneSensor
>>> phone = PhoneSensor(qrcode=True, \
proxy_client_from="localhost:3000")
>>> phone.grab(button=True)
or just run the python examples/devmode.py
Then click the link in terminal to test the app
Project details
Release history Release notifications | RSS feed
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
Close
Hashes for machinevision-toolbox-python.phone-sensor-0.2.8.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 80feb4310dceb4997655e2d92f0f880b71e1ffe9369b868c7fb4fed8bff6c1f2 |
|
MD5 | 01eb6b9a95dc6fbcd965680ac6e3277d |
|
BLAKE2b-256 | 831edb49614f00ce433296e78d655a39353856990761ad36caf34746b2fea199 |
Close
Hashes for machinevision_toolbox_python.phone_sensor-0.2.8-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b50bf69378f097f02f5208b2df1914ec1602497434147ca942086acd9e45cd6 |
|
MD5 | 7738f4bf8ce8c4616d8d968b151aafb6 |
|
BLAKE2b-256 | 3d78f42913ebda9755ba9e6ffa26ea1988523b241a4d35f9da3d81988c66bd2e |