gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:39:29 25 4
gpt4 key购买 nike

我是编程新手。我已将 dlib 添加到我的 xcode 项目中,如示例中所示 https://github.com/zweigraf/face-landmarking-ios .而且效果很好。

如何添加面部识别等附加功能?我需要将 faces 中的每个人脸图像转换为 128D vector 。我试图重写此 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 net,它会编译。如何解决问题?也许还有其他方法吗?

最佳答案

你应该发布:

- Full error logs, so we can help

- Full code with includes

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

基本上你可能会错过 dlib:: for anet_type

关于c++ - 如何在Xcode项目中使用dlib face_recognition?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54409591/

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