Visual Studio 2010中dlib库的使用

发布于 2024-11-06 06:38:22 字数 699 浏览 0 评论 0原文

我想在我的小论文项目中使用 dlib 寻求帮助。具体来说,我需要使用 BOBYQA 优化例程。

我正在用 C 语言在 MS Visual Studio 2010 Express 中编写该项目。我对使用 dlib 等库的经验为零,而且我不知道 makefile 是什么以及如何编写 makefile。
我在此处找到了一些提示,但由于我在这方面缺乏经验,我只是不知道如何在我的代码中编译和使用 dlib。

我想询问如何将 dlib 合并到我的代码中的分步说明,即:

  • 我应该从 zip 文件
  • 我应该向 Visual Studio 项目添加一些文件吗?
  • 还有其他我还没有意识到的问题吗?

我也非常感谢一个简单的使用示例代码(我要优化的函数有 6 个参数)。

I would like to ask for help in using dlib for my little thesis project. Specifically, I need to use the BOBYQA optimisation routine.

I am writing the project in MS Visual Studio 2010 Express in C language. I have zero experience in using libraries such as dlib and I don't have any idea what a makefile is and how to write one.
I have found a little hint here but due to my lack of experience in the matter, I just can't figure out how to compile and make use of dlib in my code.

I would like to ask for a step by step instruction how to incorporate dlib into my code, i.e.:

  • where exactly should I extract the dlib folder from the zip file?
  • should I add some files to the Visual Studio project?
  • are there any other problems I am not yet aware of?

I would also be very grateful for a simple example code of usage (my function to be optimised has 6 parameters).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

孤星 2024-11-13 06:38:22

如果您使用 Visual Studio,则不必使用 makefile。您可以像平常一样创建项目。然后,要使用 dlib,您只需将 dlib/all/source.cpp 添加到您的项目中,并将包含 dlib 文件夹的文件夹添加到您的包含搜索路径中。如果您只使用 BOBYQA,那么您甚至不必添加 dlib/all/source.cpp。

如果这是您第一次使用 Visual Studio 并且您对如何创建项目感到困惑,那么我建议使用 CMake。它非常易于使用,并且会自动为您设置合适的 Visual Studio 项目。此外,dlib examples/optimization_ex.cpp 附带了一个示例应用程序,它展示了如何调用BOBYQA 和此示例可以使用 cmake 使用以下命令进行构建:

cd examples
mkdir build
cd build
cmake ..

然后您应该在构建文件夹中找到一个 Visual Studio 项目,所有设置都已准备就绪。将设置它来构建所有 dlib 示例。如果您编辑示例文件夹中的 CMakeLists.txt 文件,则可以删除您不感兴趣的示例。

If you are using visual studio then you don't have to use makefiles. You can create your project just like you normally would. Then to use dlib all you have to do is add dlib/all/source.cpp to your project and add the folder containing the dlib folder into your include search path. If you only use BOBYQA then you don't even have to add dlib/all/source.cpp.

If this is your first time using visual studio and you are getting hung up on how to create the project then I would suggest using CMake. It's very easy to use and it will setup an appropriate visual studio project for you automatically. Moreover, there is an example application which comes with dlib examples/optimization_ex.cpp which shows how to call BOBYQA and this example can be built using cmake with the following commands:

cd examples
mkdir build
cd build
cmake ..

Then you should find a visual studio project inside the build folder all setup and ready to go. It will be setup to build all the dlib examples. If you edit the CMakeLists.txt file in the examples folders you can remove examples you aren't interested in.

千纸鹤 2024-11-13 06:38:22

我尝试了两种方法(1)和(2),但这不是Dlib的意图。方法(3)此时看起来可行。

Visual Studio 2013 中有一个示例,位于 如何设置Dlib 与 Visual Studio 2013 一起使用,无需 CMake?

与2010版本的区别是,你必须使用Property ->配置属性-> (1) VC++ 目录或 (2) C/C++ ->常规

关于source.cpp 文件,我刚刚添加了源文件。

我成功应用的方法是(到目前为止)

(3)#include“dlib/image_processing/frontal_face_detector.h”

dlib文件夹应位于当前源目录(Visual Studio 在哪里查找 C++ 头文件?https://msdn.microsoft.com/en-us /library/36k2cdd4(v=VS.100).aspx 了解详细信息)

I tried two methods (1) and (2) under but it wasn't the intention of Dlib. The method (3) looks like working at this moment.

There is an example in Visual Studio 2013 at How to setup Dlib with Visual Studio 2013 without CMake?.

The difference in 2010 version, you have to use Property -> Configuration Properties -> (1) VC++ Directories or (2) C/C++ -> General

Regarding the source.cpp file, I just added on Source Files.

The method that I successfully applied is (so far)

(3) #include "dlib/image_processing/frontal_face_detector.h"

The dlib folder should be located in current source directory (Where does Visual Studio look for C++ header files? and https://msdn.microsoft.com/en-us/library/36k2cdd4(v=VS.100).aspx for details)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文