Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize face recognition client with Qt

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to achieve face recognition client with Qt". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to achieve face recognition client with Qt".

I. Preface

The face recognition client program does not need to be together with the face recognition related library, but communicates with the face recognition server through protocol communication. The face recognition client and server program framework is mainly to provide a set of general framework, according to the established protocol, to achieve face recognition related processing, many manufacturers will have and will do similar mechanisms. So that third-party manufacturers or other devices of their own can be processed in accordance with this communication protocol, for example, client programs can be on PCs, web pages, or Android clients, and front-end devices such as manual visitors do not need to do face recognition and other processing locally, but send them to the server to display the results after processing, so that they can take advantage of the powerful computing power of the server.

Custom face recognition protocol features:

Offline use, while supporting Baidu offline package and embedded linux face recognition static library.

Support multiple concurrent connections, automatic queuing processing, return with a unique identity to distinguish.

Input a single image to return to the face area.

Input a single picture to return facial eigenvalues.

Input a single picture or multiple pictures to return whether it is alive or not.

Pass in two pictures to return the comparison result.

Pass in two eigenvalues to return the alignment result.

Input a single picture to add a face.

Specifies a unique identifier to delete the face.

Input a single photo to return the face information with the greatest similarity.

Modify the configuration parameters of face service, such as whether to find quickly, the proportion of face, and so on.

II. Functional features

The supported functions include face recognition, face comparison, face search, live detection and so on.

The online version also supports ID card, driver's license, driving license, bank card and other identification.

The online version of the protocol supports Baidu, absenteeism, and the offline version supports Baidu, which can be customized.

In addition to supporting X86 architecture, it also supports embedded linux such as contex-A9, raspberry pie and so on.

The execution of each function returns not only the result but also the execution time.

Multithreading, which controls the current processing type through type.

Support a single image to retrieve the most similar images.

Support to specify directory images to generate facial feature value files.

You can set the number of pictures waiting to be processed in the queue.

A success or failure signal is returned for each execution.

The return results of face search include the original image + maximum similarity map + similarity and so on.

Face comparison supports two pictures and two eigenvalues at the same time.

Related functions customize a set of protocols for client and server, which can interact through TCP communication.

The custom face recognition protocol is very suitable for the scene where several devices are requested by a server in the center.

Each module is a separate class with neat code and perfect comments.

Third, effect picture

4. Core code FaceSdkClient::FaceSdkClient (QObject * parent): QObject (parent) {isOk = false; timeout = 10; lastTime = QDateTime::currentDateTime (); / / randomly generate IP to test clientIP = QString ("192.168.1% 1") .Arg (qrand ()% 255); serverIP = "192.168.1.239"; serverPort = 6662; / / instantiate the connection object tcpSocket = new QTcpSocket (this) Connect (tcpSocket, SIGNAL (connected ()), this, SLOT (connected ()); connect (tcpSocket, SIGNAL (disconnected ()), this, SLOT (disconnected (); connect (tcpSocket, SIGNAL (readyRead ()), this, SLOT (readData (); / / timer processing data timerData = new QTimer (this); connect (timerData, SIGNAL (timeout ()), this, SLOT (checkData (); timerData- > setInterval (100) / / timer processing reconnection timerConn = new QTimer (this); connect (timerConn, SIGNAL (timeout ()), this, SLOT (checkConn (); timerConn- > setInterval (3000); / / timer sends heartbeat timerHeart = new QTimer (this); connect (timerHeart, SIGNAL (timeout ()), this, SLOT (sendHeart (); timerHeart- > setInterval (2000);} void FaceSdkClient::connected () {isOk = true; sendHeart () } void FaceSdkClient::disconnected () {isOk = false; emit receiveAnaly (serverIP, "server disconnected");} void FaceSdkClient::checkConn () {QDateTime now = QDateTime::currentDateTime (); if (lastTime.secsTo (now) > = timeout) {isOk = false; start (); emit receiveAnaly (serverIP, "reconnect server");}} void FaceSdkClient::readData () {lastTime = QDateTime::currentDateTime () QMutexLocker locker (& mutex); buffer.append (tcpSocket- > readAll ());} void FaceSdkClient::checkData () {QMutexLocker locker (& mutex); QDomDocument dom; if (! DeviceFun::getReceiveXmlData (buffer, dom, "IFACE:", 10)) {return;} / / check data emit receiveData (serverIP, dom.toString ()) one by one; QDomElement element = dom.documentElement () If (element.tagName () = = "FaceServer") {/ / find time field properties QString nowTime = element.attribute ("NowTime"); QString year, month, day, hour, min, sec; DeviceFun::getNowTime (nowTime, year, month, day, hour, min, sec); / / QUIHelper::setSystemDateTime (year, month, day, hour, min, sec) / / handle QDomNode childNode = element.firstChild (); QString name = childNode.nodeName (); QString value = element.text (); / / qDebug () abort (); tcpSocket- > connectToHost (serverIP, serverPort); timerData- > start (); timerConn- > start (); timerHeart- > start (); return true;} void FaceSdkClient::stop () {tcpSocket- > disconnectFromHost (); timerData- > stop () TimerConn- > stop (); timerHeart- > stop ();} void FaceSdkClient::sendData (const QString & body) {if (! isOk) {return;} / / build xml string QStringList list; list.append (QString (") .arg (clientIP)); list.append (body); list.append ("); QString data = DeviceFun::getSendXmlData (list.join (")," IFACE: ") TcpSocket- > write (data.toUtf8 ()); emit sendData (clientIP, data);} void FaceSdkClient::sendHeart () {if (! isOk) {return;} sendData (""); emit sendAnaly (clientIP, "send heartbeat");} void FaceSdkClient::sendFindFace (const QString & faceID, const QImage & image) {if (! isOk) {return } QString data = QString ("% 2") .arg (faceID) .arg (DeviceFun::getImageData (image)); sendData (data); emit sendAnaly (clientIP, "request face area");} void FaceSdkClient::sendFindFeature (const QString & faceID, const QImage & image) {if (! isOk) {return;} QString data = QString ("% 2") .arg (faceID) .arg (DeviceFun::getImageData (image); sendData (data)) Emit sendAnaly (clientIP, "request facial features");} void FaceSdkClient::sendFindLive (const QString & faceID, const QImage & image) {if (! isOk) {return;} QString data = QString ("% 2") .arg (faceID) .arg (DeviceFun::getImageData (image)); sendData (data); emit sendAnaly (clientIP, "request for live detection") } void FaceSdkClient::sendCompareByImage (const QString & faceID1, const QImage & image1, const QString & faceID2, const QImage & image2) {if (! isOk) {return;} QStringList list; list.append (""); list.append (QString ("2") .arg (faceID1) .arg (DeviceFun::getImageData (image1) List.append (QString ("% 2") .arg (faceID2) .arg (DeviceFun::getImageData (image2)); list.append (""); sendData (list.join (")); emit sendAnaly (clientIP," request for face matching ");} void FaceSdkClient::sendCompareByFeature (const QString & faceID1, const QString & feature1, const QString & faceID2, const QString & feature2) {if (! isOk) {return;} QStringList list List.append (""); list.append (QString ("2") .arg (faceID1) .arg (feature1)); list.append (QString ("2") .arg (faceID2) .arg (feature2)); list.append (""); sendData (list.join (")); emit sendAnaly (clientIP," request face comparison ") } void FaceSdkClient::sendAppendFace (const QString & faceID, const QImage & image) {if (! isOk) {return;} QString data = QString ("% 2") .arg (faceID) .arg (DeviceFun::getImageData (image)); sendData (data); emit sendAnaly (clientIP, "add face");} void FaceSdkClient::sendDeleteFace (const QString & faceID) {if (! isOk) {return } QString data = QString ("") .arg (faceID); sendData (data); emit sendAnaly (clientIP, "delete face");} void FaceSdkClient::sendFindByImage (const QString & faceID, const QImage & image) {if (! isOk) {return;} QString data = QString ("% 2") .arg (faceID) .arg (DeviceFun::getImageData (image)); sendData (data); emit sendAnaly (clientIP, "find the largest face") } void FaceSdkClient::sendFindByFeature (const QString & faceID, const QString & feature) {if (! isOk) {return;} QString data = QString ("% 2") .Arg (faceID) .arg (feature); sendData (data); emit sendAnaly (clientIP, "find the largest face") } Thank you for your reading. the above is the content of "how to realize the face recognition client with Qt". After the study of this article, I believe you have a deeper understanding of how to implement the face recognition client with Qt, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report