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)【除錯】——》命令引數——
(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;
}
再次執行程式:
參考資料:
【附錄】
(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