win7 x64 + vs2013 + dlib-19.1 【無CMake】 人臉檢測

本文地址:https://blog.csdn.net/zaibeijixing/article/details/80595095

本文地址:https://blog.csdn.net/zaibeijixing/article/details/80595095

 

win7 + vs2013 + dlib-19.1  【無CMake】

(配置新電腦,把之前筆記整理髮布、分享)

一:必備

官網介紹dlib19.2及以後需vs2015可用。其它歷史版本下載地址https://sourceforge.net/projects/dclib/files/dlib/

二:建立win32控制檯程序,項目配置屬性

(0)【常規】——》配置類型——選-應用程序

(1)【調試】——》命令參數——E:\mypic\00.jpg

(2)【C/C++】——》常規

①附加包含目錄 和 SDL檢查

 

②預處理器

 

③命令行 添加 /bigobj

三:解決方案資源管理器中

(1) 自建 源.cpp 文件  (內容見文後附錄)

(2) 添加現有文件E:\tool_kits\dlib-19.1\dlib-19.1\dlib\all\source.cpp

(3) 項目添加E:\tool_kits\dlib-19.1\dlib-19.1\dlib\external\(libjpeg,libpng,zlib)中的所有文件。(vs會自動歸類)

四:運行(debug+win32)

出錯修改:【dlib/ matrix/matrix_utilities.h : error C2057】

 

修正代碼:

{

COMPILE_TIME_ASSERT(static_cast<int>(pixel_traits<P>::num) > 0);

matrix<T,pixel_traits<P>::num,1> m;

pixel_to_vector_helper<P>::assign(m,pixel);

return m;

}

 

 再次運行程序:

 

 

 

參考資料:

(0)http://blog.csdn.net/shuzfan/article/details/52149882  Dlib + VS2013 人臉檢測,無需CMAKE

(1)http://blog.csdn.net/fengbingchun/article/details/53414072  Dlib簡介及在windows7 vs2013編譯過程

(2)http://blog.csdn.net/qq_22764813/article/details/53053232  Dlib 19.2+VS2015 人臉檢測(非CMake)

 

【附錄】

(1)源.cpp 代碼:

#include<dlib/image_processing/frontal_face_detector.h>
#include<dlib\image_processing\render_face_detections.h>
#include<dlib\image_processing.h>
#include<dlib\gui_widgets.h>
#include<dlib\image_io.h>

#include<iostream>
#include<vector>


//#define DDLIB_JPEG_SUPPORT
//#define DLIB_PNG_SUPPORT


using namespace dlib;
using namespace std;

int main(int argc, char **argv)
{
	try
	{
		frontal_face_detector detector = get_frontal_face_detector();

		image_window win;//一個顯示窗口

		array2d<unsigned char> img;
		cout << "processing image" << argv[1] << endl;
		load_image(img, argv[1]);//加載一張圖片
		pyramid_up(img);//對圖像進行上採樣,檢測更小的人臉

		//開始檢測,返回一系列的邊界框
		std::vector<rectangle> dets = detector(img);//detector()函數檢測人臉,返回一系列邊界盒子

		cout << "Number of faces detected:" << dets.size() << endl;//re
		//在原圖上顯示結果
		win.clear_overlay();
		win.set_image(img);
		win.add_overlay(dets, rgb_pixel(255, 0, 0));
		cout << "Hit enter to process the next image..." << endl;
		cin.get();
	}
	catch (const std::exception& e)
	{
		cout << "\nexception thrown!" << endl;
		cout << e.what() << endl;
	}
	getchar();
}

 

//--------------------------------------------------------------------------------------------------------

 

 

可以轉載分享,但需在文章開頭註明本文原始鏈接:https://blog.csdn.net/zaibeijixing/article/details/80595095

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章