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

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

于仕琪libfacedetection WIN10 VS2015

發布時間:2023/12/9 编程问答 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 于仕琪libfacedetection WIN10 VS2015 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

這里是運行速度 (i7-6700)

https://github.com/ShiqiYu/libfacedetection
首先下載代碼壓縮包,解壓


打開src

將這幾個文件復制到你的項目文件夾中

在項目中以添加現有項的方式將這四個文件添加到項目中

右鍵項目打開項目屬性,并選擇Release – x64

首先配置opencv,請自行查閱其他人的博客,有很多人都有詳細的配置步驟,這里跳過
選擇c/c++ 優化選擇使速度最大化(/O2)


所有選項OpenMp支持 --是

在facedetectcnn.h下對代碼進行修改

修改之后,在自己的項目下創建新的cpp把以下代碼復制進去(于老師給的例子,攝像頭檢測人臉,并把調用攝像頭的代碼進行了一點點更改)

/* By downloading, copying, installing or using the software you agree to this license. If you do not agree to this license, do not download, install, copy or use the software.License Agreement For libfacedetection (3-clause BSD License)Copyright (c) 2018-2020, Shiqi Yu, all rights reserved. shiqi.yu@gmail.comRedistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.* Neither the names of the copyright holders nor the names of the contributors may be used to endorse or promote products derived from this software without specific prior written permission.This software is provided by the copyright holders and contributors "as is" and any express or implied warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are disclaimed. In no event shall copyright holders or contributors be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage. */#include <stdio.h> #include <opencv2/opencv.hpp> #include "facedetectcnn.h"//define the buffer size. Do not change the size! #define DETECT_BUFFER_SIZE 0x20000 using namespace cv;int main() {VideoCapture capture(0);Mat face;int * pResults = NULL;//pBuffer is used in the detection functions.//If you call functions in multiple threads, please create one buffer for each thread!unsigned char * pBuffer = (unsigned char *)malloc(DETECT_BUFFER_SIZE);if (!pBuffer){fprintf(stderr, "Can not alloc buffer.\n");return -1;}Mat im;if (!capture.isOpened()){puts("dont open video.");system("pause");return -1;}if (capture.isOpened()){while (true){capture >> im;//cout << "Image size: " << im.rows << "X" << im.cols << endl;Mat image = im.clone();///// CNN face detection // Best detection rate////!!! The input image must be a BGR one (three-channel) instead of RGB//!!! DO NOT RELEASE pResults !!!TickMeter cvtm;cvtm.start();pResults = facedetect_cnn(pBuffer, (unsigned char*)(image.ptr(0)), image.cols, image.rows, (int)image.step);cvtm.stop();printf("time = %gms\n", cvtm.getTimeMilli());printf("%d faces detected.\n", (pResults ? *pResults : 0));Mat result_image = image.clone();//print the detection resultsfor (int i = 0; i < (pResults ? *pResults : 0); i++){short * p = ((short*)(pResults + 1)) + 142 * i;int confidence = p[0];int x = p[1];int y = p[2];int w = p[3];int h = p[4];//show the score of the face. Its range is [0-100]char sScore[256];snprintf(sScore, 256, "%d", confidence);cv::putText(result_image, sScore, cv::Point(x, y - 3), cv::FONT_HERSHEY_SIMPLEX, 0.5, cv::Scalar(0, 255, 0), 1);//draw face rectanglerectangle(result_image, Rect(x, y, w, h), Scalar(0, 255, 0), 2);//draw five face landmarks in different colorscv::circle(result_image, cv::Point(p[5], p[5 + 1]), 1, cv::Scalar(255, 0, 0), 2);cv::circle(result_image, cv::Point(p[5 + 2], p[5 + 3]), 1, cv::Scalar(0, 0, 255), 2);cv::circle(result_image, cv::Point(p[5 + 4], p[5 + 5]), 1, cv::Scalar(0, 255, 0), 2);cv::circle(result_image, cv::Point(p[5 + 6], p[5 + 7]), 1, cv::Scalar(255, 0, 255), 2);cv::circle(result_image, cv::Point(p[5 + 8], p[5 + 9]), 1, cv::Scalar(0, 255, 255), 2);if (confidence == 99)face = result_image(Rect(x, y, w, h));//print the resultprintf("face %d: confidence=%d, [%d, %d, %d, %d] (%d,%d) (%d,%d) (%d,%d) (%d,%d) (%d,%d)\n",i, confidence, x, y, w, h,p[5], p[6], p[7], p[8], p[9], p[10], p[11], p[12], p[13], p[14]);}imshow("result", result_image);if ((cv::waitKey(2) & 0xFF) == 'q')break;}}//release the bufferfree(pBuffer);return 0; }

總結

以上是生活随笔為你收集整理的于仕琪libfacedetection WIN10 VS2015的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。