python - macOS - 安装 dlib 时遇到问题

标签 python c++ x11 dlib

我想使用 Dlib 进行面部标志检测,并尝试将其安装在我的 macOS Sierra 上。我按照 main GitHub Repo for dlib 中的说明进行操作.

进入示例文件夹后,我首先执行了以下命令,没有出现错误:

mkdir build; cd build; cmake .. ; cmake --build .

回到父目录,我执行了以下命令:

sudo python2.7 setup.py install

完成 38% 后遇到 20 多个错误:

[ 35%] Building CXX object dlib_build/CMakeFiles/dlib.dir/timer/timer.cpp.o
[ 35%] Building CXX object dlib_build/CMakeFiles/dlib.dir/stack_trace.cpp.o
[ 36%] Building CXX object dlib_build/CMakeFiles/dlib.dir/gui_widgets/fonts.cpp.o
In file included from /Users/Ajay/Framework_libraries/dlib/dlib/gui_widgets/fonts.cpp:14:
/Users/Ajay/Framework_libraries/dlib/dlib/gui_widgets/nativefont.h:313:21: error: use of undeclared identifier 'XAllocColor'
                    XAllocColor(d, cmap, &xcol);
                    ^
/Users/Ajay/Framework_libraries/dlib/dlib/gui_widgets/nativefont.h:319:36: error: use of undeclared identifier 'XmbTextExtents'; did you mean 'XTextExtents'?
                            return XmbTextExtents(fs, str, len, ink, logical);
                                   ^~~~~~~~~~~~~~
                                   XTextExtents
/Users/Ajay/Framework_libraries/dlib/dlib/gui_widgets/nativefont.h:318:43: note: 'XTextExtents' declared here
                        inline static int XTextExtents (XFontSet fs, char *str, int len, XRectangle *ink, XRectangle *logical){
                                          ^
/Users/Ajay/Framework_libraries/dlib/dlib/gui_widgets/nativefont.h:322:36: error: use of undeclared identifier 'XwcTextExtents'; did you mean 'XTextExtents'?
                            return XwcTextExtents(fs, str, len, ink, logical);
                                   ^~~~~~~~~~~~~~
                                   XTextExtents
/Users/Ajay/Framework_libraries/dlib/dlib/gui_widgets/nativefont.h:321:43: note: 'XTextExtents' declared here
                        inline static int XTextExtents (XFontSet fs, wchar_t *str, int len, XRectangle *ink, XRectangle *logical){
                                          ^
/Users/Ajay/Framework_libraries/dlib/dlib/gui_widgets/nativefont.h:325:29: error: use of undeclared identifier 'XmbDrawString'; did you mean 'XDrawString'?
                            XmbDrawString(d, w, fs, gc, x, y, str, num_bytes);
                            ^~~~~~~~~~~~~
                            XDrawString
/Users/Ajay/Framework_libraries/dlib/dlib/gui_widgets/nativefont.h:324:44: note: 'XDrawString' declared here
                        inline static void XDrawString(Display *d, Window w, XFontSet fs, GC gc, int x, int y, char *str, int num_bytes){
                                           ^
/Users/Ajay/Framework_libraries/dlib/dlib/gui_widgets/nativefont.h:328:29: error: use of undeclared identifier 'XwcDrawString'; did you mean 'XDrawString'?
                            XwcDrawString(d, w, fs, gc, x, y, str, num_bytes);
                            ^~~~~~~~~~~~~
                            XDrawString
/Users/Ajay/Framework_libraries/dlib/dlib/gui_widgets/nativefont.h:327:44: note: 'XDrawString' declared here
                        inline static void XDrawString(Display *d, Window w, XFontSet fs, GC gc, int x, int y, wchar_t *str, int num_bytes){
                                           ^
/Users/Ajay/Framework_libraries/dlib/dlib/gui_widgets/nativefont.h:334:29: error: use of undeclared identifier 'XOpenDisplay'
                        d = XOpenDisplay(NULL);
                            ^
/Users/Ajay/Framework_libraries/dlib/dlib/gui_widgets/nativefont.h:337:33: error: use of undeclared identifier 'XOpenDisplay'
                            d = XOpenDisplay(":0.0");
                                ^
/Users/Ajay/Framework_libraries/dlib/dlib/gui_widgets/nativefont.h:369:29: error: use of undeclared identifier 'XFreeFontSet'
                            XFreeFontSet(d, fs);
                            ^
/Users/Ajay/Framework_libraries/dlib/dlib/gui_widgets/nativefont.h:371:30: error: use of undeclared identifier 'XCreateFontSet'
                        fs = XCreateFontSet(d, fontset, &mlist, &mcount, &def_str);
                             ^
/Users/Ajay/Framework_libraries/dlib/dlib/gui_widgets/nativefont.h:376:34: error: use of undeclared identifier 'XExtentsOfFontSet'
                        extent = XExtentsOfFontSet(fs);
                                 ^
/Users/Ajay/Framework_libraries/dlib/dlib/gui_widgets/nativefont.h:379:25: error: use of undeclared identifier 'XFreeStringList'; did you mean 'XwcFreeStringList'?
                        XFreeStringList(mlist);
                        ^~~~~~~~~~~~~~~
                        XwcFreeStringList
/Users/Ajay/anaconda/include/X11/Xutil.h:777:13: note: 'XwcFreeStringList' declared here
extern void XwcFreeStringList(
            ^
In file included from /Users/Ajay/Framework_libraries/dlib/dlib/gui_widgets/fonts.cpp:14:
/Users/Ajay/Framework_libraries/dlib/dlib/gui_widgets/nativefont.h:379:41: error: cannot initialize a parameter of type 'wchar_t **' with an lvalue of type 'char **'
                        XFreeStringList(mlist);
                                        ^~~~~
/Users/Ajay/anaconda/include/X11/Xutil.h:781:1: note: passing argument to parameter here
);
^
In file included from /Users/Ajay/Framework_libraries/dlib/dlib/gui_widgets/fonts.cpp:14:
/Users/Ajay/Framework_libraries/dlib/dlib/gui_widgets/nativefont.h:388:29: error: use of undeclared identifier 'XFreeGC'
                            XFreeGC(d, gc);
                            ^
/Users/Ajay/Framework_libraries/dlib/dlib/gui_widgets/nativefont.h:389:29: error: use of undeclared identifier 'XFreePixmap'
                            XFreePixmap(d, pix);
                            ^
/Users/Ajay/Framework_libraries/dlib/dlib/gui_widgets/nativefont.h:393:103: error: use of undeclared identifier 'XDefaultDepth'
                        pix = XCreatePixmap(d, DefaultRootWindow(d), pix_width_prev, pix_height_prev, XDefaultDepth(d, DefaultScreen(d)));
                                                                                                      ^
/Users/Ajay/Framework_libraries/dlib/dlib/gui_widgets/nativefont.h:394:30: error: use of undeclared identifier 'XCreateGC'
                        gc = XCreateGC(d, pix, 0, NULL);
                             ^
/Users/Ajay/Framework_libraries/dlib/dlib/gui_widgets/nativefont.h:398:21: error: use of undeclared identifier 'XSetForeground'
                    XSetForeground(d, gc, backcolor);
                    ^
/Users/Ajay/Framework_libraries/dlib/dlib/gui_widgets/nativefont.h:399:21: error: use of undeclared identifier 'XSetBackground'
                    XSetBackground(d, gc, backcolor);
                    ^
/Users/Ajay/Framework_libraries/dlib/dlib/gui_widgets/nativefont.h:400:21: error: use of undeclared identifier 'XFillRectangle'
                    XFillRectangle(d, pix, gc, 0, 0, width, height);
                    ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make[2]: *** [dlib_build/CMakeFiles/dlib.dir/gui_widgets/fonts.cpp.o] Error 1
make[1]: *** [dlib_build/CMakeFiles/dlib.dir/all] Error 2
make: *** [all] Error 2
error: cmake build failed!

稍微研究一下,我觉得有一条小路径(到 python)我需要更改才能让一切正常工作。引用a similar problem ,他更改了 CMakeCache.txt 中的一些路径,但我不确定是哪一行/哪一部分。此外,还有 4 个 CMakeCache.txt 文件。我应该更改哪一个(如果有的话)?

Ajays-MacBook-Pro:dlib Ajay$ find . -name "CMakeCache.txt"
./examples/build/CMakeCache.txt
./examples/build/cpp11_test_build/CMakeCache.txt
./tools/python/build/CMakeCache.txt
./tools/python/build/cpp11_test_build/CMakeCache.txt

还有其他解决办法吗?我应该怎么办?任何帮助将不胜感激!

最佳答案

看我的回答here

长话短说,你可以得到这个问题even with xQuartz installed .

Git 中的最新版本似乎可以工作,但 PyPi 存储库尚未更新。

在那之前,使用这些命令:

git clone https://github.com/davisking/dlib.git
cd dlib
pip install .

关于python - macOS - 安装 dlib 时遇到问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41289426/

相关文章:

c++ - 对按值和按引用的参数感到困惑

python - 下载的 Keras 数据集存储在哪里?

python - 快速查找二维数组中的多个最大值

python - 如何用Python编写数学组合公式编码

c++ - 如何在 C++ 中将用户输入验证为 double ?

c - 在 x11 中记录多个按键

python - 如何在不替换其他字母的情况下替换某个字母?

c++ - INT 在 FOR 循环外保持不变

c - XLib:全屏后如何返回窗口模式?

linux - evtest 没有给出扫描值