# Events

In this section you will find all of Misty's API calls for triggering different events. You can upload the sample code for an event by loading the event sample template. If you need information on how to trigger events with bump and touch sensors you can check out [sensor-events](https://lessons.mistyrobotics.com/python-elements/misty-python-api/sensor-events "mention").

<figure><img src="https://3732834919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrpyhVmLjv9Bu7tKDF8HF%2Fuploads%2FYzMruE6Z4dF0f7NURjsO%2Fimage.png?alt=media&#x26;token=b149a0cf-984a-4e54-8ab1-baa848375bb9" alt="" width="365"><figcaption></figcaption></figure>

### **StartFaceDetection**

Initiates Misty's detection of faces in her line of vision. This command assigns each detected face a random ID.

{% hint style="success" %}

```
misty.start_face_detection()
```

{% endhint %}

When you are done having Misty detect faces, call `StopFaceDetection`.

### **StopFaceDetection**

Stops Misty's detection of faces.

{% hint style="success" %}

```
misty.stop_face_detection()
```

{% endhint %}

### **StartFaceRecognition**

Directs Misty to recognize a face she sees, if it is among those she already knows. To use this command, you previously must have used either the `StartFaceDetection` command or the `StartFaceTraining` command to detect and store one or more face IDs in Misty's memory.

{% hint style="success" %}

```
misty.start_face_recognition()
```

{% endhint %}

When you are done having Misty recognize faces, call `StopFaceRecognition`.

### **StopFaceRecognition**

Stop Misty looking for face to recognize.

{% hint style="success" %}

```
misty.stop_face_recognition()
```

{% endhint %}

### **StartFaceTraining**

Trains Misty to recognize a specific face and applies a user-assigned ID to that face.

This process should take less than 15 seconds and will automatically stop when complete. To halt an in-progress face training, you can call `CancelFaceTraining`.

**Example Code**

{% hint style="success" %}

```python
misty.start_face_training("Simone")
```

{% endhint %}

**Parameters**

```python
misty.start_face_training(self, faceId : str = None)
```

* FaceId (string) - A unique string of 30 characters or less that provides a name for the face. Only alpha-numeric, -, and \_ are valid characters.

### **CancelFaceTraining**

Halts face training that is currently in progress. A face training session stops automatically, so you do not need to use the `CancelFaceTraining` command unless you want to abort a training that is in progress.

{% hint style="success" %}

```python
misty.cancel_face_training("Simone")
```

{% endhint %}

### **StartObjectDetector**

Starts Misty locating the position and type of objects.&#x20;

**Example Code**

{% hint style="success" %}
{% code overflow="wrap" %}

```python
misty.start_object_detector(0.6,0,5)
```

{% endcode %}
{% endhint %}

When you issue a `StartObjectDetector` command, Misty will start streaming `ObjectDetection` events when an appropriate object is seen.

To receive those events, you must also register for the `ObjectDetection` event type.

Object detection consumes extra resources, so when you are done using the events, you should call the `StopObjectDetector` command.

You can find a list of known objects in [known-objects](https://lessons.mistyrobotics.com/resource-database/known-objects "mention")

**Parameters**

{% code overflow="wrap" %}

```python
misty.start_object_detector(self, minimumConfidence : float = None, modelId : int = None, maxTrackerHistory : int = None, delegateType : int = None)
```

{% endcode %}

* MinimumConfidence (double) - The minimum confidence to trigger sending an event. From 0 to 1.0.
* ModelId (int) - The TensorFlow Lite object model to use. Valid model ids are 0-3.
* MaximumTrackerHistory (int) - How long to hold previous object history across frames.

### **StopObjectDetector**

Stop Misty locating the position and types of objects.

{% hint style="success" %}
{% code overflow="wrap" %}

```python
misty.stop_object_detector()
```

{% endcode %}
{% endhint %}

### **StartArTagDetector**

Starts Misty locating the position and values of Ar Tags.

**Example Code**

{% hint style="success" %}
{% code overflow="wrap" %}

```python
misty.start_ar_tag_detector(7,144)
```

{% endcode %}
{% endhint %}

When you issue a `StartArTagDetector` command, Misty will start streaming `ArTagDetection` events when an appropriate tag is seen.

To receive those events, you must also register for the [`ArTagDetection`](https://docs.mistyrobotics.com/misty-ii/robot/sensor-data/#artagdetection) event type.

**Parameters**

{% code overflow="wrap" %}

```python
misty.start_ar_tag_detector(self, dictionary : int = None, tagSizeMm : float = None)
```

{% endcode %}

* Dictionary (int) - The Ar Tag dictionary to use.
* TagSizeMm (double) - The size of the printed tags. Used in assessing distance.

### **StopArTagDetector**

Stops Misty locating position and values of AR tags.

{% hint style="success" %}

```
misty.stop_ar_tag_detector()
```

{% endhint %}

### **StartQrTagDetector**

Starts Misty detecting QR tags.

{% hint style="success" %}

```
misty.start_qr_tag_detector()
```

{% endhint %}

### **StopQrTagDetector**

Stops Misty detecting QR tags.

{% hint style="success" %}

```
misty.stop_qr_tag_detector()
```

{% endhint %}

### **StartRobotInteractionEvent**

Initiates a robot interaction event in Misty, enabling her to engage in interactions that may involve vision data processing.

**Example code**

{% hint style="success" %}

```python
misty.start_robot_interaction_event(True)
```

{% endhint %}

**Paratmeters**

```python
misty.start_robot_interaction_event(self, useVisionData : bool = None)
```

* `useVisionData` (bool): Specifies whether the interaction event should utilize Misty's vision capabilities. When set to `True`, Misty will process visual data (such as facial recognition or object detection) as part of the interaction.

### **StopRobotInteractionEvent**

Stops the interaction event.

{% hint style="success" %}

```python
misty.stop_robot_interaction_event()
```

{% endhint %}
