C# EF-45 Iris Recognition Terminal Getting Started Guide



Iris Recognition Statistics From Tractia
Iris Recognition Analytics by Tractica

Biometric Devices are being used extensively in many corporations through out the world these days. They are widely used in various fields like social insurance, public security, time attendance, fingerprint encryption, embedded systems and many others as a form of user authentication, verification and attendance.

The CMITECH EF-45 is a similar type of biometric device, which supports iris recognition including facial recognition.

This blog intends to help C# developers to successfully integrate an ES-45 Iris terminal into their application and provide basic guidelines on how the enrollment and verification works from a developers perspective.

Device Specifications

EF-45 is a dual iris recognition system which employs “deep learning” face detection algorithm for faster and smoother operation. The system has an extended capture range of 35-45 cm which captures high quality face images simultaneously along with iris image.

EF 45 Iris Terminal

Model : CMITECH EF-45
CPU : ARM Cortex A9 quad-core processor
Memory : 8GB flash + 5GB RAM
Log Capacity : 2,000,000
Iris Capacity : 10,000
Network Interface : 10/100 Base-T Ethernet (RJ45 connector)
Optional : Wifi 802.11bgn

Iris Recognition

The iris is a flat, colored (typically blue, green or brown) area, ring-shaped membrane behind the cornea of the eye, with an adjustable circular opening (pupil) in the center. Its structure remains stable throughout life.

Due to its stability and uniqueness with each individual, it serves as a good way to establish a persons identity.

The iris recognition utilizes this unique feature of the eye as a way to identify and distinguish individuals via various advanced pattern recognition techniques based on high-resolution and distortion-free images of the irises.

Iris recognition

Setting up the Device

The C# based SDK that comes with the EF-45 device enables a Windows PC to interacts with the device via an Ethernet cable using C# APIs.

Primary Setup

The primary setup that needs to be done in order to communicate with the device would be to simply connect with the device via an Ethernet cable and assign an IP address to the device.

The IP address can be setup from Settings ⇒ Network ⇒ TCP/IP.

Ef-45 Connected via Ethernet
EF-45 Device connected via Ethernet
Application Setup

The main library of the CSharp SDK is CMITech.UMXClient.dll.

You need to start by adding a reference to this dll in your Visual Studio .Net project . To add a reference in your project :

Right click your project in VS ⇒ Add ⇒ Reference  ⇒  Browse ⇒  Select ‘CMITech.UMXClient.dll‘.

This article focuses on demonstrating how to properly use the CMITech.UMXClient.dll to interact with the device via a .Net application.

Lets start ….

The Basic Workflow

The overall work to be done via the C# SDK can be summarized into a few steps that are simplified by the following image:

EF-45 Workflow

Using The SDK

The implementation of the SDK has been broken down into small code snippets for a better understanding. The interfaces can be accessed by including the CMITech.UMXClient namespace which is provided by the CMITech.UMXClient.dll that we had referenced previously.

Intialize and Connect

This is the point where we try to establish a connection with the device and initialize all the necessary events.

The Client mainly requires an IP address and an optional serial number. The serial number can be made a better use of if you are working with multiple EF-45 devices and you want to recognize each device properly.

public async void Connect()
    string ipAddress = "";
    string serialNumber = string.Empty;
    bool checkSerialEnabled = false;

    CMITech.UMXClient.Client _client = new CMITech.UMXClient.Client(ipAddress, serialNumber, checkSerialEnabled);


    // Connecting for the first time
    if (_client == null && !_client.IsConnected())
        System.Threading.Tasks.Task<bool> connectionTask = System.Threading.Tasks.Task.Run(() => _client.Connect());
        bool isConnected = await connectionTask;

        if (isConnected)
            // Get Information from device
            string deviceVersion = _client.GetVersion();

            // You can now successfully interact with the device

            // Get current devic mode
            CMITech.UMXClient.Client.UMXMode mode = _client.GetMode();


Force Connection

In case, If the device was previously initialized and we cannot somehow connect to the device due to various factors like the device currently being in use, we might have to force a connection to the device.

public async void ForceConnect()

    // If the device was initialized, but still can`t make a connection
    if (_client != null && !_client.IsConnected())
        if (_client.StealConnect())
            // Get current devic mode
            CMITech.UMXClient.Client.UMXMode mode = _client.GetMode();
The Device Events
The device provides 10 event handlers. The commonly used one are as follows :
 private void InitializeEvents()
     _client.CaptureCompleted += new Client.CaptureCompletedEventHandler(_client_CaptureCompleted);
     _client.CaptureTimedOut += new Client.CaptureTimedOutEventHandler(_client_CaptureTimedOut);
     _client.CaptureError += new Client.CaptureErrorEventHandler(_client_CaptureError);
     _client.MatchLog += new Client.MatchLogEventHandler(_client_MatchLog);
     _client.MatchData += new Client.MatchDataEventHandler(_client_MatchData);
     _client.PreviewImage += new Client.PreviewImageEventHandler(_client_PreviewImage);
Switch Modes

The EF-45 device can be set to work in two modes –

  1. Slave mode / Enrollment mode
  2. Master mode / Recognition mode

Switching between the enrollment and recognition mode is all about setting the device modes to either Recog or Slave.

private void SwitchDeviceMode()
    Client.UMXMode previousMode = _client.GetMode();

    switch (previousMode)
        case Client.UMXMode.Slave:

        case Client.UMXMode.Recog:


The Enroll Mode
Once the device is set to the enrollment mode, you can start the enrollment process which is a 4 step process –
  1. Start Capturing
  2. Acquire biometric template on Capture Complete
  3. Stop Capturing
  4. Enroll the User along with user information
Start Capturing :
private async void StartEnrollment()

    double timeOut = 60;
    bool faceMode = false; 
    bool glassesMode = false;
    bool bothEyeMode = false;
    bool eitherEyeMode = true;
    bool faceFullResolution = false;

    Task captureTask = Task.Run(() =>
        _client.StartCapture(timeOut, faceMode, glassesMode, bothEyeMode, eitherEyeMode, faceFullResolution);

    await captureTask;
Acquire Biometric Template : The biometric template is an object holding the users left and right eye data in a byte array. It can be obtained via the CaptureCompleted event.
private void _client_CaptureCompleted(CaptureCompletedEventArgs captureCompletedEventArgs)
    if (captureCompletedEventArgs.Completed)

        // Obtain the users template
        EnrolTemplate _currentEnrolTemplate= captureCompletedEventArgs.EnrolTemplate;
        // Capture failed
Stop Capturing : You also need to stop the capture once you have successfully obtained a good image.
private void StopEnrollment()
Enroll User To Device : The final enrollment step includes adding up the users personal information like first name, last name and a unique user id to distinguish the user along with his biometric template.
public void AddUser()

    string userID = "11111111";
    string firstName = "John";
    string lastName = "Doe";

    Subject subject = new Subject();
    subject.AccessAllowed = true;
    subject.FirstName = firstName;
    subject.LastName = lastName; // Required
    subject.EnrolTemplate = _currentEnrolTemplate;
    subject.SubjectUID = userID;

    subject.WiegandSite = -1;
    subject.WiegandFacility = -1;
    subject.WiegandCode = -1;


    UserInfo userInfo = new UserInfo();
    userInfo.UUID = userID;
    userInfo.Card = ""; /* Card CSN : 9A 99 1F 3E ...*/
    userInfo.Pin = "";
    userInfo.Admin = 0;
    userInfo.GroupIndex = 0;
    userInfo.ByPassCard = 0;
    userInfo.Indivisual = 0;


Saving The Template To Database

The enroll template is a combination of the users left and right eyes biometric data in the form of bite arrays as shown below :

public class EnrolTemplate
    public EnrolTemplate(byte[] leftEyeTemplate, byte[] rightEyeTemplate);

    public byte[] LeftEyeTemplate { get; set; }
    public byte[] RightEyeTemplate { get; set; }

Saving the template to the database, retrieve it and upload it to the device again can be quite troublesome if the biometric data is in such a form.

Here is a simple approach that I have implemented to encode and decode the template to perform back and forth transmission from the device to some other source.

public static string PreText = "UMXEF45";
public static string Splitter = "#######################";

// Encoding the template
public static string EnrollTemplateToEncodedString(EnrolTemplate enrollTemplate)
    string data1 = Convert.ToBase64String(enrollTemplate.LeftEyeTemplate);
    string data2 = Convert.ToBase64String(enrollTemplate.RightEyeTemplate);

    StringBuilder sb = new StringBuilder();

    return sb.ToString();

// Decoding the template
public static EnrolTemplate EncodedStringToEnrollTemplate(string data)

        string encodedString = data.Trim();
        if (!string.IsNullOrEmpty(encodedString))
            string splitter = Splitter;
            string[] content = data.Split(new string[] { Splitter }, StringSplitOptions.None);

            if (content != null)
                if (content[0] != PreText) throw new Exception("Invalid template.");

                byte[] leftEyeTemplate = Convert.FromBase64String(content[1]);
                byte[] rightEyeTemplate = Convert.FromBase64String(content[2]);

                return new EnrolTemplate(leftEyeTemplate, rightEyeTemplate);
            else return null;
            return null;
        return null;

The PreText is a unique ID to identify that the given template is an EF-45 template and not some other template like a fingerprint or facial recognition which I had in my case.

Head over to GitHub and grab a copy if you wish to explore the full code.

Here is a quick demo if you want to see if in action.

Go Beyond the frontiers of yourself. Peace !!!

EF-45 Demo

You may also like...

1 Response

  1. Muhgammad Ahsan says:

    can i get code for iris recognition

Leave a Reply

Your email address will not be published. Required fields are marked *