Quick Integration Instructions
1. Confirm project requirements:
-1.1 What type of credentials to identify.
-1.2 Whether to read the ID chip.
-1.3 Whether to read the passport chip.
-1.4 Whether the purchased equipment supports reading the first two types of chip functions.
2. What should I have to start?
The document identification system consists of three parts:
-2.1 Passport scanner device
-2.2 Authorization file
-2.3 Document identification core dll (in the demo software installation path)
Make sure you have above three parts at the time of initialization.
Important files:
After installing setup.exe in the SDK, there are documents path is as follows:
C: \ Program Files (x86) \ Passport Reader \ Samples
C: \ Program Files (x86) \ Passport Reader \ HelpDoc
C: \ Program Files (x86) \ Passport Reader \ HelpDoc
3. Recognition method:
-3.1 Automatic identification: to add the ID type to automatic identification list.
After placing the ID in the device, the ID type will be automatically identified.
It is suitable for unattended scenarios such as gates and self-service machines, or scenarios where you want to simplify operations.
-3.2 Manual identification: Some application devices support only manual identification, such operate requires customized buttons configuration. The operate buttons are bound to the corresponding ID type MainID parameter, which is identified during identification. The OCR core will identify according to this type of document. It is suitable for hotel front desks and bank counters.
4. How do I get the identified text fields?
-4.1 For the Websocket integration method, the recognition result is placed in a string, which can be split by a separator to get the result you want.
-4.2 For CS, the text fields of each certificate are different, and the field index will be given in the document (refer to the Document Identification SDK Development Manual 3.3), the required field values and field names can be obtained according to the index.
5. Integrated main points:
-5.1 BS Framework:
BS Please use websocket for integration, quick and easy!
–5.1.1. Install
Find websocket package, decompress it, Copy “IDCardLicense.dat and UserId.txt” into the authorityFiles folder, and then install.After installation finished,there will be a websocket service in the service list, please check websocket installation manual for further detail.
Here we talk about the development part: BS integrated recognition device is different from other BS systems. The project only needs to integrate one page. All computers connected to the device access this page. Then Websocket service installed locally on the computer will return recognition result to this page. We have demo page for your evaluate.
–5.1.2. Integrated
Follow with example page,the main process code as:
① Establish a link. This link is the address of a fixed service and cannot be changed.
var readyState = new array(“on connection”, “connection established”, “Closing connection”, “Close connection”);
var host = “wss://127.0.0.1:90/echo/”;
websocket = new WebSocket(host);
websocket.onopen = function(){//statusbar.innerHTML = readyState[websocket.readyState];
var statusbar = document.getElementById(“statusbar”);
statusbar.value = readyState[websocket.readyState];
② Send various identification instructions code.
websocket.send(“10000”);//Send automatic identification instruction, When set identify certificate automatically, send “10000” one time only.
websocket.send(“18201″+myselect.options[myindex].value);//Send manual identification command. When set manually identify,send 18201 + Certificate Type ID (Section 3.1 of SDK Development Manual), send one time only.
Common commands:
websocket.send(“181026150”);//Passport chip content read setting command.
websocket.send(“1810331”);//Set save picture feature, 18103 + 31 means all pictures are saved.
websocket.send(“181041”);//Whether to recognize the reading area.
websocket.send(“181061”);//Whether to return base64 format pictures.
websocket.send(“1810731”);//Which pictures return base64 format, all pictures are returned by default.
③ Get the return result
function AutoPhotoAndRecog()
{
var msg=document.getElementById(“devicetype”);
var str = msg.value;
if(str=”scanner”){
setTimeout(“getInformation()”,2000); //If it is scanner, delay 2 seconds.
}else{
getInformation();
}
}
function getInformation()
{
if(websocket != null)//Check if websoket has read information,if there is, return to the page.
{
websocket.send(“11112”);
}
}
setInterval(“AutoPhotoAndRecog()”, 1000);//Check if information is returned every second.
④ Get the result string (all the information returned is given as a string, you need to split it yourself)
websocket.onmessage = function(event){
var str = event.dat;
var strsub = str;
Get ID picture’s base64 code and split:
for(var i = 1; i<len; i++)//
{
if(seek[i].length>2)
{
var strType = seek[i][0] + seek[i][1];
seek[i] = seek[i].substr(2);
if(strType == “01”)//White light.
{
seek[i] =”data:image/jpeg;base64,” + seek[i];
}
else if(strType == “02”)//Infrared light.
{
seek[i] =”data:image/jpeg;base64,” + seek[i];
}
else if(strType == “04”)//Ultraviolet light.
{
seek[i] =”data:image/jpeg;base64,” + seek[i];
}
else if(strType == “08”)//Layout avatar.
{
strhead = seek[i];
seek[i] =”data:image/jpeg;base64,” + seek[i];
}
else if(strType == “16”)//Chip avatar.
{
strChipHead = seek[i];
seek[i] =”data:image/jpeg;base64,” + seek[i];
}//Alert(seek[i]);
}
⑤ Disconnect.
//Disconnect when closing page.
window.onclose = function()
{
websocket.close();
}
//Disconnect one time when refreshing the page.
window.onbeforeunload=function()
{
websocket.close();
}
Tip:
If your project time is urgent,directly copy and paste all the functions from sample code even there are somme do not related to the page format you need, it will not effect the application. Such integration make project goes fast but still stable.
-5.2 CS Framework
Find the routine of the programming language you want to use, identify + read the passport chip by default C: \ Program Files (x86) \ Passport Reader \ Samples \ OCR & Contactless Chip Reading
We provide various languages sample, C ++, C #, VB, Delphi.
Test in accordance with document <Detailed Use of ID Document SDK Sample> :
–5.2.1 Like other CS programs, the integration of C ++, C #, VB, and Delphi all need to import the dll library first, and running without importing the library will report an error.
—5.2.2 The core library consists of two sets of cores:
—5.2.2.1: the ID chip part(for chinese ID;
—5.2.2.2: OCR + passport reader core.
They have different routines sample, but their core is put together. You can find the test in the path given above, and then follow the main process development below.
–5.2.3 The following process must be included in the development, each step must be indispensable, otherwise there will be problems when the program is finished.
The following uses C ++ as an example:
—5.2.3.1 The main process of reading Chinese ID card chip (refer to the second-generation chinese ID card reader development manual for the interface):
① Loading DLL:
//Load dynamic library: sdtapi.dll, WltRS.dll.
bool CNIDapiDlg::LoadDLL(void)
{
{Clog log(__FUNCTION__);}
m_hNIDapi=LoadLibrary(_T(“sdtapi.dll”));
if(!m_hNIDapi)
{
AfxMessageBox(_T(”Loading DLL fail”));
return false;
}
② Open port:
int nRes = 1;
for (int iPort=1001; iPort<=1016; iPort++)
{
nRes = fpSDT_OpenPort(iPort);
if (nRes==0x90)
{
m_nOpenPort = iPort; // Open port success.
m_bLoad=true;
break;
}
}
if(nRes!=0x90)
{
AfxMessageBox(_T(“Open port fail”));
return false;
}
return true;
③ When the software is closed, closed the port and release the DLL core.
Void CNIDapiDlg::Ontimer(UINT_PTR nIDEvent)
{
Readcard();
CDialog::OnTimer(nIDEvent);
}
The timer enquiry the ID card continuously. To read the chip automatically, add the timer. To read the chip manually, don’t add the timer.
Void CNIDapiDlg::OnClose()
{
if (m_bLoad!=NULL)
{
fpSDT_ClosePort(m_nOpenPort);
if(m_hNIDapi!=NULL)
{
FreeLibrary(m_hNIDapi);
m_hNIDapi=NULL;
}
if(m_hGetBmp!=NULL)
{
FreeLibrary(m_hGetBmp);
m_hGetBmp=NULL;
}
CDialog::OnClose();
}
—5.2.3.2 OCR + Read the Passport Chip section (refer to the Document Identification SDK Development Manual for the interface):
//Load the core library and initialize the core.
int CEPRSampleDemoDlg::InitCardDll()
{
if(m_bInitSuccess)
return 0;
USES_CONVERSION;
m_hIDCard = LoadLibrary(_T(“IDCard.dll“));
if(NULL == m_hIDCard)
return 1001;
int nRet = pInitIDCard(m_strUserID,0,NULL);
if(0 != nRet)
{
FreeCardDll();
return nRet;
}
m_bInitSuccess = true;|
return 0;
}