Quickstart#

Our SDK has a Python interface and supports Python 3.12+.

Install our SDK library:

pip install tinesight

Sign up at here and note your username/password.

Background#

Tinesight leverages mTLS to authenticate devices. When you have an account, you can make a request through our SDK to “register” a new device, via a certificate signing request.

We anticipate that a larger company may make bulk requests to provision a fleet of devices, which can be done through the SDK - but you can also do a single device (subject to your subscription).

Registering a device#

To register a device, your device needs a private key, which can be generated with tools like openssl or Python’s cryptography. A single private key can be generated with

openssl genrsa -out user.key 2048

This will generate a file called user.key that should be located in a secure location on the device, and you will need the key to make requests with the SDK’s TinesightClient.

To get a signed certificate for your device, use the following code:

from tinesight.registrar import TinesightRegistrar

# declare a registrar object, login, and register a device
tsr = TinesightRegistrar()
tsr.login(my_username, my_password) # obviously put your user/password combo
device123_cert = tsr.register_device(path_to_my_key, "device123")
with open("my_new_signed_cert_for_device_123.pem","wb") as fp:
    fp.write(device123_cert)

Note that we use SRP for authentication, so your password never leaves your device.

Subject to your subscription’s device limits, the SDK will return a string that represents the signed certificate, which is valid for one year. You can save the certificate as a PEM file:

Using TinesightClient#

Now that you have a private key / signed certificate, you can use the API to classify a single image:

# declare a tinesight client with your signed certificate and invoke our API!
tsc = TinesightClient(path_to_my_key, path_to_my_cert)
tsc.classify(my_image)

You can also run object detection, which returns a list of detected objects with bounding boxes:

result = tsc.detect(my_image)
for detection in result.json():
    print(detection["class"], detection["probability"], detection["bbox"])

Or you can run classification or detection continuously on a video stream, which requires the tinesight[video] extra when installing the package.

tsc.classify_video_stream()
# or with object detection (shows bounding boxes)
tsc.detect_video_stream()

Using with a Raspberry Pi#

If you have a Raspberry Pi, you can also use the TinesightClient.

Raspberry Pi video capture is best accomplished with picamera2, which has pre-packaged Python versions but whose dependencies do not, which makes full pre-packaging (for example into the tinesight PyPi .whl) a bit more difficult than it needs to be.

Thus, it’s best to ensure that picamera2 is (system, not venv) installed on your Pi by running sudo apt install python3-picamera2. See your Pi for details.

You can check that it works as expected by opening a terminal, running Python, and running from picamera2 import Picamera2, which should give no errors.

When using a venv on a Pi, we actually need to refer to the system site package version of picamera2 so we need to run:

python -m venv venv --system-site-packages
source venv/bin/activate
pip install tinesight[video] --pre # use --pre for dev release

And then you should be able to follow the guide above to run video classification.