SAFR supports badge (AprilTag) detection. You can combine this feature with face recognition to get additional reliability at identification.

For example, some organizations may need zero-false positive identification. 

This article describe how to configure Ares for Face + Badge authentication to enhance security.


We will use badges as 2nd factor. Users will recognize face and present badge.  In this use case, we assume a user will have a badge that is a combination of 2 or more badges in order to allow enough unique combinations. 


April tags have 587 combinations. 

If you only have 587 employees, you are fine with just 1 tag.

If you have more than 587 employees. you can use multiple tags for each person. If you use 3 tags, you have 34 million of the combination.

In the following example, we will implement 3-badge authentication after face recognition. 


Enable Badge detector

Enable "badge detector" in SAFR/Preferences/Detection for the correct video mode that you want to use. Or set detector.detect-badges to true in the feed config if you use virgo.


Configure Badge number

Add space separated badge numbers in "moniker" parameter of the person. In this example, this person needs to show badges for "38, 86, 62" to authenticate himself. 

NOTE:

  1. This syntax is If using multiple April tags (in this case 3) for each person
  2. Show all April tags at the same time (in this case 3)

Configure SAFR Actions

First you need to define "nFactorDef". You can define the name of this nFactor definition, how many badges you use, and actions you want to run when all factor meet.

This example defines 3 factors of moniker. You need 3 correct tag to trigger this nFactorDef. When it gets correct tags, it executes defined actions.
"hello.py" is a simple script which writes #D (personId) to hello.log.


Next you need to define a rule to start nFactor test. In this example we start the nFactor process for events with personId, moniker.

Note that we use @nFactorStart action designate nFactorDef named "unlock".

This rule also print message "Please show your badge." to the client's screen.



Then you need the second rule.

This rule is executed when ares gets "tag" type event. It runs @nFactorResolve action to resolve which tag it received.

We use conditionalReply here to get the response of @nFactorResolve. If @nFactorResolve action returns -5, then it means the tags (badge numbers) are not matched to the moniker values defined in the person record.

If it returns -4, it's too late to show tags. The person need to start from the face recognition.

If the all factor (tags) matched to the defined moniker values, @nFactorResolve returns 0, and start the action defined in the nFactorDef "unlock".


Please see the following link for more details about the response value from @nFactorResolve.

https://docs.real.com/products/lwp/SAFRActions.config.html#N-factorActions


Please refer to the attached file to see complete SAFRActions.config example.


Let's Test

Prepair the printed aprilTag image for  "38, 86, 62". Here is the example.


Enroll your face to SAFR, and set "38 86 62" in moniker.

Open the Camera Feed Analyzer, and show your face. Then, SAFR prints message "Please show your badge.". Show the printed tag image to the camera. SAFR detects the tags immediately, and print "Badge verified." message.


Next, show your face again, and show wrong badge after the prompt. SAFR will print "Badge not matched" message.

Here is the "wrong" badge example.



  1. How this works:
    1. Check Response codes for nFactorResolve action
    2. If you get value >1, that means so far you have successfully matched all badges but you are not done. For example, if value is 2, that means you have 1 successful match so far.
    3. If you get 0 back, that means all badges matched the person record (uniquely)
    4. If you get one of the negative values, then it means the corresponding error.
  2. ares.log:
    1. Listening for events...--> 2022-02-23 08:28:59 1.75sec id: 8853a497-6171-4ef7-b0fa-210bda15a3cd HDBJ1-ICT-L0004 Logitech BRIO admin william zhang m 36 -> @nFactorStart unlock
      <-- 2022-02-23 08:29:01 Reply true 0.0 Please show your Tag
      --> 2022-02-23 08:29:03 0.24sec id: a42c5b74-b0d9-4a8e-92fe-3ac2d3c15d0d HDBJ1-ICT-L0004 Logitech BRIO -> @nFactorResolve unlock moniker|38
      nFactorResolve: 2
      --> 2022-02-23 08:29:03 0.50sec id: 1acce953-88d7-40fa-97f5-d038c845d087 HDBJ1-ICT-L0004 Logitech BRIO -> @nFactorResolve unlock moniker|62
      nFactorResolve: 1
      --> 2022-02-23 08:29:03 0.50sec id: 77538907-b26f-4666-a51c-7c3b636f5b65 HDBJ1-ICT-L0004 Logitech BRIO -> @nFactorResolve unlock moniker|86
      python C:\\ProgramData\\RealNetworks\\SAFR\\ares\\config\\relay-lcus.py -p COM3: returned: 0
      nFactorResolve: 0 python C:\\ProgramData\\RealNetworks\\SAFR\\ares\\config\\relay-lcus.py -p COM3;


Appendix: How to create AprilTag badges

The attached file, cattags.tgz contains a small script to create badge images which include any number of AprilTag.

To create a badge of (10, 231, 509), run the script with following argument.


$ python3 ./cattags.py -o 10-231-509.png 10 231 509


Then you will get following image.