In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 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 online version of Qt", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "Qt how to achieve face recognition online version"!
I. Preface
With regard to face recognition, do not be too hot a few years ago, even if it is still a mess today, everything should be on the side of face recognition. This thing should only be a very small part of artificial intelligence. Face recognition is literally to identify the face region. In fact, the real processing behind is to get the face region picture, extract face eigenvalues, and then use these eigenvalues to do comparative analysis. To identify who in the end, there are many domestic manufacturers, the competition is the accuracy of the false alarm rate, speed is nothing more than a stack of hardware, what VPU all kinds of parallel operations are piled up, speed lever, many manufacturers have achieved the level of a few milliseconds, it is estimated that many manufacturers have added their own algorithms on the basis of open source, and have been running and running to produce face model files that conform to their own algorithms. For example, Baidu's face recognition model file, after several years of development, is getting bigger and finer and more accurate.
I heard a great god say that most of the time artificial intelligence is not complete intelligence, and most of them stay in the semi-intelligent stage, and this semi-intelligent stage still needs a lot of auxiliary hardware and even artificial judgment. many model base files are generated by a little girl's similar non-stop points on the assembly line over there, the so-called deep learning algorithm, which allows him to identify more data and make it more accurate. With regard to face recognition or artificial intelligence, laymen generally feel very science fiction, experts generally feel very desperate, industry leaders and leaders beat the chicken blood.
Most of the domestic manufacturers have provided the api corresponding to the official website to deal with, register an account and set up a key, and then they can directly link it up. There is no technical difficulty about this piece, and beginners can handle it. They just need to post the data first and get the returned data for analysis. What they need to figure out is how to fill in the data to be post, such as bringing key. Organize other data, such as whether the image is uploaded by base64 string or binary file, and the returned data are all json, which can be parsed directly with the ready-made json library for ok.
Encapsulation of Baidu face recognition online and offline SDK:
The offline version requires a compiler that supports Category 11 and must be MSVC. The mingw compiler is not supported.
The key and other information in the online version, be sure to replace it with your own application.
The offline version can only be used on windows.
The offline version needs to apply for a key on its own. Find the LicenseTool.exe under the facebaidusdk folder, fill in the serial number applied for in the offline SDK management in the background, and click the activate button.
The dynamic libraries and model files corresponding to the offline version are downloaded from the official website.
If there is a facebaidusdk+face-resource folder in the source package, you only need to copy all the files under the facebaidusdk folder to the same executable directory, and the face-resource folder to the executable folder directory with the same level directory. The directory location is shown in the sample diagram under the snap folder.
TestFaceApi.exe under the facebaidusdk directory provides a test program for Baidu, which first plugs the USB camera into the computer and looks for a face frame in real time.
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. The core code void FaceWebBaiDu::finished (QNetworkReply * reply) {QString error = reply- > errorString (); if (! error.isEmpty () & & error! = "Unknown error") {emit receiveError (error);} if (reply- > bytesAvailable () > 0 & & reply- > error () = = QNetworkReply::NoError) {QString data = reply- > readAll (); reply- > deleteLater () / / send and receive data signal emit receiveData (data); / / initialize script engine QScriptEngine engine; / / build parsing object QScriptValue script = engine.evaluate ("value=" + data); / / get authentication identifier QString token = script.property ("access_token") .toString () If (! token.isEmpty ()) {this- > token = token; emit receiveResult (0, "Authentication ID returns success"); return;} / / General return result field int code = script.property ("error_code"). ToInt32 (); QString msg = script.property ("error_msg"). ToString () Emit receiveResult (code, msg); / / Image recognition part QScriptValue result = script.property ("result"); if (! result.isNull ()) {/ / face recognition if (data.contains ("location")) {QScriptValue face_list = result.property ("face_list"); checkFaceList (face_list) } / / face comparison if (data.contains ("score") & &! data.contains ("location") {QScriptValue score = result.property ("score"); float result = score.toString (). ToFloat (); if (result > 0) {emit receiveFaceCompare (QRect (), QRect (), result) } else {emit receiveFaceCompareFail ();}} / / in vivo detection if (data.contains ("face_liveness")) {QScriptValue face_liveness = result.property ("face_liveness"); float result = face_liveness.toString () .toFloat () If (result > = 0) {emit receiveLive (result);}} void FaceWebBaiDu::checkFaceList (const QScriptValue & scriptValue) {/ / create an iterator to parse the specific value QScriptValueIterator it (scriptValue) one by one; while (it.hasNext ()) {it.next () If (it.flags () & QScriptValue::SkipInEnumeration) {continue;} QRect rect; QString face_token = it.value (). Property ("face_token"). ToString (); if (! face_token.isEmpty ()) {QScriptValue value = it.value () .property ("location"); rect = FaceHelper::getRect (value) } if (rect.width () > 0) {emit receiveFaceRect (rect); break;}} void FaceWebBaiDu::getToken () {/ / see http://ai.baidu.com/ai-doc/REFERENCE/Ck3dwjhhu QStringList list; list.append (QString ("grant_type=%1") .arg ("client_credentials")) List.append (QString ("client_id=%1") .arg (key); list.append (QString ("client_secret=%1") .arg (secret)); QString data = list.join ("&"); QString url = "https://aip.baidubce.com/oauth/2.0/token"; FaceHelper::sendData (manager, url, data);} void FaceWebBaiDu::detect (const QImage & img) {QString imgData = FaceHelper::getImageData2 (img); QStringList list List.append (QString ("{\" image\ ":\"% 1\ ",\" image_type\ ":\" BASE64\ "}") .arg (imgData)); QString data = list.join (""); QString url = QString ("https://aip.baidubce.com/rest/2.0/face/v3/detect?access_token=%1").arg(token); FaceHelper::sendData (manager, url, data)) } void FaceWebBaiDu::compare (const QImage & img1, const QImage & img2) {QString imgData1 = FaceHelper::getImageData2 (img1); QString imgData2 = FaceHelper::getImageData2 (img2); / / if in vivo detection is required, NONE is changed to LOW NORMAL HIGH QStringList list; list.append ("[") List.append (QString ("{\" image\ ":\"% 1\ ",\" image_type\ ":\" BASE64\ ",\" liveness_control\ ":\" NONE\ "}") .arg (imgData1); list.append (","); list.append (QString ("{\" image\ ":\"% 1\ ",\" image_type\ ":\" BASE64\ ",\" liveness_control\ ":\" NONE\ "}") .arg (imgData2)) List.append ("]"); QString data = list.join (""); QString url = QString ("https://aip.baidubce.com/rest/2.0/face/v3/match?access_token=%1").arg(token); FaceHelper::sendData (manager, url, data);} void FaceWebBaiDu::live (const QImage & img) {QList imgs; if (! img.isNull ()) {imgs
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.