[overview]
There are at least three schemes to realize the identity authentication function based on face recognition: 1. Use the cloud services provided by major platforms, and call based on WEB API. API calls are charged per call. 2. Use SDK, embedded in the device. In this case, you need to develop your own hardware, and the SDK needs to be charged at one time according to the number of devices. 3. Purchase ready-made face recognition hardware products, and use the SDK provided by the manufacturer for secondary development. This kind of equipment is usually more expensive. In this paper, fluorite cloud combined with fluorite C2HC network camera (the first scheme) will be used to realize the identity authentication function based on face recognition. The hardware cost of this scheme is less than 200 yuan, and the cost of single face recognition + identity authentication is less than 0.01 yuan. It is a relatively economic plan.
[system architecture diagram]
Note: for the source of vehicle start signal, please refer to another article of mine. [enterprise project] engineering vehicle management system (including hardware design and development)
[preliminary preparation]
1. Because fluorite API can not directly use the photos taken by camera for face recognition, photos need to be sent to OSS cloud service for storage. Therefore, it is necessary to open OSS cloud service in advance and make corresponding configuration
2. An ECS ECS is needed to host the PC control program, and the operating system is windows
3. Before face recognition, you need to call fluorite API to create a set token. The name of the set can be specified at will.
[face registration]
#[business process]
1. The control terminal sends a photo command to the camera through the fluorite API to take a picture of the head. 2. After the camera receives the photographing instruction, it will take a picture and store it in the designated location of fluorite cloud. The fluorite API returns the image address link to the program. 3. After receiving the image address link, the control end obtains the image and stores the image in the OSS cloud service object. 4. The control end sends the picture to fluorite API for face recognition, and returns face token after recognition 5. The unique face identifier faceToken is sent to the fluorite API to the specified set of faces (setToken) for registration.
#[core code]
Token token = aiLib.checkToken();//Get token string pic = aiLib.getPic(token.accessToken, deviceSerial, "1");//Take photos with fluorite API if (pic != "") { string url = aiLib.uploadImg(pic);//Upload photos to OSS server if (url != "") { string faceToken = aiLib.faceCheck(token.accessToken, "0", url);//Face detection bool flag = aiLib.faceRegister(token.accessToken, faceToken, setToken);//Face registration result.imgUrlOss = url; result.faceToken = faceToken; result.result = flag; } } return result;
[face comparison - identity authentication]
#[business process]
1. After the vehicle starts, send a vehicle start signal to the control end 2. After the control terminal receives the signal, wait for 1 minute (wait until the camera is fully started), send the camera 6 times of photographing instructions through the fluorite API, with the sending interval of 10 seconds. 3. After the camera receives the photographing instruction, it will take a picture and store it in the designated location of fluorite cloud. The fluorite API returns the image address link to the program. 4. After receiving the image address link, the control end obtains the image and stores the image in the OSS cloud service object. 5. The control end sends the picture to fluorite API for face recognition, and returns face token after recognition 6. The face token is sent to fluorite API for face comparison, and the similarity score is returned after the comparison is successful. 7. If the similarity is greater than 90, it can be regarded as the same person.
#[core code]
Token token = aiLib.checkToken();//Get token string pic = aiLib.getPic(token.accessToken, deviceSerial, "1");//Take photos with fluorite API if (pic != "") { string url = aiLib.uploadImg(pic);//Upload photos to OSS server if (url != "") { string faceToken = aiLib.faceCheck(token.accessToken, "0", url);//Face detection Dictionary<string, object> dic = new Dictionary<string, object>(); dic["setToken"] = setToken; dic["threshold"] = 80;//Comparison threshold dic["matchCount"] = 1; string operation = "[" + JsonHelper.ObjectToJSON(dic) + "]"; string score = aiLib.faceSearch(token.accessToken, "2", faceToken, operation, "1");//Search for detected faces in face sets result.imgUrlOss = url; result.faceToken = faceToken; result.score = score;//Acquaintance score } } return result;