Evaluating Triggers

Once your device has been registered and triggers have been created, you can use the SDK to begin evaluating these triggers on your device.

import smartcapture

DEVICE_NAME = "NY Car"

smartcap_client = smartcapture.SmartCaptureClient("YOUR_SCALE_API_KEY", DEVICE_NAME)

def get_device_state():
    """ Collect all device state that is needed for trigger evaluation this time step."""

    # Example of what a state object could look like:
    return {
        speed: 18.5,
        camera_front: img,  # np.uint8 array with RGB pixel data
        predictions: [],  # list of your model's predictions in your desired format
    }

while True:
  	smartcap_client.load("ny_car.json")
    state = get_device_state()
    evaluated_triggers = smartcap_client.evaluate(state)

    for trigger_id, fired in evaluated_triggers:
      	if fired:
        		# Save image to Nucleus or data lake

Call the Smart Capture client in your main run loop to evaluate the state of the device and determine if any triggers are activated. Evaluation of the triggers does not require any network connection. Triggers can initially be saved onto the device on startup or whenever there is a network connection and will be updated upon a deploy if the device has a connection. Triggers can then be loaded from the device by the SDK in the run loop.


Did this page help you?