如何使用 DLIB 库加载 jpeg 文件?
how to load jpeg file using DLIB libarary?
在尝试 运行 从 Here 下载的示例程序后,我明白要处理 jpeg 文件,我必须添加 #define DLIB_JPEG_SUPPORT 指令到项目。但在此之前,需要下载 jpeg 库并将其添加到项目中。我做了这些步骤:
1.Download jpegsr9a.zip 来自 here 并解压。
2.Download WIN32.mak 粘贴到jpeg根文件夹
3.Open 来自 visual studio 2013 工具的开发人员命令提示
4.In 命令提示符类型:nmake -f makefile.vc setup-v10
5.After 这些步骤jpeg.sln 创建,注意是当我在 VS2013 中打开 jpeg.sln 消息来:
问题的根源可能从这里开始,我不知道
6.Build 具有正确配置的 jpeg.sln (我用不同的配置构建了很多次,最近我使用 this 构建了它。)
在构建结束时出现错误:"unable to start jpeg.lib"
但在发布文件夹或调试文件夹中(取决于配置)jpeg.lib 已创建
- 打开使用DLIB检测人脸的主项目,我将jpeg根文件夹添加到Additonal Include Directory和jepegroot/release到Additional Libarary Directories,然后将UseLibrary dependencies更改为"yes",我也添加 jpeg.lib 到依赖项。
在构建项目期间出现错误:
这是我尝试构建的来源 运行
//#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++中添加包含目录
- 包括source.cpp
- 将 dlib/external/libjpeg 中的添加文件添加到项目
- 在预处理器中定义
-- 您不需要使用任何额外的库。
在尝试 运行 从 Here 下载的示例程序后,我明白要处理 jpeg 文件,我必须添加 #define DLIB_JPEG_SUPPORT 指令到项目。但在此之前,需要下载 jpeg 库并将其添加到项目中。我做了这些步骤:
1.Download jpegsr9a.zip 来自 here 并解压。
2.Download WIN32.mak 粘贴到jpeg根文件夹
3.Open 来自 visual studio 2013 工具的开发人员命令提示
4.In 命令提示符类型:nmake -f makefile.vc setup-v10
5.After 这些步骤jpeg.sln 创建,注意是当我在 VS2013 中打开 jpeg.sln 消息来:
问题的根源可能从这里开始,我不知道
6.Build 具有正确配置的 jpeg.sln (我用不同的配置构建了很多次,最近我使用 this 构建了它。) 在构建结束时出现错误:"unable to start jpeg.lib" 但在发布文件夹或调试文件夹中(取决于配置)jpeg.lib 已创建
- 打开使用DLIB检测人脸的主项目,我将jpeg根文件夹添加到Additonal Include Directory和jepegroot/release到Additional Libarary Directories,然后将UseLibrary dependencies更改为"yes",我也添加 jpeg.lib 到依赖项。
在构建项目期间出现错误:
这是我尝试构建的来源 运行
//#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++中添加包含目录
- 包括source.cpp
- 将 dlib/external/libjpeg 中的添加文件添加到项目
- 在预处理器中定义
-- 您不需要使用任何额外的库。