如何在Xcode项目中使用dlib face_recognition?

问题描述 投票:2回答:1

我是编程新手。我将dlib添加到我的xcode项目中,如示例https://github.com/zweigraf/face-landmarking-ios所示。它的工作很棒。

如何添加脸部识别等其他功能?我需要将面部中的每个面部图像转换为128D矢量。我试图重写这个cpp代码,以便在我的项目中使用它。 https://github.com/davisking/dlib/blob/master/examples/dnn_imagenet_ex.cpp

但是我收到了编译错误。

显示最近的消息:-1:忽略文件../libdlib.a,文件是为归档而构建的,而不是被链接的体系结构(armv7):../ libdlib.a

和armv64一样的错误。

//face_recognition.hpp

class face_recognition {
public:
    std::vector<matrix<float,0,1>> compute_face_descriptor(dlib::array2d<dlib::rgb_pixel> &img, dlib::full_object_detection shape) {
        anet_type net;
        deserialize("dlib_face_recognition_resnet_model_v1.dat") >> net;
        std::vector<matrix<rgb_pixel>> faces;
        matrix<rgb_pixel> face_chip;
        extract_image_chip(img, get_face_chip_details(shape,150,0.25), face_chip);
        faces.push_back(move(face_chip));

        return net(faces);
    }

private:
    template <template <int,template<typename>class,int,typename> class block, int N, template<typename>class BN, typename SUBNET>
    using residual = add_prev1<block<N,BN,1,tag1<SUBNET>>>;

    template <template <int,template<typename>class,int,typename> class block, int N, template<typename>class BN, typename SUBNET>
    using residual_down = add_prev2<avg_pool<2,2,2,2,skip1<tag2<block<N,BN,2,tag1<SUBNET>>>>>>;

    template <int N, template <typename> class BN, int stride, typename SUBNET>
    using block  = BN<con<N,3,3,1,1,relu<BN<con<N,3,3,stride,stride,SUBNET>>>>>;

    template <int N, typename SUBNET> using ares      = relu<residual<block,N,affine,SUBNET>>;
    template <int N, typename SUBNET> using ares_down = relu<residual_down<block,N,affine,SUBNET>>;

    template <typename SUBNET> using alevel0 = ares_down<256,SUBNET>;
    template <typename SUBNET> using alevel1 = ares<256,ares<256,ares_down<256,SUBNET>>>;
    template <typename SUBNET> using alevel2 = ares<128,ares<128,ares_down<128,SUBNET>>>;
    template <typename SUBNET> using alevel3 = ares<64,ares<64,ares<64,ares_down<64,SUBNET>>>>;
    template <typename SUBNET> using alevel4 = ares<32,ares<32,ares<32,SUBNET>>>;

    using anet_type = loss_metric<fc_no_bias<128,avg_pool_everything<
    alevel0<
    alevel1<
    alevel2<
    alevel3<
    alevel4<
    max_pool<3,3,2,2,relu<affine<con<32,7,7,2,2,
    input_rgb_image_sized<150>
    >>>>>>>>>>>>;
    anet_type net;
};

#endif 

如果我不使用anet_type网,它将编译。如何解决问题?也许有另一种方式吗?

c++ objective-c dlib
1个回答
0
投票

你应该张贴:

- Full error logs, so we can help

- Full code with includes

所以我们无法检查您的实施有什么问题。

基本上你可能会错过aaz_type的dlib::

© www.soinside.com 2019 - 2024. All rights reserved.