【发布时间】:2019-06-21 21:42:02
【问题描述】:
我是编程新手。 我已将 dlib 添加到我的 xcode 项目中,如示例 https://github.com/zweigraf/face-landmarking-ios 所示。而且效果很好。
如何添加人脸识别等附加功能? 我需要将 faces 中的每个人脸图像转换为 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