Skip to main content

Pattern Matching Web Service for image recognition

About Us
Published by admin
19 January 2021
146

Introduction

This service is a software program written in C++ that can be used as a third party part of any different project with a very strict purpose - image recognition.

The web service is available over the internet and uses a standardized JSON messaging system. The program invokes pattern-finding calculations of the images that are received in the request message, then answers them with the output of these calculations. The program has base64 encode/decode module to perform picture uploading operations.

Usability case - upload photos from some source (Instagram, etc.), find some logo in all of these photos and output data sent to salesforce, do some data processing there. The next step is to give this data to the client.

Software solution

Summary:

Program architecture defined by the 3 modules. The first main module responsible for web service functionality, receiving and answering to requests. Second module responsible for picture processing and detection of one picture in another. And the third module stands for the authorization process.

1.Web Service module - written with the usage of the cpprestsdk lib. Post request implementation, define the functionality that is executed by a request of the predefined format.

Defined error handling - most obvious errors would be caught and displayed in request answers.

2.Picture detection module - has functionality that compares incoming pictures in a user-defined way. Base64 encoding/decoding functions. Also defined functions that calculate SSIM (structural similarity index measure) and PNR (peak signal-to-noise ratio) 

3.Authorization module - a module that defines the authentication process with token gathering scheme. Token generated with cryptopp lib and needed to execute all other server functions.

Source code

Inbound channel service:

pattern-matching-web-services-1

Pic.1 Login request test

 

pattern-matching-web-services-2

Pic.2 Wrong credits test

 

pattern-matching-web-services-3

Pic.3 Wrong token request

 

pattern-matching-web-services-4

Pic.4 Uploading main image

 

pattern-matching-web-services-5

Pic.5 Finding pattern in the main image(identical pattern)

 

pattern-matching-web-services-6

Pic.6 Finding pattern in the main image(different pattern)
 

Summary

Such projects reside on some cloud services (such as Amazon AWS) and make possible different workflows and extensions of the Salesforce platform. In our case, by means of the service, you can search for patterns in pictures and analyze the received data within Salesforce.

Next steps

1. Improve security by conducting pentest of the service;

2. Future development:

The next steps in the app development will provide extended functionality of the pattern matching itself, and a possibility for the user to define which images need to be processed (All vs All patterns, All main vs 1 Pattern, 1 Main vs All patterns). 

3. Develop ways of processing data under heavy load;

4. Change the pattern matching method for a more advanced one.

References

Link to cpprestsdk documentation

Link to cryptopp documentation


Andrey Ivashkin
Software Engineer

We have available resources to start working on your project within 5 business days

1 UX Designer

1 Admin

2 QA engineers

1 Consultant