gpt4 book ai didi

c++ - 如何使用 DLIB 库加载 jpeg 文件?

转载 作者:行者123 更新时间:2023-11-30 03:49:10 36 4
gpt4 key购买 nike

尝试运行从 Here 下载的示例程序后,我了解使用 jpeg 文件,我必须向项目添加 #define DLIB_JPEG_SUPPORT 指令。但在此之前,需要下载 jpeg 库并将其添加到项目中。我做了这些步骤:

1.从here下载jpegsr9a.zip并解压缩。

2.下载WIN32.mak并粘贴到jpeg根文件夹

3.从 visual studio 2013 工具打开开发者命令提示符

4.在命令提示符下输入:nmake -f makefile.vc setup-v10

5.完成这些步骤后,jpeg.sln 被创建,注意当我在 VS2013 中打开 jpeg.sln 时,消息出现:

enter image description here

也许问题的根源从这里开始,我不知道

6.使用正确的配置构建 jpeg.sln(我使用不同的配置多次构建它,最近我使用 this 构建它。)在构建结束时出现错误:“无法启动 jpeg.lib”但是在发布文件夹或调试文件夹(取决于配置)中创建了 jpeg.lib

  1. 打开使用 DLIB 检测人脸的主项目,我将 jpeg 根文件夹添加到附加包含目录,将 jepegroot/release 添加到附加库目录,然后将 UseLibrary 依赖项更改为"is",我还将 jpeg.lib 添加到家属。

在构建项目期间出现错误: enter image description here

这是我尝试构建和运行的源代码

//#define HAVE_BOOLEAN
#define DLIB_JPEG_SUPPORT
#include <dlib/image_processing/frontal_face_detector.h>
#include <dlib/image_processing/render_face_detections.h>
#include <dlib/image_processing.h>
#include<dlib/image_transforms.h>
#include <dlib/gui_widgets.h>
#include <dlib/image_io.h>
#include <iostream>
//
using namespace dlib;
using namespace std;

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

int main(int argc, char** argv)
{
try
{
// This example takes in a shape model file and then a list of images to
// process. We will take these filenames in as command line arguments.
// Dlib comes with example images in the examples/faces folder so give
// those as arguments to this program.
if (argc == 1)
{
cout << "Call this program like this:" << endl;
cout << "./face_landmark_detection_ex shape_predictor_68_face_landmarks.dat faces/*.jpg" << endl;
cout << "\nYou can get the shape_predictor_68_face_landmarks.dat file from:\n";
cout << "http://dlib.net/files/shape_predictor_68_face_landmarks.dat.bz2" << endl;
return 0;
}

// We need a face detector. We will use this to get bounding boxes for
// each face in an image.
frontal_face_detector detector = get_frontal_face_detector();
// And we also need a shape_predictor. This is the tool that will predict face
// landmark positions given an image and face bounding box. Here we are just
// loading the model from the shape_predictor_68_face_landmarks.dat file you gave
// as a command line argument.
shape_predictor sp;
deserialize(argv[1])>>sp;


image_window win, win_faces;
// Loop over all the images provided on the command line.
for (int i = 2; i < argc; ++i)
{
cout << "processing image " << argv[i] << endl;
array2d<rgb_pixel> img;
load_image(img, argv[i]);
// Make the image larger so we can detect small faces.
pyramid_up(img);

// Now tell the face detector to give us a list of bounding boxes
// around all the faces in the image.
std::vector<rectangle> dets = detector(img);
cout << "Number of faces detected: " << dets.size() << endl;

// Now we will go ask the shape_predictor to tell us the pose of
// each face we detected.
std::vector<full_object_detection> shapes;
for (unsigned long j = 0; j < dets.size(); ++j)
{
full_object_detection shape = sp(img, dets[j]);
cout << "number of parts: " << shape.num_parts() << endl;
cout << "pixel position of first part: " << shape.part(0) << endl;
cout << "pixel position of second part: " << shape.part(1) << endl;
// You get the idea, you can get all the face part locations if
// you want them. Here we just store them in shapes so we can
// put them on the screen.
shapes.push_back(shape);
}

// Now let's view our face poses on the screen.
win.clear_overlay();
win.set_image(img);
win.add_overlay(render_face_detections(shapes));

// We can also extract copies of each face that are cropped, rotated upright,
// and scaled to a standard size as shown here:
dlib::array<array2d<rgb_pixel> > face_chips;
extract_image_chips(img, get_face_chip_details(shapes), face_chips);
win_faces.set_image(tile_images(face_chips));

cout << "Hit enter to process the next image..." << endl;
cin.get();
}
}
catch (exception& e)
{
cout << "\nexception thrown!" << endl;
cout << e.what() << endl;
}
}

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

我可以选择其他选择,但我花了太多时间到达这里,我想知道如何解决这个问题并在使用 DLIB 时加载 jpeg 文件

我还阅读了这些链接:

Compiling libjpeg

http://www.dahlsys.com/misc/compiling_ijg_libjpeg/index.html

dlib load jpeg files

http://sourceforge.net/p/dclib/discussion/442518/thread/8a0d42dc/

最佳答案

我按照以下说明解决了我的问题,请按照说明操作。

- 在VC++中添加include目录 enter image description here

- 包含 source.cpp

enter image description here

- 将dlib/external/libjpeg中的文件添加到项目中

enter image description here

- 在预处理器中定义

enter image description here

-- 您不需要使用任何额外的库。

关于c++ - 如何使用 DLIB 库加载 jpeg 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32736149/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com