Rust is one of the newest kid on the block in the modern programming languages. We tried to take advantage of its great features by using it in an Image Recognition blueprint project. This project can be traded with any existing security system deployed at any organization. Hawk uses AWS services integrated with Rust.
Starting with Rust
Rust is blazingly fast and memory-efficient: with no runtime or garbage collector, it can power performance-critical services, run on embedded devices, and easily integrate with other languages.
Rust’s rich type system and ownership model guarantee memory-safety and thread-safety — and enable you to eliminate many classes of bugs at compile-time.
Rust has great documentation, a friendly compiler with useful error messages, and top-notch tooling — an integrated package manager and build tool, smart multi-editor support with auto-completion and type inspections, an auto-formatted, and more.
Hawk uses 2 way authentication process
- RFID authentication
- Image authentication
The basic flow of the project includes authenticating the RFID of an employee and then the image.
If the RFID is known to the system, the image recognizer will be triggered. If the image matches with the RFID card owner, the system will respond in the affirmation.
You might be thinking, how do all these things stack up to give us the desired results? Don’t worry, we will be discussing that in our next segment.
AWS S3 Bucket
Firstly, we set up two S3 Buckets (AWS service to store data). The first one stores the reference images of employees (Reference_Images) and the other one all the clicked images(Clicked_Images).
This project uses S3 Bucket for storing the images of all the employees of the organization. As soon as the system passes the first authentication process i.e if the card is a valid RFID card, the clicked image is sent to the Clicked_Images bucket.
Now, comes the AWS Lambda (Another AWS Service).
AWS Lambda Function
AWS Lambda stores a function in Java. It accepts the clicked images from the Rust Application and the Employee code from the RFID Card. It then fetches the employee’s image from the Reference_Image bucket. Both the images are sent to the Image Rekognition for Recognition process.
AWS Rekognition is an AWS service that helps compare two images and get a similarity score. Hawk uses CompareFace API that returns a similarity score back to Rust as a response.
For achieving our goal of faster response, the project is built using futures. By using futures, we make sure that the two tasks – hitting the API Gateway and uploading the clicked image to S3 Bucket, are done asynchronously. This enables the user to get the response from the API Gateway in 1-2 seconds.
Dockerizing Rust Application
Docker is an open source program that performs OS-level virtualization. It was first released in 2013 and is developed by Docker Inc. It is the most common and widely used Containerization platform. The Hawk project has been containerized for making it available to build once and run anywhere.
Rust gets the similarity score as a response and the final step is based on the threshold set by the AWS Lambda code i.e 80% in our case. If the returned image similarity is more than 80%, the system accepts you as a verified person.
Thank you for coming this far in the blog. If you have any suggestions for the blog/project, you can surely give your comments.
For more reference and contributing to our open source project Hawk, you can visit here. Here is demo video working of Dockerized Hawk Application on a Linux machine.