Description and features
The recognition server is installed on a separate (virtual) machine from the iBatyr Monitor server. The server includes several engines that extract data and detect graphical entities in documents.
Recognition server capabilities:
detection of seals on images according to a given pattern: scanned copies, screenshots, photographs of documents with a seal impression;
detection of images of a Russian citizen’s passport: scanned copies, screenshots, photographs of the main page;
facial recognition and creation of alerts based on recognition results;
recognition of large volumes of text, including text from any images (scanned copies, screenshots, photographs) or from container files (for example, pdf or zip format);
work with the most popular image storage formats: png, jpeg, jpg, jpe, pdf.
Server installation
To run the graphical object analyzer, install additional packages:
sudo apt update && sudo apt upgrade
sudo apt install software-properties-common
# установите python3.7
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt install python3.7
sudo apt install python3.7-venv
# установите оставшиеся пакеты
sudo apt install -y libpoppler-cpp0v5 poppler-utils libsm6 tesseract-ocr
Add the iBatyr Monitor repository to the list of system repositories and install the recognition server using apt:
wget -O - https://distr.ibatyr.kz/stable5.06/ibatyr.gpg | sudo apt-key add -
echo "deb https://distr.ibatyr.kz/stable5.06 stable5.06 non-free" | sudo tee /etc/apt/sources.list.d/ibatyr.list
sudo apt update
sudo apt install ibatyr-cpservice
The total package size is about 850 MB - with low Internet speeds, downloading may take a long time.
This completes the software installation.
Server-side configuration iBatyr Monitor
Before setting up the Content Analysis module, enable access to the server API in the iBatyr Monitor server settings:
Go to the main interface in Control Panel → Server Settings:
Select API access allowed.
Check the Value checkbox and click Save. The value of the API access allowed parameter will change to Yes.
In the Policies tab, go to Policies → System Policies → Recognition Server.
Add the details of the machine on which the recognition server is installed to the fields:
Position update step—the number of events that the recognition server processes at one time. The lower this number, the more often the update will occur. The optimal parameter value is 10,000. If the string is empty, the value is also assumed to be 10,000. Do not set values less than 10,000 to avoid increasing the load on the server.
API address—domain name or IP address of the recognition server.
Port—access port to the recognition server. Default is 9090.
Number of cores - must correspond to the number of module server cores.
Status—availability of connection to the server.
Load—load on the recognition server.
Active—turn on/off the recognition server.
Check the Policy is active checkbox and save the changes.
Configuring the Content Analysis module
Connect to the recognition server via SSH. Open the server configuration file in a text editor:
sudo nano /etc/ibatyr/cpservice-config
And specify the parameters:
PORT = 9090
SERVER_ADDR = 'http://192.168.1.x'
SECRET = 'xxxxxxxxxxxxxxxx'
Save the changes and restart the server with the command:
sudo service ibatyr-cpservice restart
Ready! The server is configured.
Content recognition policies
Configured on the iBatyr Monitor server in the web interface.
Image processing time:
Image Format |
Processing time, s |
|---|---|
full HD image without rotation |
5 |
4K image |
20 |
image of stamp, passport, picture in JPEG format |
4-6 |
face recognition |
5—60 |
Content Analysis
In the Filters section, go to the Policies tab, then in the Policies folder, select Content Analysis.
The server recognizes:
text,
speech,
printing,
faces,
Russian Federation passport.
In addition, the following options are available in Content Analysis:
Extract text - saves text content from the Transferred file event.
Archive Scanner - creates the Intercepted File event from intercepted archive files.
Text recognition
Allows you to recognize text in images.
The Properties tab contains text recognition settings:
Built-in OCR / Recognition Server - select a recognition tool. In addition to the recognition server, you can use the built-in OCR. Read more in the article Setting up the OCR module.
Recognition module — recognition engine: Tesseract, a free library for basic OCR, simple and flexible.
Recognize upside down - recognize text on upside down images. The option expands the capabilities, but loads the recognition server.
Language — languages for recognition: Russian, English.
In the Filter tab you can configure a filter for the OCR policy.
The default filter looks like this:
agent_attachedfile@mime:mime=application/pdf
agent_attachedfile@mime:mime=image/jpeg
agent_attachedfile@mime:mime=image/png
agent_attachedfile@mime:mime=image/tiff
agent_attachedfile@extracted:extracted=false
agent_eventtype@default:agent_eventtype=0#Intercepted file
{
"operator": "AND",
"rules": []
}
Stamp recognition
Note
Currently, only round stamps can be searched.
The recognition server finds print images based on specified patterns in documents in jpg, jpe, jpeg, png and pdf formats.
Note
At this time, you can only create one policy per print. If you have multiple stamps, please contact to technical support.
For the policy to work, you will need samples of seals - fragments of images that contain a seal. Surrounding text and signatures do not interfere with recognition. To improve the quality of recognition, use several print samples.
What is important for such samples:
image size - 400x400px;
different degrees of pressure when printing;
slight differences between samples;
absence of defective prints;
placement of seals at different angles.
To create an OCR policy for printing:
Go to the Policies tab to the Policies folder → Content Analysis.
Slide the Seal Recognition switch to the right.
Upload a sample stamp using the file selection button in Selecting images with stamps; wait until the recognized seals have a checkmark in the Status column.
Set a filter for the policy. For example:
Content types – pdf, jpg, png;
Event types - captured files/screenshots.
Note
The policy does not work with empty filters. Don’t skip this step.
Check the Policy active checkbox to activate the policy. The facts found will be available in the Policies that worked section.
False positives
For any pattern recognition policy, there is a possibility of false positives. Most often this happens with seals that have a certain similarity. To reduce the number of false positives, open the iBatyr Monitor server configuration file:
sudo nano /usr/share/ibatyr/settings.py
and change the values of the STAMP_RECOGNITION_THRESHOLD parameter downwards.
False positives are possible when a company or organization has similar seals that differ in department name or division code. In this case, please contact our technical support.
Face recognition
Recognition Server contains the function of recognizing faces in images and screenshots. The recognition result is recorded in the form of a corresponding notification: No face, Own face, Unknown face, Multiple faces. Own and unknown faces are identified by pre-assigned photographs of their owners in the web console.
To enable facial recognition:
Go to the Policies tab, then to the Policies folder → Content Analysis.
Slide the Face Detection switch to the right.
Check the Policy is active checkbox.
Go to the Filter tab, click Event Type and check the box next to Screenshot or captured files.
Click + File, select Content Type and check the image/jpg and image/png checkboxes.
After receiving the first recognition results, match the image to the user for each account:
Select a photo with suitable lighting and a frontal angle from the event table.
Click on the photo and a dialog box will open.
If the face matches the account, answer Yes to the question Face Recognition: This face belongs to user N.
Note
If you answer No, the previously established match will be reset. Use the Close button if you accidentally opened this window or decided not to change anything.
Changes resulting from mapping will only apply to new events. Check that the faces in the images match the computer owners.
Alerts in Constructor for face recognition:
Alert |
Description |
|---|---|
No face |
No faces found. |
Your face |
Face detected. This is the face of the PC owner. |
Unknown person |
Face detected. This person is not in the database. |
Multiple persons |
There are several people in the photo. |
No photo |
The picture is unreadable: darkness, lack of sharpness… |
False positives
False positives or a complete lack of recognition can be caused by turning the head, inappropriate angle of the face, or covering part of the face, for example with a hand. You can influence the recognition result by decreasing the FACE_DETECT_THRESHOLD parameter in /usr/share/ibatyr/settings.py:
FACE_DETECT_THRESHOLD = 0.5
Note
If necessary, the parameter can be reduced to 0.4, but it should be taken into account that the lower the value, the fewer recognitions.
Configuring the types of processed files
To configure the types of files processed, add the following entry to /usr/share/ibatyr/settings.py:
FACES_TYPES = ( "Screenshot", "InterceptedFile")
and restart iBatyr Monitor:
sudo service ibatyr restart
Additional features of the face recognition function:
There is a check for blurred sharpness, darkness and unreadable images. If the No photo alert frequently causes unwanted triggers, contact technical support.
For correct recognition, the face area must be at least 2.5% of the image area.
When recognizing several faces, their sizes should not differ from each other by more than two times. This will prevent triggering on distant faces accidentally caught in the frame.
Faces should not overlap. The center of the smaller face must not lie within the frame of the larger one, otherwise the smaller face is ignored.
The same face from the database cannot be recognized in an image more than once. Excess triggers are ignored.
The face recognition algorithm is HOG.
Russian passport
The recognition server allows you to recognize the spread of the main page of a Russian passport in PDF files, images in png and jpeg formats, and screenshots.
Spread of the main page of the passport - a page with information about the issuance of the passport and a page with the owner’s photo.
To enable Russian passport search:
Go to the Policies tab, then to the Policies folder → Content Analysis.
Slide the Russian Federation Passport switch to the right, a window will open.
Go to the Filter tab and select filter criteria: event type, content type, etc.
As a result, events that meet the established criteria will appear in Triggered Policies.
False positives
During recognition, false positives may appear when an event appears in Triggered policies, but does not contain images with a passport. The likelihood of such events is very low. Please forward such images to your manager or technical support.
If there are a lot of false positives, connect to the recognition server and in the file /etc/ibatyr/cpservice-config add the line PASSPORT_THRESHOLD:
PASSPORT_THRESHOLD = 0.7
Logs
Recognition server
The log is located at: /var/log/ibatyr-cpservice.log.
Request and its options:
2020-09-10 12:19:39,065 [DEBUG] cp_server:112 Request for 2020_09_10/ae4cd000abaecdaf46eec3d3ac90750d327e688a.jpe : text_extraction face_detection
Where text_extraction face_detection are optional parameters, text extraction and face recognition.
Processing result:
2020-09-10 12:24:20,125 [DEBUG] cp_server:127 Response for 2020_09_10/9ade404783b02bff8741ed1632ffbf63d883c64e.jpe done in 0:01:04.814513: "document_class": undetected, "face": {'size': {'width': 640, 'height': 480}, 'bounds': [{'top': 306, 'right': 381, 'bottom': 476, 'left': 211}], 'vectors': '...'}, "extracted_text": "
The command specifies the document type, samples of the result of face processing and text extraction, and the time spent on processing.
iBatyr Monitor Server
The log is located at /var/log/ibatyr/content_processing.log.
The error message [ERROR] content_processing:420 API error: [Errno28] No space left on device indicates that the server does not have enough RAM disk. The error occurs when working with large files or a large number of cores on the server. To fix it, increase the disk memory size.
To increase memory, add the following line to /etc/ibatyr/cpservice-config:
RAMDISK_SIZE = '5G'
Note
The recommended value for RAMDISK_SIZE can be calculated as follows: multiply the maximum file size per processing by the number of server cores. The default is 500 MB.