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.9.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | d73327902e9236350608cd853dcb2c59c50e64edce815cb476466d826c76ebea |
|
MD5 | 49007b2c7dadda2c5e24d725481b9c71 |
|
BLAKE2b-256 | 3ae3e7471e4c64185cfb210c5cfc18582e96ce8db62a5c80db25259b162fb727 |
Close
Hashes for machinevision_toolbox_python.phone_sensor-0.2.9-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1907d18c2ee95c82ff7d228e07c68f644024b8b6be37d4db52999e76eb741817 |
|
MD5 | 450e2f8354d3de47993cf2f06b3cdc28 |
|
BLAKE2b-256 | b8f0839095ebc19aa3ec2d67b210acd69b755d9f9a3f626c90f17e2e5c3b587f |