日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 运维知识 > linux >内容正文

linux

Linux 实现人脸识别

發(fā)布時(shí)間:2023/12/9 linux 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Linux 实现人脸识别 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

通過(guò)識(shí)別照片判斷是否為同一人

  • 1.借助工具
    • 1.注冊(cè)登錄
    • 2.選擇人臉識(shí)別
    • 3.1毛錢購(gòu)買
  • 2.代碼測(cè)試

1.借助工具

圖像識(shí)別靠自己做成比較費(fèi)勁且識(shí)別率不高,故需借助一些工具,我們利用翔云智能平臺(tái),百度搜索翔云(因?yàn)橄柙票阋艘恍!!?#xff09;

1.注冊(cè)登錄

進(jìn)入后,上方選項(xiàng)欄選擇價(jià)格與購(gòu)買

2.選擇人臉識(shí)別

右側(cè)選擇人臉識(shí)別,以后若有其他需要亦可使用其他

3.1毛錢購(gòu)買

第一次1毛錢(便宜吧。。。)加入購(gòu)物車,右側(cè)購(gòu)車內(nèi)進(jìn)行購(gòu)買

完成后,再次選擇上方選項(xiàng)欄的產(chǎn)品,選擇人臉識(shí)別

可以先選擇本地上傳試一下

2.代碼測(cè)試

接下來(lái)進(jìn)入正題
根據(jù)網(wǎng)頁(yè)下方的API文檔
在Linux系統(tǒng)下編寫程序
記得先在文件夾下放兩張圖片,函數(shù)詳細(xì)使用見
libcurl

#include <stdio.h> #include <curl/curl.h> #include<string.h> #include<stdlib.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <unistd.h>#define true 1 #define false 0 typedef unsigned int bool;char Buf[12000]; size_t readData( void *ptr, size_t size, size_t nmemb, void *stream) {strncpy(Buf,ptr,1024);printf("============================get data============================");printf("%s\n",Buf); }//將圖片轉(zhuǎn)換為base64格式 char *readBase64(char *filePath) {char *bufPic;char cmd[128];memset(cmd,'\0',128);sprintf(cmd,"base64 %s > tmpFile",filePath);system(cmd);int fd = open("./tmpFile",O_RDWR);int filelen = lseek(fd,0,SEEK_END);lseek(fd,0,SEEK_SET);bufPic = (char *)malloc(filelen+2);bufPic = memset(bufPic,'\0',filelen+2);read(fd,bufPic,filelen);system("rm -f tmpFile");close(fd);return bufPic; }bool postUrl() {CURL *curl;CURLcode res;char *pointData;char *key = "UbkpH8e8ydNsj6uhHUecDu";char *secret = "1026b30b3cb7468e9d301afe73dce9f9";int typeId = 21;char *format = "xml";char *bufPic1;char *bufPic2;bufPic1 = readBase64("./a.jpg");bufPic2 = readBase64("./b.jpg");int len = strlen(key)+strlen(secret)+strlen(bufPic1)+strlen(bufPic2)+128;pointData = (char *)malloc(len);memset(pointData,'\0',len);sprintf(pointData,"&img1=%s&img2=%s&key=%s&secret=%s&typeId=%d&format=%s",bufPic1,bufPic2,key,secret,21,format);//printf("%s\n",pointData);// int fp =open("./test.txt",O_RDWR|O_CREAT,0666);curl = curl_easy_init();if (curl){curl_easy_setopt(curl,CURLOPT_POSTFIELDS,pointData);curl_easy_setopt(curl,CURLOPT_URL,"https://netocr.com/api/faceliu.do");curl_easy_setopt(curl,CURLOPT_WRITEFUNCTION,readData);res = curl_easy_perform(curl);printf("OK:%d\n",res);if(strstr(Buf, "是") != NULL){printf("the person same\n");}else{printf("the person different\n");}curl_easy_cleanup(curl);}return true; } int main(void) {postUrl(); }

運(yùn)行結(jié)果:

如果發(fā)現(xiàn)無(wú)法實(shí)現(xiàn),代碼運(yùn)行進(jìn)入不了網(wǎng)址,可能是沒有安裝openssl庫(kù),請(qǐng)參考
安裝openssl

此篇內(nèi)容備忘而做的筆記,希望可以幫到您

師從上官可編程,陳立臣

總結(jié)

以上是生活随笔為你收集整理的Linux 实现人脸识别的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。