Для корректной работы необходимо убедиться в том, что в папке /home/promobot/ существует папка scans. Если она отсутствует, то необходимо ее создать под пользователем promobot.


Работа со сканером паспортов Regula осуществляется по websocket.

Подключение производится по адресу ws://192.168.250.91:5680/


При корректно подключенном устройстве после подключения по ws придет сообщение вида:

{status = -51, description = "Document not detected"}

Порядок сканирования и распознавания документов

  1. scan - запуск сканирования на устройстве. Если устройство исправно и подключено, то метод последовательно возвращает следующие статусы:


    {status = 1, description = "Scanner successfully enabled"}


    {status = 2, description = "Starting scanning"}


    {status = 3, description = "Scanning finish"}


    {status = 4, description = "Trustability checking started"}


    {status = 5, description = "Trustability checking finish"}


    При завершении всех этапов сканирования и распознавания документа, придет сообщение вида:

    {
     "Scan_White":"/home/promobot/scans/Scan_1.jpg",
     "Scan_Photo":"/home/promobot/scans/Scan_Photo.jpg",
     "ft_Issuing_State_Code_VISUAL":"RUS",
     "ft_Document_Number_VISUAL":"5555555555",
     "ft_Date_of_Birth_VISUAL":"01.01.1990",
     "ft_Place_of_Birth(1049)_VISUAL":"ГОР. ПЕРМЬ",
     "ft_Place_of_Birth_VISUAL":"GOR.PERM",
     "ft_Surname(1049)_VISUAL":"ЛАЛЕТИН",
     "ft_Surname_VISUAL":"LALETIN",
     "ft_Given_Names(1049)_VISUAL":"ДМИТРИЙ",
     "ft_Given_Names_VISUAL":"DMITRII",
     "ft_Nationality_VISUAL":"Russian Federation",
     "ft_Sex(1049)_VISUAL":"МУЖ",
     "ft_Sex_VISUAL":"M",
     "ft_Surname_And_Given_Names(1049)_VISUAL":"ЛАЛЕТИН ДМИТРИЙ АНДРЕЕВИЧ",
     "ft_Surname_And_Given_Names_VISUAL":"LALETIN DMITRII ANDREEVICH",
     "ft_Nationality_Code_VISUAL":"RUS",
     "ft_Issuing_State_Name_VISUAL":"Russian Federation",
     "ft_Document_Series_VISUAL":"5555",
     "ft_Fathers_Name(1049)_VISUAL":"АНДРЕЕВИЧ",
     "ft_Fathers_Name_VISUAL":"ANDREEVICH",
     "ft_Authority_RUS(1049)_VISUAL":"Пермский край",
     "ft_Booklet_Number_VISUAL":"555555",
     "ft_Age_VISUAL":"26",
     "status":100,
     "status_description":"finish",
     "Doc_Name":"Russian Federation - Passport (2006)",
     "Processing_Time":"03.962",
     "UV_Luminescence":"ch_Check_Error"
    }

    где

     "Scan_White" - путь до изображения с белым сканом,
     "Scan_Photo" - путь до изображения с фотографией владельца паспорта,
     "ft_Issuing_State_Code_VISUAL" - страна, в которой произведена выдача паспорта,
     "ft_Document_Number_VISUAL" - номер документа,
     "ft_Date_of_Birth_VISUAL" - дата рождения,
     "ft_Place_of_Birth(1049)_VISUAL" - место рождения,
     "ft_Place_of_Birth_VISUAL" - место рождения,
     "ft_Surname(1049)_VISUAL" - фамилия,
     "ft_Surname_VISUAL" - фамилия,
     "ft_Given_Names(1049)_VISUAL" - имя,
     "ft_Given_Names_VISUAL" - имя,
     "ft_Nationality_VISUAL" - национальность,
     "ft_Sex(1049)_VISUAL" - пол,
     "ft_Sex_VISUAL" - пол,
     "ft_Surname_And_Given_Names(1049)_VISUAL" - ФИО,
     "ft_Surname_And_Given_Names_VISUAL" - ФИО,
     "ft_Nationality_Code_VISUAL" - код страны,
     "ft_Issuing_State_Name_VISUAL" - название страны, выдавшей документ,
     "ft_Document_Series_VISUAL" - серия документа,
     "ft_Fathers_Name(1049)_VISUAL" - отчество,
     "ft_Fathers_Name_VISUAL" - отчество,
     "ft_Authority_RUS(1049)_VISUAL" - область/край,
     "ft_Booklet_Number_VISUAL" - доподлинно неизвестно,
     "ft_Age_VISUAL" - возраст,
     "status" - статус в результате сканирования и распознавания (100 - успешно, -100 - не успешно),
     "status_description" - описание статуса,
     "Doc_Name" - тип документа,
     "Processing_Time" - время, затраченное на сканирование и распознавание (в секундах),
     "UV_Luminescence" - статус проверки подлинности UV


    У возвращаемых полей могут быть 2 вида постфикса:

    _VISUAL - это поля, которые были распознаны в визуальной зоне документа

    _MRZ - это поля, которые были распознаны в машиночитаемой зоне документа



  2. killThreads - принудительное завершение потоков распознавания. Необходим для того, чтобы завершить зависшие потоки распознавания. Реализован для того, чтобы восстановить работу софта после "отпадывания сканера по питанию". Такое происходит периодически, проявляется долгим сканированием и постоянно включенными диодами освещения зоны документа. В программной реализации такое поведение легко отследить по статусам сканирования. Если статус не меняется в течение ~3 секунд, то необходимо перезагрузить сканер по питанию. После успешного выполнения будет получено сообщение следующего вида:

    {status = 311, description = "Zombie thread finished"}


  3. deleteScans - удаляет полученные сканы из файловой системы (потребуется для 152 ФЗ). После успешного выполнения вернет:

    {status = 303, description = "Files deleted"}


  4. powerReset - ребут по питанию (через плату USB). На текущий момент возможно 2 варианта ребута. Через отдельную плату с контроллером, которая подключается в материнскую плату с Windows, а также с помощью выключения/включения питания на виндовом хабе мейна. При успешном выполнении вернет последовательно:

    {"status":614,"description":"Power disabled -> 00 00 55 \r\n<- 01 A0 A0 \r\n"}


    {"status":615,"description":"Power enabled -> 01 00 55 \r\n<- 01 A0 A0 \r\n"}

    Описание статусов

    Статус в JSONОписание в JSONСообщениеОписание
    1Scanner successfully enabled{status = 1, description = "Scanner successfully enabled"}Успешная инициализация сканера
    -1Scanner not connected{status = -1, description = "Scanner not connected"}Сканер не подключен
    311Zombie thread finished{status = 311, description = "Zombie thread finished"}Зависшие потоки успешно уничтожены (возвращается на killThreads)
    -71Device is inaccessible{status = -71, description = "Device is inaccessible"}Устройство недоступно. Возвращает в случае, когда сканирование производится после отвала по питанию.
    303Files deleted{status = 303, description = "Files deleted"}Файлы удалены
    51Document detected{status = 51, description = "Document detected"}Документ находится на сканере
    -51Document not detected{status = -51, description = "Document not detected"}Документ на сканере отсутствует
    2Starting scanning{status = 2, description = "Starting scanning"}Начало сканирования
    3Scanning finish{status = 3, description = "Scanning finish"}Сканирование завершено
    4Trustability checking started{status = 4, description = "Trustability checking started"}Начало проверки подлинности
    5Trustability checking finish{status = 5, description = "Trustability checking finish"}Проверка подлинности завершена
    100finishБудет содержаться в общем финальном сообщении (см. порядок сканирования и распознавания документа)Сканирование и распознавание документа успешно завершено
    -100Can't recognize fieldsБудет содержаться в общем финальном сообщенииНе удалось распознать документ и поля
    614
    Power disabled -> 00 00 55 \r\n<- 01 A0 A0 \r\n
    {"status":614,"description":"Power disabled -> 00 00 55 \r\n<- 01 A0 A0 \r\n"}
    Питание выключено
    615
    Power enabled -> 01 00 55 \r\n<- 01 A0 A0 \r\n
    {"status":615,"description":"Power enabled -> 01 00 55 \r\n<- 01 A0 A0 \r\n"}
    Питание включено

    Проверка работы сканера на роботе

    Протестировать работу подключенного сканера можно через плагин для браузера Chrome (Websocket Test Client)

    https://chrome.google.com/webstore/detail/websocket-test-client/fgponpodhbmadfljofbimhhlengambbn?hl=ru

    или с помощью консольного клиента wsdump.py


    Порядок проверки через wsdump.py

    1. Загрузить wsdump.py в домашнюю папку пользователя promobot на роботе

    2. Подключиться к роботу по ssh

    3. Выполнить sudo pip3 install websocket-client

    4. Выполнить python3 wsdump.py ws://192.168.250.91:5680

    5. Отправить команду "scan"

    6. Успешное выполнение команды при сканировании без документа на сканере показано ниже на скриншоте

    sudo pip3

    4install websocket-clientsudo pip3 install websocket-client



    Расширенное описание возвращаемых полей при сканировании различных типов документов доступно в приложенном файле (стр. 114).



    Сканер может быть подключен тремя способами:


    1. Реле
    2. Отдельная USB плата
    3. Win хаб мейна
    Для каждого типа подключения используется свой JS-модуль сканирования




You need to make sure that the scans folder exists in /home/promobot/ folder. If it is not, then you need to create it under promobot user.


Working with the Regula passport scanner is carried out via websocket.

Connection is carried out at this address: ws://192.168.250.91:5680/


After connecting via ws, a message like this will appear (if device is correctly connected):

{status = -51, description = "Document not detected"}

How to scan and recognize documents

scan - starts scanning on the device. If the device is working properly and connected, then the method sequentially returns the following statuses:

{status = 1, description = "Scanner successfully enabled"}


{status = 2, description = "Starting scanning"}


{status = 3, description = "Scanning finish"}


{status = 4, description = "Trustability checking started"}


{status = 5, description = "Trustability checking finish"}


Upon completion of all stages of scanning and document recognition, you will receive a message like this:

{
 "Scan_White":"/home/promobot/scans/Scan_1.jpg",
 "Scan_Photo":"/home/promobot/scans/Scan_Photo.jpg",
 "ft_Issuing_State_Code_VISUAL":"RUS",
 "ft_Document_Number_VISUAL":"5555555555",
 "ft_Date_of_Birth_VISUAL":"01.01.1990",
 "ft_Place_of_Birth(1049)_VISUAL":"ГОР. ПЕРМЬ",
 "ft_Place_of_Birth_VISUAL":"GOR.PERM",
 "ft_Surname(1049)_VISUAL":"ЛАЛЕТИН",
 "ft_Surname_VISUAL":"LALETIN",
 "ft_Given_Names(1049)_VISUAL":"ДМИТРИЙ",
 "ft_Given_Names_VISUAL":"DMITRII",
 "ft_Nationality_VISUAL":"Russian Federation",
 "ft_Sex(1049)_VISUAL":"МУЖ",
 "ft_Sex_VISUAL":"M",
 "ft_Surname_And_Given_Names(1049)_VISUAL":"ЛАЛЕТИН ДМИТРИЙ АНДРЕЕВИЧ",
 "ft_Surname_And_Given_Names_VISUAL":"LALETIN DMITRII ANDREEVICH",
 "ft_Nationality_Code_VISUAL":"RUS",
 "ft_Issuing_State_Name_VISUAL":"Russian Federation",
 "ft_Document_Series_VISUAL":"5555",
 "ft_Fathers_Name(1049)_VISUAL":"АНДРЕЕВИЧ",
 "ft_Fathers_Name_VISUAL":"ANDREEVICH",
 "ft_Authority_RUS(1049)_VISUAL":"Пермский край",
 "ft_Booklet_Number_VISUAL":"555555",
 "ft_Age_VISUAL":"26",
 "status":100,
 "status_description":"finish",
 "Doc_Name":"Russian Federation - Passport (2006)",
 "Processing_Time":"03.962",
 "UV_Luminescence":"ch_Check_Error"
}

where:

 "Scan_White" - path to image with white scan,
 "Scan_Photo" - path to the photo of passport holder,
 "ft_Issuing_State_Code_VISUAL" - country in which the passport was issued,
 "ft_Document_Number_VISUAL",
 "ft_Date_of_Birth_VISUAL",
 "ft_Place_of_Birth(1049)_VISUAL",
 "ft_Place_of_Birth_VISUAL",
 "ft_Surname(1049)_VISUAL",
 "ft_Surname_VISUAL",
 "ft_Given_Names(1049)_VISUAL",
 "ft_Given_Names_VISUAL",
 "ft_Nationality_VISUAL",
 "ft_Sex(1049)_VISUAL",
 "ft_Sex_VISUAL",
 "ft_Surname_And_Given_Names(1049)_VISUAL",
 "ft_Surname_And_Given_Names_VISUAL",
 "ft_Nationality_Code_VISUAL" - code of the country,
 "ft_Issuing_State_Name_VISUAL" - name of the country that issued the document,
 "ft_Document_Series_VISUAL",
 "ft_Fathers_Name(1049)_VISUAL",
 "ft_Fathers_Name_VISUAL",
 "ft_Authority_RUS(1049)_VISUAL" - region,
 "ft_Booklet_Number_VISUAL" - доподлинно неизвестно,
 "ft_Age_VISUAL",
 "status" - status as a result of scanning and recognition (100 - success, -100 - fail),
 "status_description",
 "Doc_Name" - document type,
 "Processing_Time" - time spent on scanning and recognition (in seconds),
 "UV_Luminescence" - authentication status UV


Returned fields can have 2 types of postfix:

_VISUAL - these are the fields that were recognized in the visual area of the document

_MRZ - these are the fields that were recognized in the machine-readable zone of the document


killThreads - forced termination of recognition threads. This method is useful in order to terminate recognition threads which are not responding. Implemented in order to restore the software after such error as scanner power failure. This kind of error occurs occasionally and shows up as scanning takes a long time and diodes of illumination of the document area constantly switched on. In software implementation, this behavior can be easily discovered by scan statuses. If the status does not change within ~ 3 seconds, then it is necessary to reboot the scanner by power supply. After successful execution, you will receive a message similar to the following:

{status = 311, description = "Zombie thread finished"}


deleteScans - deletes received scans from the file system. Upon successful execution, it will return following kind of message:

{status = 303, description = "Files deleted"}


powerReset - reboot the scanner by power supply (via USB board). At the moment, there are 2 options for reboot. First, via separate controller board that connects to the Windows motherboard, and second by turning off / on the power of Windows Main-board hub.

If successful, it will return sequentially:

{"status":614,"description":"Power disabled -> 00 00 55 \r\n<- 01 A0 A0 \r\n"}


{"status":615,"description":"Power enabled -> 01 00 55 \r\n<- 01 A0 A0 \r\n"}


Status description

JSON StatusJSON DescriptionMessageDescription
1Scanner successfully enabled{status = 1, description = "Scanner successfully enabled"}Scanner initialized successfully
-1Scanner not connected{status = -1, description = "Scanner not connected"}Scanner not connected
311Zombie thread finished{status = 311, description = "Zombie thread finished"}

Not-responding threads have been successfully destroyed (status is returned when killThreads was called)

-71Device is inaccessible{status = -71, description = "Device is inaccessible"}

Device is inaccessible. Returns when scanning is performed after a power failure.

303Files deleted{status = 303, description = "Files deleted"}Files deleted
51Document detected{status = 51, description = "Document detected"}The document is on the scanner
-51Document not detected{status = -51, description = "Document not detected"}No document on scanner
2Starting scanning{status = 2, description = "Starting scanning"}Starting scanning
3Scanning finish{status = 3, description = "Scanning finish"}Scanning finish
4Trustability checking started{status = 4, description = "Trustability checking started"}Trustability checking started
5Trustability checking finish{status = 5, description = "Trustability checking finish"}Trustability checking finish
100finish

Will be contained in the general final message (see How to scan and recognize documents)

Scanning and document recognition completed successfully
-100Can't recognize fieldsWill be contained in the general final messageCould not recognize document and its fields
614
Power disabled -> 00 00 55 \r\n<- 01 A0 A0 \r\n
{"status":614,"description":"Power disabled -> 00 00 55 \r\n<- 01 A0 A0 \r\n"}
Power off
615
Power enabled -> 01 00 55 \r\n<- 01 A0 A0 \r\n
{"status":615,"description":"Power enabled -> 01 00 55 \r\n<- 01 A0 A0 \r\n"}
Power on


Checking the operation of the scanner on the robot

You can test the operation of the connected scanner via Chrome browser plugin (Websocket Test Client)

https://chrome.google.com/webstore/detail/websocket-test-client/fgponpodhbmadfljofbimhhlengambbn?hl=ru

or using a console client wsdump.py

Test algorithm via wsdump.py

1. Place wsdump.py into home repository of promobot user on robot

2. Connect to robot via ssh

3. Run following command in terminal:

sudo pip3 install websocket-client

4. Run following command in terminal:

python3 wsdump.py ws://192.168.250.91:5680

5. Send the scan command

6. The successful execution of the command when scanning without a document on the scanner is shown in the screenshot below

sudo pip3

4install websocket-clientsudo pip3 install websocket-client


An extended description of the fields returned when scanning various types of documents is available in the attached file (p. 114). RUS.


The scanner can be connected in three ways:


1. Relay
2. Separate USB board
3. Windows Main-board hub

Each type of connection uses its own JS-scanning module.