精华内容
下载资源
问答
  • Dlib

    2021-01-21 17:15:42
    机器学习库dlib的C++编译和使用(windows和linux) 踏莎行 科技/金融/文学/游戏/美术/运动,游戏赏析公众号 youxizhimei 1 人赞同了该文章 dlib是一个C++编写的工具集,相比于深度学习库而言,dlib内部更多的...

    机器学习库dlib的C++编译和使用(windows和linux)

    机器学习库dlib的C++编译和使用(windows和linux)

    踏莎行

    踏莎行

    科技/金融/文学/游戏/美术/运动,游戏赏析公众号 youxizhimei

    1 人赞同了该文章

    dlib是一个C++编写的工具集,相比于深度学习库而言,dlib内部更多的是封装了很多传统机器学习计算函数,例如回归分析、支撑向量机、聚类,开箱即用,对外提供了C++和python两种接口。

    本文通过一个C++调用dlib的demo来体验一下dlib这个强大的工具库。

    获取

    从官网dlib官网或者github地址dlib源码下载最新源码

    这里用的是dlib-19.17

    编译

    支持windows和linux双平台编译

    为了避免引入过多的依赖,解压源码后,打开dlib-19.17/dlib/CMakeLists.txt找到以下几行进行修改

    if (DLIB_ISO_CPP_ONLY)
          option(DLIB_JPEG_SUPPORT ${DLIB_JPEG_SUPPORT_STR} OFF)
          option(DLIB_LINK_WITH_SQLITE3 ${DLIB_LINK_WITH_SQLITE3_STR} OFF)
          option(DLIB_USE_BLAS ${DLIB_USE_BLAS_STR} OFF)
          option(DLIB_USE_LAPACK ${DLIB_USE_LAPACK_STR} OFF)
          option(DLIB_USE_CUDA ${DLIB_USE_CUDA_STR} OFF)
          option(DLIB_PNG_SUPPORT ${DLIB_PNG_SUPPORT_STR} OFF)
          option(DLIB_GIF_SUPPORT ${DLIB_GIF_SUPPORT_STR} OFF)
          #option(DLIB_USE_FFTW ${DLIB_USE_FFTW_STR} OFF)
          option(DLIB_USE_MKL_FFT ${DLIB_USE_MKL_FFT_STR} OFF)
    else()
          option(DLIB_JPEG_SUPPORT ${DLIB_JPEG_SUPPORT_STR} ON)
          option(DLIB_LINK_WITH_SQLITE3 ${DLIB_LINK_WITH_SQLITE3_STR} ON)
          option(DLIB_USE_BLAS ${DLIB_USE_BLAS_STR} ON)
          option(DLIB_USE_LAPACK ${DLIB_USE_LAPACK_STR} ON)
          option(DLIB_USE_CUDA ${DLIB_USE_CUDA_STR} ON)
          option(DLIB_PNG_SUPPORT ${DLIB_PNG_SUPPORT_STR} ON)
          option(DLIB_GIF_SUPPORT ${DLIB_GIF_SUPPORT_STR} ON)
          #option(DLIB_USE_FFTW ${DLIB_USE_FFTW_STR} ON)
          option(DLIB_USE_MKL_FFT ${DLIB_USE_MKL_FFT_STR} ON)
    endif()

    改为

    if (DLIB_ISO_CPP_ONLY)
          option(DLIB_JPEG_SUPPORT ${DLIB_JPEG_SUPPORT_STR} OFF)
          option(DLIB_LINK_WITH_SQLITE3 ${DLIB_LINK_WITH_SQLITE3_STR} OFF)
          option(DLIB_USE_BLAS ${DLIB_USE_BLAS_STR} OFF)
          option(DLIB_USE_LAPACK ${DLIB_USE_LAPACK_STR} OFF)
          option(DLIB_USE_CUDA ${DLIB_USE_CUDA_STR} OFF)
          option(DLIB_PNG_SUPPORT ${DLIB_PNG_SUPPORT_STR} OFF)
          option(DLIB_GIF_SUPPORT ${DLIB_GIF_SUPPORT_STR} OFF)
          #option(DLIB_USE_FFTW ${DLIB_USE_FFTW_STR} OFF)
          option(DLIB_USE_MKL_FFT ${DLIB_USE_MKL_FFT_STR} OFF)
    else()
          option(DLIB_JPEG_SUPPORT ${DLIB_JPEG_SUPPORT_STR} ON)
          option(DLIB_LINK_WITH_SQLITE3 ${DLIB_LINK_WITH_SQLITE3_STR} ON)
          option(DLIB_USE_BLAS ${DLIB_USE_BLAS_STR} OFF)
          option(DLIB_USE_LAPACK ${DLIB_USE_LAPACK_STR} OFF)
          option(DLIB_USE_CUDA ${DLIB_USE_CUDA_STR} OFF)
          option(DLIB_PNG_SUPPORT ${DLIB_PNG_SUPPORT_STR} ON)
          option(DLIB_GIF_SUPPORT ${DLIB_GIF_SUPPORT_STR} ON)
          #option(DLIB_USE_FFTW ${DLIB_USE_FFTW_STR} ON)
          option(DLIB_USE_MKL_FFT ${DLIB_USE_MKL_FFT_STR} OFF)
    endif()

    显式地禁止使用blas,lapack,cuda和mkl依赖

    另外,确保编译器能支持C++11全部特性

    windows

    环境

    • win7/win10 64位
    • vs2015 update3 及以上

    步骤

    1,用cmake编译静态库

    要用release版,计算效率快

    windows下推荐用官网的命令来编译,也可以用cmake的gui工具

    cd dlib-19.17
    mkdir build_x64
    cd build_x64
    cmake -G "Visual Studio 14 2015 Win64" -T host=x64 ..
    cmake --build . --config Release

    会在build/dlib/Release目录生成静态链接库dlib19.17.0_release_64bit_msvc1900.lib将其改名为dlib.lib

    2,替换config.h

    这一步非常重要,解决调用dlib时USER_ERROR__inconsistent_build_configuration__see_dlib_faq_2这个报错

    需要将build/dlib/config.h文件拷贝到源码目录dlib-19.17/dlib进行覆盖

    linux

    环境

    • ubuntu14.04 64位
    • gcc4.8.1及以上

    步骤

    1,用cmake编译静态库

    要用release版,计算效率快

    cd dlib-19.17
    mkdir build
    cd build
    cmake ..
    cmake --build . --config Release

    会在build/dlib/Release目录生成静态链接库libdlib.a

    2,替换config.h

    这一步非常重要,解决调用dlib时USER_ERROR__inconsistent_build_configuration__see_dlib_faq_2这个报错

    需要将build/dlib/config.h文件拷贝到源码目录dlib-19.17/dlib进行覆盖

    使用

    创建项目,用cmake构建跨平台项目

    目录结构
    dlib_test
    ├── CMakeLists.txt
    └── src
    └── main.cpp

    其中
    CMakeLists.txt

    用cmake编译,运行,注意demo程序也是采用64位release模式进行编译运行

    project(dlib_test)
    cmake_minimum_required(VERSION 2.8)
    
    add_definitions(-std=c++11)
    
    if (UNIX)
    include_directories(
        /home/user/codetest/dlib-19.17
    )
    else()
    include_directories(
        D:/Programs/dlib-19.17
    )
    endif()
    
    aux_source_directory(./src DIR_SRCS)
    
    if (UNIX)
    link_directories(
        /home/user/codetest/dlib-19.17/build/dlib
    )
    else()
    link_directories(
        D:/Programs/dlib-19.17/build_x64/dlib/Release
    )
    endif()
    
    add_executable(dlib_test ${DIR_SRCS})
    target_link_libraries(dlib_test dlib)

    main.cpp

    #include <iostream>
    #include "dlib/svm.h"
    
    using namespace std;
    using namespace dlib;
    
    int main()
    {
    	
    	typedef matrix<double, 2, 1> sample_type;
    	typedef radial_basis_kernel<sample_type> kernel_type;
    
    
    	// Now we make objects to contain our samples and their respective labels.
    	std::vector<sample_type> samples;
    	std::vector<double> labels;
    
    	// Now let's put some data into our samples and labels objects.  We do this
    	// by looping over a bunch of points and labeling them according to their
    	// distance from the origin.
    	for (int r = -20; r <= 20; ++r)
    	{
    		for (int c = -20; c <= 20; ++c)
    		{
    			sample_type samp;
    			samp(0) = r;
    			samp(1) = c;
    			samples.push_back(samp);
    
    			// if this point is less than 10 from the origin
    			if (sqrt((double)r*r + c*c) <= 10)
    				labels.push_back(+1);
    			else
    				labels.push_back(-1);
    
    		}
    	}
    
    	vector_normalizer<sample_type> normalizer;
    	// Let the normalizer learn the mean and standard deviation of the samples.
    	normalizer.train(samples);
    	// now normalize each sample
    	for (unsigned long i = 0; i < samples.size(); ++i)
    		samples[i] = normalizer(samples[i]);
    
    	randomize_samples(samples, labels);
    
    
    	// here we make an instance of the svm_c_trainer object that uses our kernel
    	// type.
    	svm_c_trainer<kernel_type> trainer;
    
    	cout << "doing cross validation" << endl;
    	for (double gamma = 0.00001; gamma <= 1; gamma *= 5)
    	{
    		for (double C = 1; C < 100000; C *= 5)
    		{
    			// tell the trainer the parameters we want to use
    			trainer.set_kernel(kernel_type(gamma));
    			trainer.set_c(C);
    
    			cout << "gamma: " << gamma << "    C: " << C;
    			// Print out the cross validation accuracy for 3-fold cross validation using
    			// the current gamma and C.  cross_validate_trainer() returns a row vector.
    			// The first element of the vector is the fraction of +1 training examples
    			// correctly classified and the second number is the fraction of -1 training
    			// examples correctly classified.
    			cout << "     cross validation accuracy: "
    				<< cross_validate_trainer(trainer, samples, labels, 3);
    		}
    	}
    
    	trainer.set_kernel(kernel_type(0.15625));
    	trainer.set_c(5);
    	typedef decision_function<kernel_type> dec_funct_type;
    	typedef normalized_function<dec_funct_type> funct_type;
    
    	// Here we are making an instance of the normalized_function object.  This
    	// object provides a convenient way to store the vector normalization
    	// information along with the decision function we are going to learn.  
    	funct_type learned_function;
    	learned_function.normalizer = normalizer;  // save normalization information
    	learned_function.function = trainer.train(samples, labels); // perform the actual SVM training and save the results
    
    																// print out the number of support vectors in the resulting decision function
    	cout << "\nnumber of support vectors in our learned_function is "
    		<< learned_function.function.basis_vectors.size() << endl;
    
    	// Now let's try this decision_function on some samples we haven't seen before.
    	sample_type sample;
    
    	sample(0) = 3.123;
    	sample(1) = 2;
    	cout << "This is a +1 class example, the classifier output is " << learned_function(sample) << endl;
    
    	sample(0) = 3.123;
    	sample(1) = 9.3545;
    	cout << "This is a +1 class example, the classifier output is " << learned_function(sample) << endl;
    
    	sample(0) = 13.123;
    	sample(1) = 9.3545;
    	cout << "This is a -1 class example, the classifier output is " << learned_function(sample) << endl;
    
    	sample(0) = 13.123;
    	sample(1) = 0;
    	cout << "This is a -1 class example, the classifier output is " << learned_function(sample) << endl;
    
    
    	// We can also train a decision function that reports a well conditioned
    	// probability instead of just a number > 0 for the +1 class and < 0 for the
    	// -1 class.  An example of doing that follows:
    	typedef probabilistic_decision_function<kernel_type> probabilistic_funct_type;
    	typedef normalized_function<probabilistic_funct_type> pfunct_type;
    
    	pfunct_type learned_pfunct;
    	learned_pfunct.normalizer = normalizer;
    	learned_pfunct.function = train_probabilistic_decision_function(trainer, samples, labels, 3);
    	// Now we have a function that returns the probability that a given sample is of the +1 class.  
    
    	// print out the number of support vectors in the resulting decision function.  
    	// (it should be the same as in the one above)
    	cout << "\nnumber of support vectors in our learned_pfunct is "
    		<< learned_pfunct.function.decision_funct.basis_vectors.size() << endl;
    
    	sample(0) = 3.123;
    	sample(1) = 2;
    	cout << "This +1 class example should have high probability.  Its probability is: "
    		<< learned_pfunct(sample) << endl;
    
    	sample(0) = 3.123;
    	sample(1) = 9.3545;
    	cout << "This +1 class example should have high probability.  Its probability is: "
    		<< learned_pfunct(sample) << endl;
    
    	sample(0) = 13.123;
    	sample(1) = 9.3545;
    	cout << "This -1 class example should have low probability.  Its probability is: "
    		<< learned_pfunct(sample) << endl;
    
    	sample(0) = 13.123;
    	sample(1) = 0;
    	cout << "This -1 class example should have low probability.  Its probability is: "
    		<< learned_pfunct(sample) << endl;
    
    	serialize("saved_function.dat") << learned_pfunct;
    
    	// Now let's open that file back up and load the function object it contains.
    	deserialize("saved_function.dat") >> learned_pfunct;
    
    	cout << "\ncross validation accuracy with only 10 support vectors: "
    		<< cross_validate_trainer(reduced2(trainer, 10), samples, labels, 3);
    
    	// Let's print out the original cross validation score too for comparison.
    	cout << "cross validation accuracy with all the original support vectors: "
    		<< cross_validate_trainer(trainer, samples, labels, 3);
    
    	// When you run this program you should see that, for this problem, you can
    	// reduce the number of basis vectors down to 10 without hurting the cross
    	// validation accuracy. 
    
    
    	// To get the reduced decision function out we would just do this:
    	learned_function.function = reduced2(trainer, 10).train(samples, labels);
    	// And similarly for the probabilistic_decision_function: 
    	learned_pfunct.function = train_probabilistic_decision_function(reduced2(trainer, 10), samples, labels, 3);
    
    	return 0;
    }
    

    跑一个简单的svm的例子,借鉴自官方的example里面svm_c_ex.cpp

    运行结果

    doing cross validation
    gamma: 1e-05    C: 1     cross validation accuracy: 0 1 
    gamma: 1e-05    C: 5     cross validation accuracy: 0 1 
    gamma: 1e-05    C: 25     cross validation accuracy: 0 1 
    gamma: 1e-05    C: 125     cross validation accuracy: 0 1 
    gamma: 1e-05    C: 625     cross validation accuracy: 0 1 
    gamma: 1e-05    C: 3125     cross validation accuracy: 0 1 
    gamma: 1e-05    C: 15625     cross validation accuracy: 0 1 
    gamma: 1e-05    C: 78125     cross validation accuracy: 0 1 
    gamma: 5e-05    C: 1     cross validation accuracy: 0 1 
    gamma: 5e-05    C: 5     cross validation accuracy: 0 1 
    gamma: 5e-05    C: 25     cross validation accuracy: 0 1 
    gamma: 5e-05    C: 125     cross validation accuracy: 0 1 
    gamma: 5e-05    C: 625     cross validation accuracy: 0 1 
    gamma: 5e-05    C: 3125     cross validation accuracy: 0 1 
    gamma: 5e-05    C: 15625     cross validation accuracy: 0 1 
    gamma: 5e-05    C: 78125     cross validation accuracy: 0 1 
    gamma: 0.00025    C: 1     cross validation accuracy: 0 1 
    gamma: 0.00025    C: 5     cross validation accuracy: 0 1 
    gamma: 0.00025    C: 25     cross validation accuracy: 0 1 
    gamma: 0.00025    C: 125     cross validation accuracy: 0 1 
    gamma: 0.00025    C: 625     cross validation accuracy: 0 1 
    gamma: 0.00025    C: 3125     cross validation accuracy: 0 1 
    gamma: 0.00025    C: 15625     cross validation accuracy: 0 1 
    gamma: 0.00025    C: 78125     cross validation accuracy: 0.990476 0.991189 
    gamma: 0.00125    C: 1     cross validation accuracy: 0 1 
    gamma: 0.00125    C: 5     cross validation accuracy: 0 1 
    gamma: 0.00125    C: 25     cross validation accuracy: 0 1 
    gamma: 0.00125    C: 125     cross validation accuracy: 0 1 
    gamma: 0.00125    C: 625     cross validation accuracy: 0 1 
    gamma: 0.00125    C: 3125     cross validation accuracy: 0.980952 0.994126 
    gamma: 0.00125    C: 15625     cross validation accuracy: 0.980952 0.991924 
    gamma: 0.00125    C: 78125     cross validation accuracy: 0.984127  0.99486 
    gamma: 0.00625    C: 1     cross validation accuracy: 0 1 
    gamma: 0.00625    C: 5     cross validation accuracy: 0 1 
    gamma: 0.00625    C: 25     cross validation accuracy: 0 1 
    gamma: 0.00625    C: 125     cross validation accuracy: 0.980952  0.99486 
    gamma: 0.00625    C: 625     cross validation accuracy: 0.980952 0.991924 
    gamma: 0.00625    C: 3125     cross validation accuracy: 0.980952 0.995595 
    gamma: 0.00625    C: 15625     cross validation accuracy: 0.987302 0.994126 
    gamma: 0.00625    C: 78125     cross validation accuracy: 0.990476  0.99486 
    gamma: 0.03125    C: 1     cross validation accuracy: 0 1 
    gamma: 0.03125    C: 5     cross validation accuracy: 0.971429 0.996329 
    gamma: 0.03125    C: 25     cross validation accuracy: 0.974603 0.992658 
    gamma: 0.03125    C: 125     cross validation accuracy: 0.980952 0.996329 
    gamma: 0.03125    C: 625     cross validation accuracy: 0.987302  0.99486 
    gamma: 0.03125    C: 3125     cross validation accuracy: 0.990476  0.99486 
    gamma: 0.03125    C: 15625     cross validation accuracy:  0.95873 0.995595 
    gamma: 0.03125    C: 78125     cross validation accuracy: 0.996825 0.995595 
    gamma: 0.15625    C: 1     cross validation accuracy: 0.952381 0.998532 
    gamma: 0.15625    C: 5     cross validation accuracy: 0.993651 0.996329 
    gamma: 0.15625    C: 25     cross validation accuracy: 0.990476 0.995595 
    gamma: 0.15625    C: 125     cross validation accuracy: 0.980952  0.99486 
    gamma: 0.15625    C: 625     cross validation accuracy: 0.949206 0.997797 
    gamma: 0.15625    C: 3125     cross validation accuracy: 0.993651 0.998532 
    gamma: 0.15625    C: 15625     cross validation accuracy: 0.987302        1 
    gamma: 0.15625    C: 78125     cross validation accuracy: 0.990476 0.997797 
    gamma: 0.78125    C: 1     cross validation accuracy: 0.952381 0.997797 
    gamma: 0.78125    C: 5     cross validation accuracy: 0.974603 0.997797 
    gamma: 0.78125    C: 25     cross validation accuracy: 0.974603        1 
    gamma: 0.78125    C: 125     cross validation accuracy: 0.984127        1 
    gamma: 0.78125    C: 625     cross validation accuracy: 0.987302        1 
    gamma: 0.78125    C: 3125     cross validation accuracy: 0.987302        1 
    gamma: 0.78125    C: 15625     cross validation accuracy: 0.987302 0.997797 
    gamma: 0.78125    C: 78125     cross validation accuracy: 0.980952 0.998532 
    
    number of support vectors in our learned_function is 209
    This is a +1 class example, the classifier output is 2.71477
    This is a +1 class example, the classifier output is -0.0102314
    This is a -1 class example, the classifier output is -4.36211
    This is a -1 class example, the classifier output is -2.16552
    
    number of support vectors in our learned_pfunct is 209
    This +1 class example should have high probability.  Its probability is: 1
    This +1 class example should have high probability.  Its probability is: 0.465781
    This -1 class example should have low probability.  Its probability is: 3.05246e-11
    This -1 class example should have low probability.  Its probability is: 5.78323e-06
    
    cross validation accuracy with only 10 support vectors: 0.993651  0.99486 
    cross validation accuracy with all the original support vectors: 0.993651 0.996329 
    展开全文
  • dlib

    2020-09-29 22:14:53
    使用opecv4.2.0和dlib19.12编译时出错:error: conversion from ‘const cv::Mat’ to non-scalar type ‘IplImage’ 问题描述 我在使用opencv和dlib做人脸关键点检测时,遇到如标题所示的编译错误,库的具体版本也...

    使用opecv4.2.0和dlib19.12编译时出错:error: conversion from ‘const cv::Mat’ to non-scalar type ‘IplImage’

    问题描述
    我在使用opencv和dlib做人脸关键点检测时,遇到如标题所示的编译错误,库的具体版本也在标题中给出了。
    原因分析
    opencv从4.1.2更迭到4.2.0时不再支持Mat类型到IplImage类型的转换。结论来自cv::cvarrToMat link error and mat to Ipimage error!!!。

    解决方案
    目前github上最新的dlib(尚未发布)已经修复了这个问题。具体的,修改dlib源码中的cv_image.h的第37行,136行,从如下代码:
    IplImage temp = img;
    修改为

    #if CV_MAJOR_VERSION > 3
    	IplImage temp = cvIplImage(img);
    #else
    	IplImage temp = img;
    #endif
    

    以上修改引用自官方,可放心使用。

    展开全文
  • Dlib Windows下安装Dlib

    2020-03-17 00:19:23
    Dlib

    Microsoft Visual Studio:https://visualstudio.microsoft.com/zh-hans/downloads/
    CMake:https://cmake.org/download/
    Dlib:https://github.com/davisking/dlib

    Dlib is a modern C++ toolkit containing machine learning algorithms and tools for creating complex software in C++ to solve real world problems. See http://dlib.net for the main project documentation and API reference.
    Dlib是一个现代的C ++工具箱,其中包含机器学习算法和工具,这些工具和工具可以用C ++创建复杂的软件来解决实际问题。 有关主要项目文档和API参考,请参见http://dlib.net


    一、C/C++编译环境

    Microsoft Visual Studio下载页面,可以通过安装完整版的Visual Studio,或者安装生成工具,安装过程中选择C++生成工具。
    没有安装的话会出现以下错误:

    windows CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
    windows CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
    

    在这里插入图片描述
    在这里插入图片描述

    二、安装CMake

    CMake官网下载CMake并安装,也可以通过pip install cmake安装(很慢)。
    没有安装的话会提示缺少CMake。
    在这里插入图片描述

    三、安装Dlib

    按照Dlib Github上的README安装就可以。
    下载,解压,cd dlib-mastermkdir buildcd buildcmake ..cmake --build .cd ..python setup.py install
    在这里插入图片描述

    展开全文
  • Py之dlib:Python库之dlib库的简介、安装、使用方法详细攻略 目录 dlib库的简介 dlib库的安装 dlib库的使用函数 0、利用dlib.get_frontal_face_detector函数实现人脸检测可视化 1、hog提取特征的函数 2...

    Py之dlib:Python库之dlib库的简介、安装、使用方法详细攻略

     

     

     

    目录

    dlib库的简介

    dlib库的安装

    dlib库的使用函数

    0、利用dlib.get_frontal_face_detector函数实现人脸检测可视化

    1、hog提取特征的函数

    2、CNN提取特征的函数

     


     

    dlib库的简介

        一个机器学习的开源库,包含了机器学习的很多算法,使用起来很方便,直接包含头文件即可,并且不依赖于其他库(自带图像编解码库源码)。Dlib可以帮助您创建很多复杂的机器学习方面的软件来帮助解决实际问题。目前Dlib已经被广泛的用在行业和学术领域,包括机器人,嵌入式设备,移动电话和大型高性能计算环境。

    Dlib是一个使用现代C++技术编写的跨平台的通用库,遵守Boost Software licence. 主要特点如下: 

    • 完善的文档:每个类每个函数都有详细的文档,并且提供了大量的示例代码,如果你发现文档描述不清晰或者没有文档,告诉作者,作者会立刻添加。 
    • 可移植代码:代码符合ISO C++标准,不需要第三方库支持,支持win32、Linux、Mac OS X、Solaris、HPUX、BSDs 和 POSIX 系统 
    • 线程支持:提供简单的可移植的线程API 
    • 网络支持:提供简单的可移植的Socket API和一个简单的Http服务器 
    • 图形用户界面:提供线程安全的GUI API 
    • 数值算法:矩阵、大整数、随机数运算等 
    • 机器学习算法:
    • 图形模型算法: 
    • 图像处理:支持读写Windows BMP文件,不同类型色彩转换 
    • 数据压缩和完整性算法:CRC32、Md5、不同形式的PPM算法 
    • 测试:线程安全的日志类和模块化的单元测试框架以及各种测试assert支持
    • 一般工具:XML解析、内存管理、类型安全的big/little endian转换、序列化支持和容器类
       


    dlib pypi
    dlib库
    dlib c++ library

     

     

    dlib库的安装

    本博客提供三种方法进行安装

    T1方法:pip install dlib

    此方法是需要在你安装cmake、Boost环境的计算机使用

    T2方法:conda install -c menpo dlib=18.18

    此方法适合那些已经安装好conda库的环境的计算机使用,conda库的安装本博客有详细攻略,请自行翻看。

    T3方法:pip install dlib-19.8.1-cp36-cp36m-win_amd64.whl

    dlib库的whl文件——dlib-19.7.0-cp36-cp36m-win_amd64.rar

    dlib-19.3.1-cp35-cp35m-win_amd64.whl

    哈哈,大功告成!如有资料或问题需求,请留言!

     

     

    dlib库的使用函数

    0、利用dlib.get_frontal_face_detector函数实现人脸检测可视化

    CV之dlib:利用dlib.get_frontal_face_detector函数实现人脸检测

     

    1、hog提取特征的函数

    dlib.get_frontal_face_detector()    #人脸特征提取器,该函数是在C++里面定义的

    help(dlib.get_frontal_face_detector())
    Help on fhog_object_detector in module dlib.dlib object:
    
    class fhog_object_detector(Boost.Python.instance)
     |  This object represents a sliding window histogram-of-oriented-gradients based object detector.
     |
     |  Method resolution order:
     |      fhog_object_detector
     |      Boost.Python.instance
     |      builtins.object
     |
     |  Methods defined here:
     |
     |  __call__(...)
     |      __call__( (fhog_object_detector)arg1, (object)image [, (int)upsample_num_times=0]) -> rectangles :
     |          requires
     |              - image is a numpy ndarray containing either an 8bit grayscale or RGB
     |                image.
     |              - upsample_num_times >= 0
     |          ensures
     |              - This function runs the object detector on the input image and returns
     |                a list of detections.
     |              - Upsamples the image upsample_num_times before running the basic
     |                detector.
     |
     |  __getstate__(...)
     |      __getstate__( (fhog_object_detector)arg1) -> tuple
     |
     |  __init__(...)
     |      __init__( (object)arg1) -> None
     |
     |      __init__( (object)arg1, (str)arg2) -> object :
     |          Loads an object detector from a file that contains the output of the
     |          train_simple_object_detector() routine or a serialized C++ object of type
     |          object_detector<scan_fhog_pyramid<pyramid_down<6>>>.
     |
     |  __reduce__ = <unnamed Boost.Python function>(...)
     |
     |  __setstate__(...)
     |      __setstate__( (fhog_object_detector)arg1, (tuple)arg2) -> None
     |
     |  run(...)
     |      run( (fhog_object_detector)arg1, (object)image [, (int)upsample_num_times=0 [, (float)adjust_threshold=0.0]]) -> tuple :
     |          requires
     |              - image is a numpy ndarray containing either an 8bit grayscale or RGB
     |                image.
     |              - upsample_num_times >= 0
     |          ensures
     |              - This function runs the object detector on the input image and returns
     |                a tuple of (list of detections, list of scores, list of weight_indices).
     |              - Upsamples the image upsample_num_times before running the basic
     |                detector.
     |
     |  save(...)
     |      save( (fhog_object_detector)arg1, (str)detector_output_filename) -> None :
     |          Save a simple_object_detector to the provided path.
     |
     |  ----------------------------------------------------------------------
     |  Static methods defined here:
     |
     |  run_multiple(...)
     |      run_multiple( (list)detectors, (object)image [, (int)upsample_num_times=0 [, (float)adjust_threshold=0.0]]) -> tuple :
     |          requires
     |              - detectors is a list of detectors.
     |              - image is a numpy ndarray containing either an 8bit grayscale or RGB
     |                image.
     |              - upsample_num_times >= 0
     |          ensures
     |              - This function runs the list of object detectors at once on the input image and returns
     |                a tuple of (list of detections, list of scores, list of weight_indices).
     |              - Upsamples the image upsample_num_times before running the basic
     |                detector.
     |
     |  ----------------------------------------------------------------------
     |  Data and other attributes defined here:
     |
     |  __instance_size__ = 160
     |
     |  __safe_for_unpickling__ = True
     |
     |  ----------------------------------------------------------------------
     |  Methods inherited from Boost.Python.instance:
     |
     |  __new__(*args, **kwargs) from Boost.Python.class
     |      Create and return a new object.  See help(type) for accurate signature.
     |
     |  ----------------------------------------------------------------------
     |  Data descriptors inherited from Boost.Python.instance:
     |
     |  __dict__
     |
     |  __weakref__

    2、CNN提取特征的函数

    cnn_face_detector = dlib.cnn_face_detection_model_v1(cnn_face_detection_model)

    help(dlib.cnn_face_detection_model_v1)
    Help on class cnn_face_detection_model_v1 in module dlib.dlib:
    
    class cnn_face_detection_model_v1(Boost.Python.instance)
     |  This object detects human faces in an image.  The constructor loads the face detection model from a file. You can download a pre-trained model from http://dlib.net/files/mmod_human_face_detector.dat.bz2.
     |
     |  Method resolution order:
     |      cnn_face_detection_model_v1
     |      Boost.Python.instance
     |      builtins.object
     |
     |  Methods defined here:
     |
     |  __call__(...)
     |      __call__( (cnn_face_detection_model_v1)arg1, (object)img [, (int)upsample_num_times=0]) -> mmod_rectangles :
     |          Find faces in an image using a deep learning model.
     |                    - Upsamples the image upsample_num_times before running the face
     |                      detector.
     |
     |      __call__( (cnn_face_detection_model_v1)arg1, (list)imgs [, (int)upsample_num_times=0 [, (int)batch_size=128]]) -> mmod_rectangless :
     |          takes a list of images as input returning a 2d list of mmod rectangles
     |
     |  __init__(...)
     |      __init__( (object)arg1, (str)arg2) -> None
     |
     |  __reduce__ = <unnamed Boost.Python function>(...)
     |
     |  ----------------------------------------------------------------------
     |  Data and other attributes defined here:
     |
     |  __instance_size__ = 984
     |
     |  ----------------------------------------------------------------------
     |  Methods inherited from Boost.Python.instance:
     |
     |  __new__(*args, **kwargs) from Boost.Python.class
     |      Create and return a new object.  See help(type) for accurate signature.
     |
     |  ----------------------------------------------------------------------
     |  Data descriptors inherited from Boost.Python.instance:
     |
     |  __dict__
     |
     |  __weakref__

     

    inline frontal_face_detector get_frontal_face_detector()
     


     

    展开全文
  • Dlib unity

    2018-12-19 17:47:01
    基于dlib版unity的人脸识别,Dlib FaceLandmark Detector 1.2.0亲测可用
  • dlib软件包

    2017-12-22 15:14:35
    Dlib19.8库版本,Dlib库是一个跨平台的C++库,支持C++和Python,提供很多功能,是个不错的学习资料,供初学者使用
  • dlib源文件

    2016-11-09 09:09:08
    官方网址为dlib.net,这是一个版本dlib-19.2,一个不错的开源库,图像处理和机器学习,有例子代码,在windows下,用cmake编译,在自己的工程中加入dlib的源文件根路径和dlib.lib编译库的路径即可
  • Dlib 编译好的dLib 19.10

    2018-04-13 18:18:52
    编译好的最新dlib 版本19.10,里面包含debug 和 release 编译的lib库
  • dlib C++ library Dlib is a modern C++ toolkit containing machine learning algorithms and tools for creating complex software in C++ to solve real world problems. See ...
  • 安装dlib

    千次阅读 2019-04-28 17:37:38
    安装dlib 标签: python 直接安装法 原来以为安装太麻烦,但是下面的方法确实可以使用,真的简单,所以转载做一个纪录。转载自python 安装dlib dlib是人脸识别比较有名的库,有c++、Python的接口。使用dlib可以...
  • Dlib介绍

    万次阅读 2019-01-05 23:12:36
    Dlib介绍 Dlib是一个现代化的C ++工具箱,其中包含用于在C ++中创建复杂软件以解决实际问题的机器学习算法和工具。它广泛应用于工业界和学术界,包括机器人,嵌入式设备,移动电话和大型高性能计算环境。Dlib的开源...
  • dlib源码vs2015编译后 生成dlib库文件 里面有库文件 还是demo 直接打开就可以调式dlib源码。配套的opcn库在这下载,也是编译好了的:https://download.csdn.net/download/weixin_42713739/11181285
  • Dlib各种组件

    2020-06-09 09:01:07
    大名鼎鼎的Dlib(人脸特征点定位神器),官网下载的用VS2015运行报错,故而搬运了这个可以运行的版本。 大名鼎鼎的Dlib(人脸特征点定位神器),官网下载的用VS2015运行报错,故而搬运了这个可以运行的版本。
  • dlib库文件

    2018-07-31 11:53:45
    dlib库文件 dlib-19.7.0-cp36-cp36m-win_amd64.rar
  • dlib模型数据

    2019-05-07 15:06:13
    dlib模型数据,包括dlib_face_recognition_resnet_model_v1.dat、mmod_human_face_detector.dat、shape_predictor_5_face_landmarks.dat、shape_predictor_68_face_landmarks.dat
  • Dlib

    千次阅读 2019-03-26 20:10:27
    Dlib是开源的、免费的;官网和git地址:#官网http://dlib.net/#githubhttps://github.com/davisking/dlib
  • 用64位vs2013生成的c++人脸检测dlib库的动态链接库 dlib.dll
  • Dlib安装教程

    2018-01-25 15:52:59
    Dlib安装教程,详细介绍了,开源库dlib的安装过程,以及依赖 库的安装。
  • dlib库安装

    2018-11-22 23:47:13
    1、下载安装pycharm  ... 2、下载安装Anaconda3  ... 随后在环境变量添加:D:\software\Anaconda3;D:\software\Anaconda3\Scripts;...pip install dlib-xxx.whl 即可。(dlib-xxx.whl 对应下载的文件名) 最后测试一下
  • 3.用VIS2019打开dlib-master的安装目录并且开始编辑json文件,开启USE_AVX_INSTRUCTIONS,失效USE_SSE2_INSTRUCTIONS   4.进入dlib的安装目录 #不用像网上说的那样加什么--yes python .\setup.py install 5.结果 ...
  • dlib-androidPurposePort dlib to Android platformYou can build it to dynamic or static library for Android. You can also build dlib's sample to Android executable file.You can refer to dlib-android-app...
  • dlib 标签转换

    2018-09-10 21:08:52
    dlib标签转换,希望对大家有用。
  • dlib-android 目的 将到Android平台 您可以将其构建为Android的动态或静态库。 您也可以将dlib的示例构建为Android可执行文件。 您可以参考来演示dlib-android的功能 抓住来源 $ git clone --recursive ...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 13,196
精华内容 5,278
关键字:

dlib