> For the complete documentation index, see [llms.txt](https://gsfcorp.gitbook.io/macula/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gsfcorp.gitbook.io/macula/administration-guide-v1.33.0/tags-and-subjects.md).

# Tags and Subjects

Macula offers a possibility to create tags and subjects for LPR and FR black/white lists, respectively. You can use these in combination with the Event\&Action rules to roll our desired automated scenarios. Tags and subjects in Macula Console are not exported or imported to/from tags and subjects in LPR/FR services; they can act as a supplement or a replacement of these.

{% hint style="info" %}
Tags and subjects here are not synchronized or somehow related to those in Macula LPR or FR modules. If you already have tag lists in the LPR module, you can continue using it with E\&A events.
{% endhint %}

{% hint style="info" %}
At this point, it is only possible to add tags and subjects from Macula Console. The option to add tags from the Macula Monitor application only refers to external LPR/FR service tags.
{% endhint %}

The recognition itself may run on an edge device (e.g., ANPR camera) or be provided by an external service. The idea is that the recognition results are received by Macula and then matched with the local tag/subject database.

**Subjects** are expected license plate or facial recognition results. For ANPR, a subject is a car number plate, and for FR each subject is a person.

**Tags** are used as marks for the LPR/FR subjects. One or more subjects with the same tag form a list, and you can use tags to trigger events and event chains. Each tag can be used for all types of services, which is convenient, for example, to handle access for a group of people and their cars.

#### Create Tags

To create tags in Macula Console, switch to the *Events\&Actions* section. Choose *Tags* on the left, then click the *+New tag* button on the upper panel.

For each tag, you can choose:

* **Title**: user-defined tag name that will appear in rules and in Macula Monitor
* **Color**: will also appear in Macula Monitor to mark entries with this tag
* **Flags**: choose if you want to use this tag for FR lists, LPR lists, or both

<figure><img src="https://412599993-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeNXnJx0OpvxnmpWqOBNm%2Fuploads%2FLzdw1CUj1tSgeuCPRiTe%2Fimage.png?alt=media&amp;token=52d69277-ebf2-4da1-bb81-9d9967608496" alt=""><figcaption></figcaption></figure>

When finished, click *OK* to save and close the dialog box. The newly created tag will appear in the item list; you can edit any tag by double-clicking it in the list, or by selecting a tag and clicking the *Edit* button on the upper panel. Remove tags by selecting one or more items and then clicking the *Recycle bin* icon on the upper panel.

#### Create Subjects

Creating subjects is similar. To create subjects in Macula Console, switch to the *Events\&Actions* section. Choose *Subjects* on the left, then click the *+New LPR subject* or *+New FR subject* button on the upper panel.

For each subject, the following settings are available:

* **Title**: user-defined tag name that will appear in rules and in Macula Monitor
* **Color**: will also appear in Macula Monitor to mark this subject's recognitions (if the subject is tagged,\
  the subject color will be replaced by tag color)
* **Pattern**: exact plate number or a mask (e.g., D\* to match all plates starting with D and having any length)
* **Mask**: enable this to enter a mask instead of the exact match in the pattern field above

Patterns for masks: use \* for any number of unknown characters, and ? for exactly one unknown character. For example:

* F\* will match all license plates of any length starting with F
* F????? will match all license plates starting with F with a total length of 6 characters
* F?\* means there's F and then one or more unknown characters

Use query **testing** (see below) to check if an expected recognition value is "caught" by the mask.

<figure><img src="https://412599993-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeNXnJx0OpvxnmpWqOBNm%2Fuploads%2FndwZfwmBsS8WpyBtu7Jr%2Fimage.png?alt=media&amp;token=d0e70f9b-1071-4454-af55-184accc38a3b" alt=""><figcaption></figcaption></figure>

When finished, click *OK* to save and close the dialog box. The newly created subject will appear in the item list; you can edit any subject by double-clicking it in the list, or by selecting a subject and clicking the *Edit* button on the upper panel. Remove subjects by selecting one or more items and then clicking the *Recycle bin* button on the upper panel.

#### Add Tag Matching Events

A special event type is available for the built-in tags. This event is triggered **when a recognition result has a matching tag** profile: this may mean one of the required tags is present or absent, and other scenarios.

To add the tag matching event, switch to the *Events* subsection and click *+ New event* button on the upper panel. Set the event type to *Tag match*. The following settings are available:

* **Title**: user-defined event title that will appear in the *E\&A Configurator*
* **Source**: a channel that will serve as a recognition source
* **Tag** **match** **mode**: choose what kind of match you want (see more detailed explanation below)
* **Flags**: choose one or more if you want this tag event to be triggered for specific recognition type
* **Tags**: choose a set of tags that will be used for comparison

Recognition may be LPR or FR and it may run on the camera side or as an external service.

<figure><img src="https://412599993-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeNXnJx0OpvxnmpWqOBNm%2Fuploads%2FKewLKvm3k82hxyLHeF2U%2Fimage.png?alt=media&amp;token=4aaeb399-08d6-4029-9400-8565eb21e778" alt=""><figcaption></figcaption></figure>

Possible tag match modes: event will be triggered if..

* **NoTags**: recognition result does not have any tags (the license plate/subject is not present in the database)
* **Any**: recognition result tag matches one or more tags in the list (at least one)
* **All**: recognition result matches all defined tags (possibly more, but at least those listed)
* **NotAny**: doesn't match any of the specified tags

For example: in the snapshot above, the event is triggered when recognition result matches *Staff*, *VIP*, *Visitors*, or *Guards* tag.

#### Create Rules

As soon as you have created tag-based events, you can match them with any actions to create automated scenarios in the *Event & Action Configurator*.

Rule examples:

* open a gate based on staff car entering (action: change DO state, prerequisite: DO wired to the gate)
* notify operators with a sound (action: send event to client, option: play audio notification, prerequisite: audio notifications enabled on the client side)

#### Test Tags and Subjects

From the *Subjects* section, you can **check if the whole scenario works** for a specific **recognition result**. Simply click the *Test* button on the upper panel, enter the desired parameters, and click *Run*. The test query is not bound to any specific subject entry so it does not matter which item is selected in the item list.

The test validates if the entered recognition value has any matching subjects and, therefore, tags, and also checks if it triggers any events. Events are only checked if there are active rules using these events!

<figure><img src="https://412599993-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeNXnJx0OpvxnmpWqOBNm%2Fuploads%2FzF6jTgtRaQ4pZ7bpVLE9%2Fimage.png?alt=media&amp;token=a019a002-06e6-44b7-87e8-7d5e49d193aa" alt=""><figcaption></figcaption></figure>

As an example, let's see the test results for the test above. The dialog box with the results will have several tabs.

In the *Subjects* tab, all matching **subjects** will be listed. In the example here, E-plate matches the recognition result because this subject is defined as a mask WUL\*, matching any license plate starting with WUL.

<figure><img src="https://412599993-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeNXnJx0OpvxnmpWqOBNm%2Fuploads%2FoNTSd5ijjsCcCx9pqKxb%2Fimage.png?alt=media&amp;token=18c6ca2d-bece-4cf2-8775-46b43cf7cc4b" alt=""><figcaption></figcaption></figure>

In the *Tags* tab, all matching **tags** will be listed with their corresponding colors.

<figure><img src="https://412599993-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeNXnJx0OpvxnmpWqOBNm%2Fuploads%2F84sMTdY7mpfnxn2lZ66o%2Fimage.png?alt=media&amp;token=950ef133-942e-4578-8d97-d6b36c1184db" alt=""><figcaption></figcaption></figure>

Finally, in the *Events* tab, you will see, which **events** would be triggered by the test pattern.

<figure><img src="https://412599993-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeNXnJx0OpvxnmpWqOBNm%2Fuploads%2F963xeplGKYIZtDobbvu2%2Fimage.png?alt=media&amp;token=296fce31-976d-42d8-90ed-ad360c3c0202" alt=""><figcaption></figcaption></figure>

Note that the event list will be empty if there exist some relevant events but there are no rules using them!
